Allowed Imports


In the Agentverse β†— (opens in a new tab) Code Editor, you have the freedom to import and utilize a selected set of modules to create your code, while maintaining security and control. These pre-approved modules offer a diverse range of functionalities, allowing you to build complex agents.

The listed modules include:

  • uagents: build fast and lightweight agents for decentralized scenarios using the ΞΌAgents framework. Checkout the ΞΌAgents β†— documentation for more information.

    • Available classes: Model, Context, Protocol.


    from uagents import Context, Model
    class Message(Model):
        text: str
    async def print_message(ctx: Context):
        msg = Message(text=f"Hello there my wallet address is {ctx.wallet}.")
  • json: Seamlessly interact with JSON data structures.

    • Available functions: dumps, loads.


    import json
    some_json =  '{ "agent":"Alice", "age":"1 day"}'
    # JSON to python dictionary
    python_dict = json.loads(some_json)
    # python dictionary to JSON:
    some_json_2 = json.dumps(python_dict)
    # the result is a JSON string equal to some_json:
  • requests: Interact with HTTP requests and responses.

    • Available functions: get, post, put, patch, delete.


    import requests
    response = requests.get('')
    if response.status_code == 200:
    elif response.status_code == 404:
        print('Not Found.')
  • cosmpy: A Python library for interacting with Cosmos-based blockchains. Checkout CosmPy β†— documentation for more information.

    • Full access to all functions and features.


    from cosmpy import aerial
    # Define network configuration, faucet and ledger
    network = aerial.client.NetworkConfig.fetchai_stable_testnet()
    faucet_api = aerial.faucet.FaucetApi(network)
    ledger = aerial.client.LedgerClient(network)
    MINIMUM_BALANCE = 100000000000000000
    async def get_tokens(ctx: Context):
        agent_balance = ledger.query_bank_balance(ctx.wallet)
        if agent_balance < MINIMUM_BALANCE:
            print("Providing wealth to agent...")
  • datetime: Handle date and time operations with ease.

    • Full access to all functions and features.


    import datetime
    today =
    print(f"Today is: {today.year}:{today.month}:{}")
  • enum: Create enumerations with symbolic names and unique values.

    • Full access to all functions and features.


    from enum import Enum
    class Agent(Enum):
        alice = 1
        bob = 2
        carl = 3
  • pydantic: Ensure data validation and settings management.

    • Full access to all functions and features. Example:
    from pydantic import BaseModel
    data = {
        "name": "alice",
        "age": 21
    class User(BaseModel):
        name: str
        age: int
    user = User(**data)

Multi-file Support:

The Agentverse Code Editor enhances your agent development experience with multi-file support, enabling you to tackle complex projects with ease. Leverage this feature to:

  • Interact Between Files: seamlessly import functions, classes, and variables from one file to another.
  • Modular Development: divide your projects into manageable components for streamlined creation.
  • Code Reuse: utilize modules across various sections of your project for efficient development.
  • Enhanced Organization: maintain a structured and organized codebase for easier maintenance.

To create new files you just need to click on + New File on Agentverse β†— (opens in a new tab) inside your managed agent.

You can create a message Python file with the following Model:

from uagents import Model
class Sentence(Model):
    text: str

Then you can just import the Sentence data model to your file and make use of it:

from uagents import Context
from message import Sentence
async def print_message(ctx: Context):
    msg = Sentence(text=f"Hello there my wallet address is {ctx.wallet}.")

Explore the resources at the Agentverse guides β†— and Agentverse concepts β†— for additional guides and documentation resources!