Skip to main content

Overview

The Agentor class is the main entry point for building AI agents. It provides a simple interface to create agents with tools, serve them as APIs, and run them with various configurations.

Constructor

Parameters

name
str
required
The name of the agent. Used in API endpoints and agent identification.
instructions
str
default:"None"
System prompt that defines the agent’s behavior and personality. This guides how the agent responds to user queries.
model
str | LitellmModel
default:"gpt-5-nano"
The LLM model to use. Supports any model from LiteLLM (e.g., "gpt-4o", "gemini/gemini-pro", "anthropic/claude-4"). For non-OpenAI models, use the format "provider/model-name" and provide an api_key.
tools
List[Union[FunctionTool, str, MCPServerStreamableHttp, BaseTool]]
default:"None"
List of tools available to the agent. Can be:
  • FunctionTool objects created with @function_tool
  • String names from the tool registry (e.g., "gmail", "get_weather")
  • MCPServerStreamableHttp instances for MCP servers
  • BaseTool subclasses with capabilities
output_type
type[Any] | AgentOutputSchemaBase
default:"None"
Optional Pydantic model or schema to structure the agent’s output.
debug
bool
default:"False"
Enable debug mode for additional logging and diagnostics.
api_key
str
default:"None"
API key for the LLM provider. Falls back to OPENAI_API_KEY environment variable if not provided.
model_settings
ModelSettings
default:"None"
Advanced model configuration including temperature, top_p, max_tokens, etc. See ModelSettings for details.
skills
List[str]
default:"None"
List of skill file paths to inject into the agent’s system prompt.
enable_tracing
bool
default:"False"
Enable LLM tracing and monitoring via Celesto. Requires CELESTO_API_KEY environment variable.

Methods

run

Run the agent synchronously with a single prompt.
Parameters:
  • input (str): The user’s input prompt
Returns: Agent response as a string or list of strings Example:

arun

Run the agent asynchronously with support for batch processing and fallback models.
Parameters:
  • input: A single prompt string, list of prompts for batch processing, or list of message dictionaries
  • limit_concurrency (int): Maximum concurrent tasks for batch prompts (default: 10)
  • max_turns (int): Maximum agent turns before stopping (default: 20)
  • fallback_models (List[str]): Optional fallback models to try on rate limit or API errors
Returns: Agent response(s) Example:

chat

Interactive chat interface with optional streaming support.
Parameters:
  • input (str): User message
  • stream (bool): Enable streaming responses (default: False)
  • serialize (bool): Serialize output to JSON (default: True)
Returns: Agent response or async iterator for streaming

stream_chat

Stream agent responses in real-time.
Example:

serve

Serve the agent as an HTTP API with A2A protocol support.
Parameters:
  • host: Server host address (default: “0.0.0.0”)
  • port (int): Server port (default: 8000)
  • log_level: Logging level (default: “info”)
  • access_log (bool): Enable access logging (default: True)
Example:

from_md

Create an Agentor instance from a markdown file with YAML frontmatter.
Parameters:
  • md_path: Path to markdown file
  • Other parameters override markdown frontmatter settings
Markdown Structure:
Example:

think

Make the agent “think” through a problem using chain-of-thought reasoning.
Parameters:
  • query (str): The problem or question to analyze
Returns: The agent’s reasoning and conclusion

Usage Examples

Basic Agent

Agent with Custom Model

Agent with Tools

Agent with Model Settings

Serving an Agent

Last modified on May 28, 2026