Getting Started
Quickstart
Get your first agent session traced and visible in the dashboard in under five minutes.
Install the SDK
# Core SDK (always needed)
pip install niitaka-sdk
# Include your LLM provider
pip install "niitaka-sdk[openai]" # OpenAI
pip install "niitaka-sdk[anthropic]" # Anthropic
pip install "niitaka-sdk[gemini]" # Google Gemini
pip install "niitaka-sdk[groq]" # Groq
pip install "niitaka-sdk[langchain]" # LangChain
pip install "niitaka-sdk[all]" # EverythingOnly install the extras for providers you actually use. The core package is always required.
Get your API key
Log in to the Niitaka dashboard, go to Organization → API Keys, and create a key. Store it as an environment variable:
NIITAKA_API_KEY=nii_live_xxxxxxxxxxxxConfigure the SDK
Call niitaka.configure() once at startup — before any LLM calls or session starts.
import niitaka
import os
niitaka.configure(
api_key=os.getenv("NIITAKA_API_KEY"),
api_url="https://api.niitaka.ai", # or your self-hosted backend
)Instrument your provider
Instrumentation patches the provider client so every call is automatically captured. You don't need to change any of your existing API calls.
# Call once at startup — before any LLM calls
niitaka.instrument_openai()
# Or instrument multiple providers
niitaka.instrument_openai()
niitaka.instrument_anthropic()
# Or instrument OpenAI, Anthropic, Gemini, and Groq in one call
niitaka.auto_instrument()
# LiteLLM is not included in auto_instrument() — call it separately if you use it
niitaka.instrument_litellm()Wrap your run in a session
Use start_session() as a context manager around your agent run. Everything inside — LLM calls, tool calls, errors — is automatically associated with this session.
import openai
client = openai.OpenAI()
with niitaka.start_session(
goal="Summarise the quarterly report",
agent_id="report-summariser", # matches an agent in the dashboard
):
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a concise summariser."},
{"role": "user", "content": "Summarise: ..."},
],
)
print(response.choices[0].message.content)agent_id should match the Agent you created in the dashboard. If it doesn't exist yet, Niitaka will create it automatically on first use.
View your session
Run your agent. Open the Sessions dashboard — your session will appear within seconds with full cost, latency, and event breakdown.