Basic Setup
Initialize the SDK with your app name:Collector Configuration
Configure the Anyway collector endpoint to send your traces.Environment Variables (Recommended)
Set environment variables to configure the SDK:For gRPC endpoints, omit the
http:// or https:// prefix. For HTTP endpoints, include the full URL with prefix.Direct Configuration
You can also pass configuration directly toinit():
Configuration Options
| Parameter | Type | Description |
|---|---|---|
app_name | string | Required. Name of your application for trace grouping |
api_endpoint | string | Collector endpoint URL. Overrides TRACELOOP_BASE_URL |
headers | dict | Authentication headers. Overrides TRACELOOP_HEADERS |
exporter | Exporter | Custom OpenTelemetry exporter for advanced use cases |
pricing_json_path | string | Path to a custom pricing JSON file for cost calculations |
disable_batch | boolean | Disable batching of traces (useful for debugging) |
Custom Exporters
For advanced use cases, you can provide a custom OpenTelemetry exporter:Custom Pricing
You can provide your own pricing data to calculate costs for models not included in the default pricing or to override existing prices:Default Pricing
If no custom pricing JSON is provided, Anyway uses a default pricing file that includes pricing for popular models from OpenAI, Anthropic, Google, Meta, and other providers.Pricing JSON Format
The pricing JSON file should follow this structure:promptPrice: Cost per 1K input tokenscompletionPrice: Cost per 1K output tokens
Environment-Based Configuration
A common pattern is to configure based on environment:Next Steps
Tracing LLM Calls
Trace OpenAI and Anthropic API calls