vLLM
Trace vLLM 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="http://localhost:8000/v1", api_key=os.environ["VLLM_API_KEY"])response = client.chat.completions.create( model="<MODEL_NAME>", 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: "http://localhost:8000/v1", apiKey: process.env.VLLM_API_KEY });await client.chat.completions.create({ model: "<MODEL_NAME>", 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 provideropenai. - Input and output token counts come from the response.
- No built-in price: add a custom model price in Settings → Model prices to get a cost.
Limits
Section titled “Limits”- cetra cannot tell a vLLM server from OpenAI by its host, so the provider shows as
openaiand the built-in prices do not apply. Add a custom model price for the model you serve. - No spans of vLLM are captured in the repository. The host
localhostis not in cetra’s host table, so the provider isopenai. - The built-in prices have no vLLM rows, so cost is empty until you add a custom model price in Settings → Model prices.
- 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.