Skip to content
GitHubLog inStart free
cetra is not released yet. These docs describe the development version.

vLLM

Trace vLLM model calls with cetra through the OpenAI client.

Terminal window
pip install "cetra-sdk[openai]" openai
import os
import cetra
from 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()
  • Each chat completion is an llm span with the provider openai.
  • 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.
  • cetra cannot tell a vLLM server from OpenAI by its host, so the provider shows as openai and 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 localhost is not in cetra’s host table, so the provider is openai.
  • 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. Use cetra.init(instrument=["openai"]) or OpenLLMetry.
  • If a field is missing, look at the span’s Attributes tab and compare it with Span attributes.