fetch-logo
ConceptsConceptsGuidesGuidesExamplesExamplesReferencesReferencesAPIsAPIs
GitHub (opens in a new tab)
  • Examples
      • Create your first agent
      • Interval task with Agents
      • Multiple agents communication
      • Local Network Interaction
      • Agents communication
      • Agents storage
      • Table booking service with Agents
      • Cleaning service with Agents
      • Send tokens with Agents
      • Verify messages with Agents
      • Communicating with other agents wallet
      • Agents communication using Agentverse Mailbox service
      • Agents Broadcast
      • Agents Name Service
      • Query an agent using a proxy API
      • Register a dice roll agent as a Function
      • Register a coin toss agent as a Function
      • Register a local agent as a Function
      • Using News API to build network of Primary and Secondary functions
      • Locally Hosted Agent with LangChain Integration
      • Hugging face API agent as a Function
      • On Query decorator example
      • Agents and Functions Creation using APIs
      • Adding Secret to agent using Agentverse API
      • React app with agents 'on_query' decorator
      • Open Dialogue Chit-Chat
      • Predefined Dialogue Chit-Chat
      • Chat API example
      • DeltaV Dialogue Chit-Chat
  • Examples
      • Create your first agent
        • Introduction
        • Guide
        • The agent
        • Expected Output
      • Interval task with Agents
      • Multiple agents communication
      • Local Network Interaction
      • Agents communication
      • Agents storage
      • Table booking service with Agents
      • Cleaning service with Agents
      • Send tokens with Agents
      • Verify messages with Agents
      • Communicating with other agents wallet
      • Agents communication using Agentverse Mailbox service
      • Agents Broadcast
      • Agents Name Service
      • Query an agent using a proxy API
      • Register a dice roll agent as a Function
      • Register a coin toss agent as a Function
      • Register a local agent as a Function
      • Using News API to build network of Primary and Secondary functions
      • Locally Hosted Agent with LangChain Integration
      • Hugging face API agent as a Function
      • On Query decorator example
      • Agents and Functions Creation using APIs
      • Adding Secret to agent using Agentverse API
      • React app with agents 'on_query' decorator
      • Open Dialogue Chit-Chat
      • Predefined Dialogue Chit-Chat
      • Chat API example
      • DeltaV Dialogue Chit-Chat
Examples
Getting Started
Create your first agent

Create your first Agent

Introduction

Welcome to your journey into the world of AI Agents! This example will equip you with the tools to create your very first intelligent agent using the uAgents Python library.

Ready to get started?

The code provided in this example can be run on any platform which supports Python with the necessary install permissions. As you progress throughout the examples, you'll get to understand topics in an increasingly difficult way.

Let's get started and explore the basic concepts you need to develop your first Agent!

Guide

  • Agents - uAgents Framework ↗️
  • Installing the uAgents Framework ↗️
  • Creating your first agent ↗️
  • Agents address ↗️

The agent

agent.py
# Import necessary classes from the uAgents library
from uagents import Agent, Context
 
# Create an agent named alice
agent = Agent(name="alice")
 
# Function to be called when the agent is started
@agent.on_event("startup")
async def introduce_agent(ctx: Context):
    # Print a greeting message with the agent's name and its address
    print(f"Hello, I'm agent {agent.name} and my address is {agent.address}.")
 
# Run the agent only when the script is executed directly
if __name__ == "__main__":
    agent.run()

Expected Output

Hello, I'm agent alice and my address is agent1qtx288pfqm9e5qausyzdy6zmmn65ytwygqdq2h7d4g0q80ft04rygg96jtt.

Was this page helpful?

ExamplesInterval task with Agents
footer-logo

Main website

Integrations

Events

We’re hiring!

Twitter (opens in a new tab)Telegram (opens in a new tab)Discord (opens in a new tab)GitHub (opens in a new tab)Youtube (opens in a new tab)LinkedIn (opens in a new tab)Reddit (opens in a new tab)
Sign up for developer updates