How do I send LLM cost and usage data to Langfuse or OpenTelemetry?
Export every proxied call to Langfuse or any OpenTelemetry backend, with cost, tokens, latency and your attribution tags. Asynchronous, encrypted credentials, and never prompt or response content.
Cognocient AI can forward every proxied call to the observability tools you already run, so AI cost sits next to your other telemetry. Configure destinations in Integrations (sidebar → Control).
What is sent
| Field | Langfuse | OpenTelemetry |
|---|---|---|
| Model, provider | Generation model and metadata | gen_ai.request.model, gen_ai.system |
| Tokens | usageDetails (input, output, total) | gen_ai.usage.input_tokens, gen_ai.usage.output_tokens |
| Cost | costDetails.total (USD) | cognocient.cost_usd |
| Latency, status | Start/end time; ERROR level for 4xx/5xx | Span duration; error status for 4xx/5xx |
| Attribution tags | Trace name, userId, sessionId, tags and metadata | cognocient.feature, .user, .session, .department, .project, … |
Prompt and response text are never included: Cognocient AI does not store them. This feeds cost and usage analytics in your tools; it is not a prompt-tracing feed.
Connect Langfuse
- In Langfuse, create a project API key pair.
- In Control → Integrations → Langfuse, enter your host (
https://cloud.langfuse.com, the EU/US regional host, or your self-hosted URL), the public key and the secret key. - Click Connect, then Send test event. A trace named
cognocient-connection-testshould appear in Langfuse.
Requires Langfuse v3 or later (or Cloud): cost and usage are sent in the usageDetails / costDetails fields.
Connect an OpenTelemetry backend
- Get your backend's OTLP/HTTP endpoint and any auth header it needs (for example
Authorizationorx-honeycomb-team). - In Integrations → OpenTelemetry (OTLP), enter the endpoint. Cognocient AI appends
/v1/tracesunless it is already there. Add your headers. - Click Connect, then Send test event.
Spans use the OpenTelemetry GenAI semantic conventions with service.name = cognocient. Cognocient AI uses OTLP over HTTP with JSON encoding; gRPC and protobuf-only endpoints are not supported.
Behaviour and limits
- Asynchronous. Delivery is batched (up to 100 events every ~2 seconds) and never blocks or slows a call.
- Best effort. A transient failure is retried once. If a destination stays down, events are dropped once the in-memory queue is full (10,000 events per proxy process), so a dead endpoint cannot exhaust memory. Cognocient AI's own dashboards are unaffected.
- Visible health. Each destination shows Connected, Paused or Failing, the number of calls exported, the last delivery time and the last error.
- HTTPS only, and destinations resolving to private or internal addresses are rejected.
- Cache hits are exported with
cognocient.cache_hit = trueand zero cost. - One destination per type per account.
Related
Prefer to pull rather than push? Scrape spend into Prometheus or Grafana with Prometheus Metrics.
Related articles
OpenAI Responses API
POST /v1/responses on every provider, with streaming and function tools. Budgets, guardrails and routing apply unchanged.
Audio & Rerank Endpoints
Transcription, translation, speech and rerank through Cognocient AI, with the same budgets, guardrails and cost tracking as chat.
OpenAI Batch API
Create batches through Cognocient AI and have each batch's discounted cost attributed to your tags when it finishes. Growth plan.