Skip to main content
5 minutes to get up and running. Just 3 lines of code to start tracking.
Follow these steps to integrate AgentBasis into your application.

1. Install the SDK

pip install agentbasis

2. Get Your Credentials

You’ll need two things from the AgentBasis dashboard:
1

API Key

Go to Dashboard → Settings → API Keys and copy your API key.
2

Agent ID

Go to Dashboard → Agents and create a new agent (or select an existing one) to get the Agent ID.

3. Set Environment Variables

Add your credentials to your environment. The SDK will read them automatically.
# .env
AGENTBASIS_API_KEY=your-api-key
AGENTBASIS_AGENT_ID=your-agent-id
Load with python-dotenv or your framework’s env loader.

4. Initialize the SDK

Add this at the top of your main application file:
import agentbasis

# Reads from AGENTBASIS_API_KEY and AGENTBASIS_AGENT_ID env vars
agentbasis.init()

5. Instrument Your LLM

Choose your LLM provider and add one line to start tracking:
from agentbasis.llms.openai import instrument
instrument()

# Use OpenAI as normal - all calls are now tracked
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello"}]
)

6. Track Custom Functions (Optional)

Use the @trace decorator to track any function:
from agentbasis import trace

@trace
def process_user_request(query):
    # Your logic here
    return result

What’s Next?

Core Concepts

Learn about context, sessions, and manual tracing

LangChain

Trace chains, agents, and tools

Pydantic AI

Monitor Pydantic AI agents

API Reference

Complete function reference