Python API#

Full programmatic control over Pantheon agents and teams.

Overview#

The Python API provides complete control over:

  • Agent creation and configuration

  • Team orchestration

  • Toolset integration

  • Memory management

  • Model selection

Quick Example#

import asyncio
from pantheon.agent import Agent

async def main():
    agent = Agent(
        name="assistant",
        instructions="You are a helpful assistant."
    )

    # Single query
    response = await agent.run("What is 2 + 2?")
    print(response.content)

    # Interactive chat
    await agent.chat()

asyncio.run(main())

Core Classes#

Agent

The fundamental building block. Represents an AI-powered entity.

from pantheon.agent import Agent

agent = Agent(
    name="assistant",
    instructions="...",
    tools=[...]
)

See Agent API for details.

Team

Multiple agents working together.

from pantheon.team import PantheonTeam

team = PantheonTeam([agent1, agent2, agent3])

See Team API for team patterns.

ToolSet

Extend agent capabilities with tools.

from pantheon.toolsets import FileManagerToolSet

agent = Agent(
    name="dev",
    instructions="You are a developer."
)

# Add toolsets at runtime
await agent.toolset(FileManagerToolSet("files"))

See Toolsets API for available toolsets.

Async Pattern#

All Pantheon APIs are async:

import asyncio

async def main():
    # Your Pantheon code here
    pass

asyncio.run(main())

For Jupyter notebooks:

# In Jupyter, you can use await directly
response = await agent.run("Hello!")

Integration#

With FastAPI

from fastapi import FastAPI
from pantheon.agent import Agent

app = FastAPI()
agent = Agent(name="api_assistant", ...)

@app.post("/chat")
async def chat(message: str):
    response = await agent.run(message)
    return {"response": response.content}

With LangChain

Pantheon can work alongside LangChain:

# Use Pantheon agents for specific tasks
# Use LangChain for chains/pipelines

Next Steps#