Observability for TrueFoundry with Opik
TrueFoundry AI Gateway is the proxy layer that sits between your applications and the LLM providers and MCP Servers. It is an enterprise-grade platform that enables users to access 1000+ LLMs using a unified interface while taking care of observability and governance.
The gateway exports OpenTelemetry traces, and Opik ingests them at its native OTLP endpoint. You get one trace for every request that passes through the gateway, without a change to your application code.
Gateway Overview
The TrueFoundry AI Gateway gives you these features:
- Unified OpenAI-compatible endpoint: One endpoint routes to any supported model, from a commercial provider or from your own deployment.
- Native MCP support: Connect enterprise tools to your agents, and apply OAuth2, RBAC, and metadata policies to each tool call.
- Routing and reliability: Load balancing by weight, latency, or priority, with automatic fallback chains and retries.
- Governance controls: Rate limits, quotas per user and per team, budget alerts, spend caps, and scoped API keys with RBAC.
- Observability: Token, latency, cost, and error metrics for each request, with OpenTelemetry export to a platform such as Opik.
- Data sovereignty: VPC and on-premises deployment options for compliance and data privacy.
To learn more about the gateway, see the TrueFoundry AI Gateway documentation.
Account Setup
Comet provides a hosted version of the Opik platform. Simply create an account and grab your API Key.
You can also run the Opik platform locally, see the installation guide for more information.
Integration Options
You can connect TrueFoundry to Opik in two ways. The two options work together, so you can also use both.
Gateway Trace Export
The gateway exports OpenTelemetry traces over OTLP. Opik accepts these traces at its native OTLP endpoint. TrueFoundry also documents this setup, with a screenshot of each field, on the Comet Opik page in the TrueFoundry documentation.
Prerequisites
- A TrueFoundry account with access to the AI Gateway. See the TrueFoundry quick start.
- An Opik account, on Opik Cloud or on your own deployment.
- Your Opik API key, your Opik workspace name, and the name of the Opik project for the traces.
Opik ingests traces only. Keep the Otel Metrics Exporter Configuration toggle disabled. Opik also accepts HTTP transport only, so do not select the gRPC configuration.
Trace Endpoint
The Opik OTLP base endpoint is /api/v1/private/otel. TrueFoundry sends traces to the signal-specific endpoint, which is the base endpoint with /v1/traces at the end. TrueFoundry does not add this path for you, so enter the full path in the Endpoint field.
Opik Cloud
Self-hosted deployment
Enterprise deployment
Configuring the Exporter
Get your Opik API key, workspace, and project
Open your Opik account settings and copy your API key. Note the workspace name from the workspace switcher. Then choose the name of the project for the traces. Opik creates the project on the first trace if it does not exist.
Open the OTEL configuration in TrueFoundry
In the TrueFoundry dashboard, go to AI Gateway → Controls → Settings. Find the OTEL Config section and click the edit button.
Enable the traces exporter
Turn on the Otel Traces Exporter Configuration toggle, then enter the values below.
The Authorization header value is the raw API key. Do not add the Bearer prefix.
Configuration Reference
For more information about the Opik OTLP endpoint and its headers, see the OpenTelemetry integration guide.
Troubleshooting
No traces appear in Opik
Check that the Endpoint field ends with /v1/traces. TrueFoundry does not add this path for you, so the base
OTLP endpoint on its own returns an error. Check also that the protocol is HTTP Configuration and that the
encoding is Proto.
The gateway reports an authentication error
The Authorization header takes the raw Opik API key. Remove the Bearer prefix if you added one. Then check
that the Comet-Workspace header matches your Opik workspace name exactly.
Traces land in the wrong project
The projectName header sets the project. Opik uses the project named Default Project when this header is
absent or empty. Add the header, then send a new request.
Metrics do not appear in Opik
This is expected. Opik ingests traces only, and it rejects OTLP metrics. Keep the Otel Metrics Exporter Configuration toggle disabled.
Application Tracing
The gateway exposes an OpenAI-compatible API, so you can use the Opik OpenAI SDK wrapper to log gateway calls as generations in Opik. Use this option when you want to group several LLM calls into one trace.
Installation
First, ensure you have both opik and openai packages installed:
Configuring Opik
Configure the Opik Python SDK for your deployment type. See the Python SDK Configuration guide for detailed instructions on:
- CLI configuration:
opik configure - Code configuration:
opik.configure() - Self-hosted vs Cloud vs Enterprise setup
- Configuration files and environment variables
Configuring TrueFoundry
You need a TrueFoundry API key and the base URL of your gateway.
- Base URL:
https://gateway.truefoundry.aifor TrueFoundry SaaS. For a self-hosted gateway, get the base URL from the Code Snippet tab of the TrueFoundry playground. - API key: Create a Personal Access Token or a Virtual Account Token in the Access section of the TrueFoundry platform. See Generating TrueFoundry API keys.
Set your configuration as environment variables:
Or set them programmatically:
Simple LLM Call
The model value is the TrueFoundry model ID, in the format provider_account/model_name. Copy it from the Code
Snippet tab of the TrueFoundry playground. See the TrueFoundry Chat Completions
API for the full request format.
Multi-Step Traces
If you have multiple steps in your LLM pipeline, you can use the @track decorator to log the traces for each step. If TrueFoundry is called within one of these steps, the LLM call will be associated with that corresponding step:
The trace will show nested LLM calls with hierarchical spans.
TrueFoundry Documentation
- Comet Opik integration — the TrueFoundry side of the OpenTelemetry export, with a screenshot of each field.
- AI Gateway quick start — create an account, add models, and get your base URL, API key, and model ID.
- Chat Completions API — the unified request format for all supported models.
- Authentication — Personal Access Tokens and Virtual Account Tokens.
Next steps
- Log traces — add tags, metadata, and feedback scores to the traces from your gateway.
- Evaluate your LLM application — build datasets from gateway traffic and score it.
- Gateway integrations — the other LLM gateways that Opik supports.
Further Improvements
If you have suggestions for improving the TrueFoundry integration, please let us know by opening an issue on GitHub.