Skip to main content

Build an Agent

Use the Agentor class to initialize an Agent providing the name, instructions, and tools. You can run the Agent with the run method or stream the response with the stream method.
from agentor.tools import GetWeatherTool
from agentor import Agentor

agent = Agentor(
    name="Weather Agent",
    model="gpt-5-mini",
    tools=[GetWeatherTool()]
)
result = agent.run("What is the weather in London?")
print(result)

Connect to a tool

Agents has access to tools to perform tasks and get information from the world.
Learn more about LLM tool use here.
You can define your own tools or use the ones provided by Celesto AI ToolHub.
from agentor.tools import GetWeatherTool
from agentor import Agentor

agent = Agentor(
    name="Weather Agent",
    model="gpt-5-mini",
    tools=[GetWeatherTool()],  # 100+ Celesto AI managed tools — plug-and-play
)
result = agent.run("What is the weather in London?")
print(result)

Stream the response

You can stream the response from the Agent with the stream method.
from agentor.tools import GetWeatherTool
from agentor import Agentor
import asyncio

agent = Agentor(name="Weather Agent", tools=[GetWeatherTool()])

async def main():
    async for event in agent.stream_chat("How is the weather in Tokyo?"):
        print(event, flush=True)

if __name__ == "__main__":
    asyncio.run(main())
The response is streamed as a JSON object with the following fields:
  • type: The type of event.
  • message: The message from the Agent.
  • chunk: The chunk of the message.
  • tool_action: The tool action from the Agent.
  • reasoning: The reasoning from the Agent.
  • raw_event: The raw event from the Agent.

Tracing and observability

Agentor supports tracing out of the box. Traces capture agent runs and tool calls so you can inspect them in Celesto.
1

Set your Celesto API key

Add your Celesto API key to the environment.
export CELESTO_API_KEY="cel_..."
2

Enable tracing

Choose the setup that fits your workflow.
After you run the agent, open the Celesto dashboard to view the trace.

Troubleshooting tracing setup

  • Confirm you set CELESTO_API_KEY in the same environment where you run the agent.
  • If you set CELESTO_DISABLE_AUTO_TRACING=true, enable tracing explicitly with enable_tracing=True.