Skip to Content
Launching the open-source gateway

Users & identifiers

Tag gateway requests with the user, conversation, trace, and properties they belong to, and cap each user's spend.

Respan params are fields you send next to the standard request body. The gateway reads them, removes them, and never sends them to the provider. Use them to say who the request is for, which conversation and trace it belongs to, and which properties you want to filter by in Logs.

Terminal
curl https://gateway.respan.ai/chat/completions \ -H "Authorization: Bearer $RESPAN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello!"}], "customer_identifier": "user_8842", "thread_identifier": "thread_7f3a", "metadata": {"feature": "support-chat", "environment": "production"} }'

Parameters

ParameterTypeDefaultDescription
customer_identifierstringNoneThe end user the request belongs to. Drives per-customer analytics, budgets, and rate limits.
customer_paramsobjectNonecustomer_identifier plus name, email, and rate_limit.
thread_identifierstringNoneGroups the requests of one conversation.
trace_unique_idstringThe request’s gateway request IDThe trace to put the request in.
trace_namestringNoneThe trace’s name, used for the root row when span_name is not set.
span_namestringThe call’s own nameThe name of the request’s root row.
metadataobjectNoneYour own key-value pairs, shown as custom properties. Values are stored as strings.
disable_logbooleanfalsetrue keeps the input and output out of the log. Tokens, cost, and latency are still recorded.
customer_credentialsobjectNoneYour provider keys for this request, keyed by provider. Never sent on to the provider as a param.
credential_overrideobjectNoneA provider key for one model, keyed by model.

Request headers that act like params:

HeaderDescription
X-Data-Respan-ParamsRespan params as base64-encoded JSON, for when you can’t change the body.
X-Respan-Managed-Fallback-Enabledtrue lets a call that your own key’s provider rate limited (429) retry on Respan’s key. See Managed fallback.
X-Respan-Betaenv-scoped-integrations-2026-03-28 scopes the request to the provider keys saved for its API key’s environment. See BYOK.

The OpenAI fields the gateway reads are listed in Chat Completions.

How to send them

Use whichever fits your client. You can combine them.

WhereHowUse when
Top level of the body"customer_identifier": "user_8842"; with the OpenAI SDK, in extra_body (Python) or as extra fields (TypeScript)You build the request yourself
respan_params object"respan_params": {"customer_identifier": "user_8842"}You want Respan’s fields kept apart from the provider’s
X-Data-Respan-Params headerBase64-encoded JSON objectYou can’t change the body, for example in a CLI or a third-party SDK
metadata.respan_paramsInside the request’s own metadataAnthropic Messages, Responses, and Gemini requests

Header. Encode a JSON object as base64:

Terminal
PARAMS=$(echo -n '{"customer_identifier":"user_8842","metadata":{"feature":"support-chat"}}' | base64 | tr -d '\n') curl https://gateway.respan.ai/chat/completions \ -H "Authorization: Bearer $RESPAN_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Data-Respan-Params: $PARAMS" \ -d '{"model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello!"}]}'

If the header isn’t valid base64, isn’t valid JSON, or doesn’t decode to an object, the whole header is ignored. The request is still served, and its log carries a header_parsing_error warning. The header is also how a realtime session names its customer and disable_log.

Anthropic Messages and other provider formats. On /v1/messages, /v1/responses, and the Gemini routes, you can put the params in metadata.respan_params. The gateway removes them before the provider sees the body:

Python
import os import anthropic client = anthropic.Anthropic(base_url="https://gateway.respan.ai", api_key=os.environ["RESPAN_API_KEY"]) message = client.messages.create( model="claude-sonnet-4-5-20250929", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], metadata={"respan_params": {"customer_identifier": "user_8842"}}, )

On Chat Completions, metadata holds your custom properties, so a respan_params key inside it isn’t read there. Use respan_params at the top level or extra_body.

Precedence. When the same field arrives more than one way, respan_params wins over the header, and both win over a top-level field. The legacy names keywordsai_params and X-Data-Keywordsai-Params still work.

respan_params must be a JSON object wherever you send it. Any other value, such as a list, a number, or a string, is ignored without an error, and none of its params apply: the request isn’t attributed to the customer, budgets and rate limits don’t apply, and a disable_log inside it is ignored, so the request is logged in full. A top-level respan_params string that decodes to an object is the one exception, for multipart uploads where a form field can’t hold an object. The OpenAI SDK types metadata as strings, so don’t json.dumps the params into it; send an object through extra_body.

Customers

customer_identifier attributes the request to one of your end users. Respan keeps a record per customer with their requests, tokens, and cost, and the gateway enforces a budget and a rate limit for each one before any provider is called. Use a stable ID that doesn’t reveal who the user is, such as a hashed user ID. customer_params adds details:

JSON
{ "customer_params": { "customer_identifier": "user_8842", "name": "Maya Patel", "email": "maya@example.com", "rate_limit": 60 } }
  • A customer is created the first time Respan sees its identifier, cut to 254 characters. Production and test API keys keep separate records.
  • customer_params.customer_identifier wins over a top-level customer_identifier.
  • name and email are saved only the first time the customer is seen. Edit them on the customer record after that.

Budgets

A budget caps what one customer can spend in a period. Go to Observability › Users & identifiers, click the customer, and under Budgets edit Period budget. Or set period_budget and budget_duration (daily, weekly, or monthly) with Update a user. Budget fields sent on a request are ignored, so a client can’t raise its own budget.

Once the customer’s spend in the period passes the budget, their requests get 402 until the next period, and Respan sends a customer_budget_limit_reached webhook. Spend is counted when a call ends, so the call that crosses the budget completes.

Rate limit

The default for every customer is Customer rate limit (requests/min) on the Limits tab. customer_params.rate_limit replaces it for one request. It applies to Chat Completions, and a customer over it gets 429 rate_limit_exceeded.

Analytics

Observability › Users & identifiers lists each customer with their requests, tokens, and cost. Click one for their metrics and budget, or Open in Logs for their requests. To read customers from code, use List users. If you also trace your app with the Respan SDK, tag spans with the same identifier. See Users.

Thread and trace

thread_identifier groups the turns of one conversation, so Logs can show them as a thread. trace_unique_id places the request in a trace, and span_name (else trace_name) names its root row:

JSON
{ "thread_identifier": "thread_7f3a", "trace_unique_id": "trace_order_1042", "span_name": "support-reply" }

Every gateway request is one trace by default. See Logs to join calls to a trace from your own code.

Metadata

metadata holds any number of key-value pairs, shown on the log as custom properties:

JSON
{ "metadata": {"feature": "support", "region": "us-east", "customer_tier": "pro"} }

See Custom IDs & attributes to group and filter by them.

disable_log

"disable_log": true keeps the request’s input and output out of the log. The log still records the model, tokens, cost, latency, status, and your other params, so usage and billing stay complete. See Data retention and ZDR.

Find them in Logs

Open Logs, click a request, and open the Metadata tab. Properties shows the customer and thread, and Custom properties lists your metadata keys.

A span's Metadata tab in Logs: Properties with Customer ID, Customer name, Customer email, Thread ID, and Custom ID, and Custom properties with feature, environment, and customer_tier

Hover Customer ID or Thread ID and click the filter icon to show only the requests with that value.

Environment scoping

Send X-Respan-Beta: env-scoped-integrations-2026-03-28 to scope a request to the provider keys saved for its API key’s environment. See Bring your own key.