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

Helicone

Trace Helicone AI Gateway 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="https://oai.helicone.ai/v1",
api_key=os.environ["OPENAI_API_KEY"],
default_headers={"Helicone-Auth": f"Bearer {os.environ['HELICONE_API_KEY']}"},
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "What is the capital of France?"}],
)
print(response.choices[0].message.content)
cetra.flush()

The AI Gateway host ai-gateway.helicone.ai works the same way.

  • Each chat completion is an llm span with the provider helicone.
  • Input and output token counts come from the response.
  • Cost is the model publisher’s price, as described under Limits.
  • With cetra.init(instrument=["openai"]), the endpoint host is in server.address, and cetra names the provider from it.
  • Setup only: no spans of Helicone are captured in the repository.
  • Helicone has no OTLP trace export of its own, so this page traces the client side only: a call through it is never counted twice, because only your app’s instrumentation sends spans for it.
  • Cost is the model publisher’s price when the model names its publisher (vendor/model, or a bare name a publisher has a row for); Helicone’s fees are not included. Models no publisher row matches have no built-in price.
  • 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.