DeepInfra
Trace DeepInfra model calls with cetra through the OpenAI client.
Install
Section titled “Install”pip install "cetra-sdk[openai]" openainpm install @cetra-ai/sdk @arizeai/openinference-instrumentation-openai openaiSet up
Section titled “Set up”import os
import cetrafrom openai import OpenAI
cetra.init(instrument=["openai"])
client = OpenAI(base_url="https://api.deepinfra.com/v1/openai", api_key=os.environ["DEEPINFRA_TOKEN"])response = client.chat.completions.create( model="meta-llama/Meta-Llama-3.1-8B-Instruct", messages=[{"role": "user", "content": "What is the capital of France?"}],)print(response.choices[0].message.content)
cetra.flush()import { init } from "@cetra-ai/sdk";import { openai } from "@cetra-ai/sdk/openai";import OpenAI from "openai";init({ apiKey: process.env.CETRA_API_KEY, instrument: [openai(OpenAI)] });const client = new OpenAI({ baseURL: "https://api.deepinfra.com/v1/openai", apiKey: process.env.DEEPINFRA_TOKEN });await client.chat.completions.create({ model: "meta-llama/Meta-Llama-3.1-8B-Instruct", messages: [{ role: "user", content: "What is the capital of France?" }],});What you get
Section titled “What you get”- Each chat completion is an
llmspan with the providerdeepinfra. - Input and output token counts come from the response.
- Cost comes from the built-in prices.
- With
cetra.init(instrument=["openai"]), the endpoint host is inserver.address, and cetra names the provider from it.
Limits
Section titled “Limits”- No spans of DeepInfra are captured in the repository. cetra maps the host
api.deepinfra.comto the providerdeepinfra. - With plain OpenInference or the official OpenAI instrumentation in Python, the provider shows as
openai: they do not record the endpoint. Usecetra.init(instrument=["openai"])or OpenLLMetry. - If a field is missing, look at the span’s Attributes tab and compare it with Span attributes.
- Traces: read the trace as a tree and a timeline.
- Cost and tokens: how cost is computed from the token counts.
- Custom model prices: price a model the built-in prices do not cover.