Skip to main content
Available via: Cloudflare’s built-in OpenTelemetry exporter (any language calling through the gateway). This is not a Zespan SDK wrapper — see Send traces from any OTel-instrumented app for how the underlying endpoint works. Configuration is dashboard-based, not code.
If you already route LLM traffic through Cloudflare AI Gateway, its built-in OpenTelemetry exporter automatically emits a trace span for every request the gateway processes, with no changes to the apps calling it.

Setup

1

Open your gateway's Settings

In the Cloudflare dashboard, go to your AI Gateway, then the Settings tab.
2

Add an OTEL exporter

Add a new exporter and set:
  • URL: https://api.zespan.com/v1/traces
  • Headers: x-api-key: zsp_... (or use the Authorization field with a Secrets Store secret holding Bearer zsp_...)
  • Content type: json or protobuf — Zespan accepts both
3

Save

Every subsequent request through this gateway is exported as an OTel trace.

What gets captured

Every request routed through the gateway is exported regardless of the calling app’s language or framework. Zespan reads the model, the input and output token counts and Cloudflare’s own attribute names for the provider (gen_ai.model.provider) and for the prompt and completion text (gen_ai.prompt_json, gen_ai.completion_json). Text is stored only if your project’s prompt storage setting allows it (Cloudflare documents no way to switch the content off, so check that setting before you add the exporter). Calls are priced by Zespan from the model and token counts; Cloudflare’s cost estimate (gen_ai.usage.cost) is kept as evidence next to the span and is used as the price only for a model Zespan has no price for, with GATEWAY_COST_FALLBACK=on on a self-hosted deployment.
Attribute names come from Cloudflare’s published documentation and can change between versions. Use the Gateway and OTLP data card to see what actually arrives. The gateway is recognised by these attribute names.

Verify

Send one request through the gateway, then open Settings → Instrumentation → Gateway and OTLP data and press Refresh. See Instrumentation.

Using the SDK too

If an app also uses the Zespan SDK for the same call, Zespan can count its tokens and cost once when merging is on (see the linked section). Cloudflare reads its own trace headers, cf-aig-otel-trace-id and cf-aig-otel-parent-span-id, and the SDK’s gatewayCorrelation option sends exactly those (plus traceparent) for the hosts you list, so the gateway’s span nests under the SDK span. Cloudflare does not document the provider’s response id on its span, so turn on gatewayCorrelation for this gateway.

Next steps