Every request through Spro is logged to your project's usage logs with a trace ID — a value that ties a request (or a whole multi-step agent run) together in the dashboard. You can bring your own trace ID with headers, set one in the request body, or let Spro infer one.
How a trace ID is chosen
Spro resolves the trace ID for each request in this order:
| Priority | Source | trace_source value |
|---|---|---|
| 1 | x-spro-trace-id or x-trace-id request header | header |
| 2 | metadata.trace_id in the request body (Responses API style) | request |
| 3 | The request's own ID — generated per request | inferred |
Priority 3 is why this works with zero setup: even if you never send a trace ID, every usage-log row is traceable — a single request is its own trace. Send a shared ID across multiple requests (one per agent step, for example) and they all roll up under the same trace.
Sending a trace ID
Headers (any endpoint)
curl https://spro.hridaai.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer spro-xxxxxxxxxxxxxxxx" \ -H "x-spro-trace-id: run_9f2c1a" \ -H "x-spro-trace-name: mortgage-agent" \ -d '{ "model": "gpt-oss-20b", "messages": [{"role": "user", "content": "Hello!"}] }'| Header | Purpose |
|---|---|
x-spro-trace-id | Your trace ID — group requests under one trace. (x-trace-id also works.) |
x-spro-trace-name | Human-readable name for the trace, up to 512 chars. |
x-spro-title | Name of the calling app, shown in the dashboard (x-openrouter-title also works). |
referer / HTTP-Referer | The calling app's URL — picked up automatically. |
Body metadata (Responses API)
curl https://spro.hridaai.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer spro-xxxxxxxxxxxxxxxx" \ -d '{ "model": "gpt-oss-20b", "input": "Summarize this document", "metadata": { "trace_id": "run_9f2c1a", "trace_name": "doc-summary" } }'Python — one trace across an agent loop
from openai import OpenAI
client = OpenAI( base_url="https://spro.hridaai.com/v1", api_key="spro-xxxxxxxxxxxxxxxx",)
trace_id = "run_9f2c1a"messages = []
for step in ["Extract the loan amount", "Classify the risk", "Draft a reply"]: messages.append({"role": "user", "content": step}) response = client.chat.completions.create( model="gpt-oss-20b", messages=messages, extra_headers={ "x-spro-trace-id": trace_id, "x-spro-trace-name": "mortgage-agent", }, ) messages.append(response.choices[0].message)
# All three calls share trace_id → they group as one trace in the dashboard.# Anthropic SDK — same headers workmessage = client.messages.create( model="anthropic/claude-sonnet-4", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], extra_headers={"x-spro-trace-id": trace_id},)Resolved headers on every response
Every response — streamed or not — carries headers telling you what was actually served:
| Header | When |
|---|---|
x-spro-resolved-model | Always — the exact model ID that served this request. |
x-spro-upgraded-from | Only when the requested model was inactive/retired and Spro auto-upgraded to its successor. |
x-spro-upgrade-reason | Only when upgraded, alongside x-spro-upgraded-from — model_retired or model_deprecated. |
x-spro-deprecation-notice | Only when the served model has a retirement date scheduled. |
response = client.chat.completions.create( model="gpt-oss-20b", messages=[{"role": "user", "content": "Hello!"}],)
print(response.headers.get("x-spro-resolved-model")) # gpt-oss-20bprint(response.headers.get("x-spro-upgraded-from")) # e.g. old-model-id, if upgradedprint(response.headers.get("x-spro-deprecation-notice")) # e.g. retiring 2026-12-31, if retiringLog these alongside your own telemetry — they're the source of truth for what you were billed for.
Streaming and cancellation
When you disconnect from a stream early, Spro still records usage — it never silently logs a cancelled stream as zero tokens. How the tokens are accounted depends on a per-provider strategy (estimate, exact, or zero) that Spro sets in its catalog — you don't configure anything.
# A client disconnect mid-stream...response = client.chat.completions.create( model="gpt-oss-20b", messages=[{"role": "user", "content": "Write a long story"}], stream=True, extra_headers={"x-spro-trace-id": "run_9f2c1a"},)for chunk in response: if chunk.choices and chunk.choices[0].delta.content == "stop-here": break # disconnect — the request still lands in your usage logs, # under this same trace ID, with accounted tokensFull details — the strategy table, JavaScript abort examples, and what shows up in your logs — in Stream Cancellation.
Every surface is traced
The same trace headers work on every gateway endpoint:
Chat Completions
response = client.chat.completions.create( model="gpt-oss-20b", messages=[{"role": "user", "content": "Hello!"}], extra_headers={"x-spro-trace-id": trace_id},)Responses API
response = client.responses.create( model="gpt-oss-20b", input="Hello!", extra_headers={"x-spro-trace-id": trace_id},)Anthropic Messages
message = client.messages.create( model="anthropic/claude-sonnet-4", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], extra_headers={"x-spro-trace-id": trace_id},)Embeddings
response = client.embeddings.create( model="text-embedding-3-small", input="The quick brown fox", extra_headers={"x-spro-trace-id": trace_id},)Image generation
result = client.images.generate( model="openai/gpt-image-1", prompt="A white Siamese cat wearing a tiny wizard hat", extra_headers={"x-spro-trace-id": trace_id},)Agent traces (beta)
For full span-level tracing of agent runs — every agent step, LLM generation, and tool call as a tree — point the OpenAI Agents SDK's trace exporter at Spro:
Beta
Agent trace ingestion is in beta. The exporter, span stitching to usage logs, and the dashboard views are still evolving.
from agents import set_trace_processorsfrom agents.tracing.processors import BackendSpanExporter, BatchTraceProcessor
set_trace_processors([ BatchTraceProcessor( BackendSpanExporter( endpoint="https://spro.hridaai.com/v1/traces/ingest", api_key="YOUR_SPRO_API_KEY", ) )])Spans are ingested idempotently and generation spans are stitched to the usage logs of the gateway calls they made — see the Agents SDK integration and the Trace Ingest API.
