Skip to navigation

Helicone (tracing)

Helicone’s Manual Logger records calls to custom, self-hosted, and provider-backed models. The Respan Helicone instrumentation observes that same manual-logger lifecycle and emits canonical Respan spans without replacing or bypassing Helicone’s own logging.

The integration supports helicone-helpers >=1.2.1,<1.3.0 for Python and @helicone/helpers >=1.8.3 <1.9.0 for TypeScript.

Create an account at platform.respan.ai and grab an API key.

Run npx @respan/cli setup to set up with your coding agent.

See Helicone gateway setup to replace Helicone Gateway routing with the OpenAI-compatible Respan Gateway.

Setup

1

Install packages

pip install respan-ai respan-instrumentation-helicone "helicone-helpers~=1.2.1" openai
2

Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
export HELICONE_API_KEY="YOUR_HELICONE_API_KEY"
export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"

RESPAN_API_KEY exports traces to Respan. HELICONE_API_KEY keeps the Manual Logger connected to Helicone. This example calls OpenAI directly, so it also needs OPENAI_API_KEY; use the credential required by the provider in your callback. RESPAN_BASE_URL is optional for a self-hosted or non-default Respan endpoint.

3

Initialize and run

Initialize Respan before the first Helicone Manual Logger call.

import os
from helicone_helpers import HeliconeManualLogger
from openai import OpenAI
from respan import Respan
from respan_instrumentation_helicone import HeliconeInstrumentor
respan = Respan(
api_key=os.environ["RESPAN_API_KEY"],
app_name="helicone-manual-logger",
instrumentations=[HeliconeInstrumentor()],
)
helicone = HeliconeManualLogger(api_key=os.environ["HELICONE_API_KEY"])
openai = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
request = {
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Say hello in three languages."}],
}
def call_model(recorder):
response = openai.chat.completions.create(**request)
recorder.append_results(response.model_dump())
return response
try:
response = helicone.log_request(
request=request,
operation=call_model,
provider="openai",
additional_headers={
"Helicone-User-Id": "user_123",
"Helicone-Session-Id": "conversation_456",
"Helicone-Property-Environment": "production",
},
)
print(response.choices[0].message.content)
finally:
respan.flush()
respan.shutdown()
4

View your trace

Open the Traces page to inspect the Helicone span’s model, provider, input, output, usage, status, timing, and correlation attributes.

What is traced

The instrumentors patch Helicone’s published Manual Logger methods rather than the underlying provider SDK.

LanguageManual Logger surface
Pythonlog_request(), direct send_log(), log_builder(), and the builder’s async send_log() lifecycle
TypeScriptlogRequest(), logStream(), logSingleStream(), logSingleRequest(), direct sendLog(), and HeliconeLogBuilder

The emitted span type is inferred from the payload:

Helicone payloadRespan log type
Chat messages, including OpenAI-, Anthropic-, and Google-shaped contentchat
Prompt and text completiontext
Embedding input and vectorsembedding
_type=tool custom eventtool
_type=vector_db custom eventtask
_type=data custom eventtask

When Helicone supplies them, Respan retains model and provider identity, request and response content, token usage, tool definitions and calls, streaming timing, HTTP status, and errors. An operation that fails before Helicone reaches its shared logging sink still produces one error span rather than a duplicate success/error pair.

Configuration

ParameterTypeDefaultDescription
api_key / apiKeystr | None / string | undefinedRESPAN_API_KEYRespan API key used to export traces.
base_url / baseURLstr | None / string | undefinedRESPAN_BASE_URLOptional Respan trace export endpoint.
instrumentationslist / RespanInstrumentation[][]Include HeliconeInstrumentor() or new HeliconeInstrumentor() to activate tracing.
capture_contentboolTruePython option that controls request and response content capture.
traceContentbooleantrueTypeScript option that controls request and response content capture.

Disable content capture

Disable content capture when prompts or responses may contain sensitive data:

from respan_instrumentation_helicone import HeliconeInstrumentor
instrumentor = HeliconeInstrumentor(capture_content=False)

Model, provider, usage, timing, status, errors, and safe correlation fields remain available. Helicone API keys, authorization headers, unknown headers, and structured secret fields are never copied into spans.

Correlation attributes

The instrumentors recognize Helicone’s safe correlation headers:

HeaderRespan behavior
Helicone-User-IdSets the customer identifier.
Helicone-Session-IdSets the session or conversation identifier.
Helicone-Property-*Preserved as safe association properties or Helicone metadata.

Respan propagated attributes also stay attached to the manual-log span, including parent workflow context captured when a delayed builder is created.

Avoid duplicate telemetry

Helicone instrumentation is explicit-only. Activate it only in processes that use HeliconeManualLogger.

Do not also activate a provider-specific instrumentor for the same provider call unless two spans for one logical operation are intentional. Likewise, a request routed through Respan Gateway already creates a gateway log; wrapping it in an instrumented Helicone manual log adds a separate manual-log span. See the gateway guide for the simpler gateway-only migration path.