Guides & Tutorials
These guides walk through real tasks with the ANTS Platform Python SDK (ants-platform). Each one uses only shipped SDK calls and points you to the screens where the results show up.
Start here
Install the SDK, trace a small agent end to end, and find the trace in the product.
Fix missing traces, record errors, find slow steps and turn failures into test cases.
Configure environments, sampling, masking and flushing for production services.
More guides
Trace collaborating agents.
Trace retrieval and generation steps.
Find and reduce AI spend.
Before you start
Every guide assumes the SDK is installed and configured from environment variables.
Create the key pair under Settings > API Keys in your project. The host is the URL of your ANTS Platform app. See API Keys.
The Python SDK requires an agent_name on the outermost observation of every trace. Open each unit of work with start_as_current_observation(..., as_type="agent", agent_name="..."). Nested observations, @observe() functions and OpenAI drop-in calls inside it inherit the agent name. Without one, the SDK raises ValueError: agent_name is required.
Choose an integration path
| Path | Use it when | Docs |
|---|---|---|
| Python SDK, manual observations | You want full control over spans, generations and tools | Python SDK |
OpenAI drop-in (ants_platform.openai) | Your code calls the OpenAI client | Python SDK |
LangChain CallbackHandler | You run LangChain chains or agents | LangChain |
CrewAI EventListener | You run CrewAI crews | CrewAI |
| OpenTelemetry (OTLP) | You already emit OpenTelemetry spans | Sending Data In |
For JavaScript, TypeScript or Java, see the JS/TS SDK and Java SDK pages.
LangChain
CrewAI
OpenTelemetry
Point any OTLP/HTTP exporter at https://<your-host>/api/public/otel/v1/traces with an Authorization: Basic <base64(public_key:secret_key)> header. See Sending Data In.
Common patterns
The patterns below assume a client configured from environment variables.
Request and response logging
Multi-step workflow
Retries
Call with_retry inside an agent observation so it inherits the agent name.
Where results show up
| What you want to see | Where in the product |
|---|---|
| Individual traces and their observation tree | Discover AI > Tracing (Traces) |
Multi-turn conversations grouped by session_id | Discover AI > Sessions (Sessions) |
| Spend by model and user | Gauge AI > Cost Dashboard (Cost & Latency Dashboards) |
| p95 and p99 latency by model | Gauge AI > Latency Dashboard |
| Usage trends | Gauge AI > AI Usage (AI Usage) |
| Cost and performance per model | Gauge AI > Cost Performance Metrics and Latency & Analytics (Cost & Performance Metrics) |
| Cheaper model recommendations | Gauge AI > AI Optimizer (AI Optimizer) |
| Your own charts | Custom Dashboards |