---
title: "Respan params"
subtitle: "Fields you send with a gateway request to tag its session, user, and properties, and to 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 which session and user the request belongs to, and which properties you want to filter by in Logs.

<Tabs>
<Tab title="cURL">
```bash
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!"}],
    "session_identifier": "chat_7f3a",
    "customer_identifier": "user_8842",
    "metadata": {"feature": "support-chat"}
  }'
```
</Tab>
<Tab title="OpenAI SDK">
```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.respan.ai",
    api_key=os.environ["RESPAN_API_KEY"],
)

response = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello!"}],
    extra_body={
        "session_identifier": "chat_7f3a",
        "customer_identifier": "user_8842",
        "metadata": {"feature": "support-chat"},
    },
)
```

In TypeScript, pass the same fields next to `messages`, with `// @ts-expect-error` above them.
</Tab>
<Tab title="Anthropic SDK">
```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": {
            "session_identifier": "chat_7f3a",
            "customer_identifier": "user_8842",
            "metadata": {"feature": "support-chat"},
        }
    },
)
```
</Tab>
<Tab title="Gemini SDK">
```python
import os
from google import genai

client = genai.Client(
    api_key=os.environ["RESPAN_API_KEY"],
    http_options={"base_url": "https://gateway.respan.ai"},
)

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Hello!",
    config={
        "http_options": {
            "extra_body": {
                "respan_params": {
                    "session_identifier": "chat_7f3a",
                    "customer_identifier": "user_8842",
                    "metadata": {"feature": "support-chat"},
                }
            }
        }
    },
)
```

In TypeScript, the same object goes in `config.httpOptions.extraBody`.
</Tab>
</Tabs>

## Sessions

`session_identifier` groups the turns of one conversation into a session. Use the id your app already has, such as a chat id. `thread_identifier`, the old name, still works, and `session_identifier` wins when a request sends both.

If you have no id, send `"is_auto_session_enabled": true` and Respan finds the session for you:

- A request joins the session it continues: its messages are an earlier request's messages plus that request's reply, from the same `customer_identifier`, less than an hour before. Otherwise it starts a new session.
- On Responses requests, `previous_response_id` or `conversation` also joins the request to the session of the response it continues.
- It works on Chat Completions, Anthropic Messages and Responses requests. A response served from the gateway cache isn't given a session.

See [Sessions](/docs/documentation/features/custom-attributes#sessions) for how to find them in Logs.

## 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](/docs/apis/users/update-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](/docs/documentation/admin/webhooks). 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](/docs/ai-gateway/routing/limits#customer-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](/docs/apis/users/list-users). If you also trace your app with the Respan SDK, tag spans with the same identifier. See [Custom attributes](/docs/documentation/features/custom-attributes#users).

## 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 attributes](/docs/documentation/features/custom-attributes) to group and filter by them.

## All params

| Parameter | Type | Default | Description |
|---|---|---|---|
| [`session_identifier`](#sessions) | string | None | The session (conversation) the request belongs to. |
| [`is_auto_session_enabled`](#sessions) | boolean | `false` | `true` with no session id: Respan finds the session the conversation continues, or starts one. |
| [`thread_identifier`](#sessions) | string | None | Old name for `session_identifier`. Used when no `session_identifier` is sent. |
| [`customer_identifier`](#customer) | string | None | The end user the request belongs to. Drives per-customer analytics, [budgets](#budgets), and [rate limits](#rate-limits). |
| [`customer_params`](#customer) | object | None | `customer_identifier` plus `name`, `email`, and `rate_limit`. |
| [`metadata`](#metadata) | object | None | Your own key-value pairs, shown as custom properties. Values are stored as strings. |
| [`disable_log`](#disable_log) | boolean | `false` | `true` keeps the input and output out of the log. Tokens, cost, and latency are still recorded. |
| [`customer_credentials`](/docs/ai-gateway/spend/credits-vs-byok#request-keys) | object | None | Your provider keys for this request, keyed by provider. Never sent on to the provider as a param. |
| [`credential_override`](/docs/ai-gateway/spend/credits-vs-byok#request-keys) | object | None | A provider key for one model, keyed by model. |

Request headers that act like params:

| Header | Description |
|---|---|
| `X-Data-Respan-Params` | Respan params as base64-encoded JSON, for when you can't change the body. |
| `X-Respan-Managed-Fallback-Enabled` | `true` lets a call that your own key's provider rate limited (`429`) retry on Respan's key. See [Managed fallback](/docs/ai-gateway/spend/credits-vs-byok#managed-fallback). |
| `X-Respan-Beta` | `env-scoped-integrations-2026-03-28` scopes the request to the provider keys saved for its API key's environment. See [BYOK](/docs/ai-gateway/spend/credits-vs-byok#environment-scoped-keys). |

The OpenAI fields the gateway reads are listed in [Chat Completions](/docs/ai-gateway/requests/chat-completions#request-body).

## How to send them

Use whichever fits your client. You can combine them.

| Where | How | Use 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` header | Base64-encoded JSON object | You can't change the body, for example in a CLI or a third-party SDK |
| `metadata.respan_params` | Inside the request's own `metadata` | Anthropic Messages, Responses, and Gemini requests |

**Header.** Encode a JSON object as base64:

```bash
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](/docs/ai-gateway/modalities/realtime) 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, as in the Anthropic SDK tab above. With the Gemini SDK, a top-level `respan_params` sent through `extra_body` works too, as in the Gemini SDK tab.

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.

<Warning>
`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`.
</Warning>

## 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.

To keep the content of every request out of the log, turn it on for the whole organization instead: go to **Settings** › **General** › **Data retention** and turn on **Disable logging**. It's available on Team and above. See [Data retention and ZDR](/docs/ai-gateway/security/zero-data-retention#disable-logging).

## Find them in Logs

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

<img src={"/docs/images/gateway-features/logs-metadata-tab-light.png"} className="block dark:hidden" alt="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" />
<img src={"/docs/images/gateway-features/logs-metadata-tab-dark.png"} className="hidden dark:block" alt="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 **Session 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](/docs/ai-gateway/spend/credits-vs-byok#environment-scoped-keys).
