Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.requesty.ai/llms.txt

Use this file to discover all available pages before exploring further.

What are Analytics Headers?

Analytics headers are custom X-Requesty-* HTTP headers you attach to your API requests. Requesty captures them, strips them before forwarding to the AI provider, and makes them available as dimensions in your analytics dashboards. They are the simplest way to add metadata to requests β€” no SDK changes, no request body modifications. Just set an HTTP header.
curl https://router.requesty.ai/v1/chat/completions \
  -H "Authorization: Bearer $REQUESTY_API_KEY" \
  -H "X-Requesty-Agent: my-support-bot" \
  -H "X-Requesty-Environment: production" \
  -H "X-Requesty-Team: platform" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4-5",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

How It Works

  1. Add one or more X-Requesty-* headers to your request.
  2. Requesty extracts the headers and removes them before forwarding to the AI provider β€” no data leaks upstream.
  3. The header values are stored as custom metadata fields on the request.
  4. In analytics, filter or Group By those fields to slice your data any way you want.
Header matching is case-insensitive β€” x-requesty-team, X-REQUESTY-TEAM, and X-Requesty-Team are all treated the same.

Naming Your Headers

Any header matching the X-Requesty-<Name> pattern is captured. The <Name> part (after the prefix) becomes the field key in analytics.
HeaderAnalytics field
X-Requesty-AgentAgent
X-Requesty-BranchBranch
X-Requesty-EnvironmentEnvironment
X-Requesty-TeamTeam
X-Requesty-CustomerCustomer
You can use any name you like β€” there is no fixed list. Pick names that match the dimensions you care about.

Use Cases

Name your AI agent

Give each agent or bot a distinct identity so you can track cost and usage per agent:
-H "X-Requesty-Agent: support-bot"
-H "X-Requesty-Agent: code-reviewer"
-H "X-Requesty-Agent: data-pipeline"
Then in the Advanced analytics tab, Group By β†’ Agent to see a cost and request breakdown per agent.

Track by environment

Separate production traffic from development and staging:
-H "X-Requesty-Environment: production"

Track by team or department

Attribute AI costs to the team that generated them:
-H "X-Requesty-Team: backend"
-H "X-Requesty-Department: engineering"

Track by customer

If you’re building AI features for multiple customers, tag each request:
-H "X-Requesty-Customer: acme-corp"

Track git context

Tag requests with the branch and repo to see which feature branches are driving cost:
-H "X-Requesty-Branch: feat/new-onboarding"
-H "X-Requesty-Repo: myorg/backend"
The Claude Code analytics wrapper does this automatically β€” it tags every request with your current git branch, repo, agent version, and OS username.

Implementation Examples

Python (OpenAI SDK)

import openai

client = openai.OpenAI(
    api_key="YOUR_REQUESTY_API_KEY",
    base_url="https://router.requesty.ai/v1",
    default_headers={
        "X-Requesty-Agent": "my-support-bot",
        "X-Requesty-Environment": "production",
    }
)

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-5",
    messages=[{"role": "user", "content": "Hello"}]
)

Node.js (OpenAI SDK)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_REQUESTY_API_KEY",
  baseURL: "https://router.requesty.ai/v1",
  defaultHeaders: {
    "X-Requesty-Agent": "my-support-bot",
    "X-Requesty-Environment": "production",
  },
});

const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4-5",
  messages: [{ role: "user", content: "Hello" }],
});

cURL

curl https://router.requesty.ai/v1/chat/completions \
  -H "Authorization: Bearer $REQUESTY_API_KEY" \
  -H "X-Requesty-Agent: my-support-bot" \
  -H "X-Requesty-Environment: production" \
  -H "X-Requesty-Team: backend" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1",
    "messages": [{"role": "user", "content": "Summarize this document"}]
  }'

Claude Code (automatic)

Install the Requesty analytics wrapper and every Claude Code session automatically sends:
HeaderValue
X-Requesty-BranchCurrent git branch
X-Requesty-Repoorg/repo from git origin
X-Requesty-Ai-AgentClaude Code version
X-Requesty-UserOS username
curl -fsSL https://www.requesty.ai/claude/install.sh | bash
See Claude Code Analytics for details.

Viewing in Dashboards

Once you start sending analytics headers, the fields appear in the Analytics dashboard:
  1. Open the Advanced tab.
  2. In the Group By dropdown, select your custom field (e.g., Agent, Environment, Team).
  3. Choose a Metric (Cost, Requests, Tokens, Latency, etc.) and a Time Range.
  4. Optionally add Filters to narrow down (e.g., Agent = support-bot).
You can combine analytics headers with any other grouping or filter β€” for example, group by Agent and filter by model = anthropic/* to see which agents use Anthropic models the most.
Establish naming conventions for your analytics headers across your organization. Consistent names like X-Requesty-Team, X-Requesty-Environment, and X-Requesty-Agent make dashboards easy to read for everyone.

Analytics Headers vs. Request Metadata

Requesty supports two ways to attach custom metadata:
Analytics HeadersRequest Metadata
HowX-Requesty-* HTTP headersrequesty field in the request body
Best forInfrastructure-level tags (agent, branch, environment) that are set onceApplication-level context (user ID, trace ID, tags) that vary per request
SDK changesNone β€” set default_headers onceRequires extra_body or body modification per request
Supports arraysNo β€” single string values onlyYes β€” tags is an array
Supports user_id / trace_idNo β€” use Request Metadata for theseYes
Both methods can be used together. For example, set X-Requesty-Agent and X-Requesty-Environment as default headers, and add per-request user_id and tags via the request body.

Privacy & Security

  • Analytics headers are stripped from the request before it is forwarded to the AI provider. The provider never sees them.
  • Header values are stored as metadata alongside the request log in your Requesty organization β€” visible only to your team.
  • Do not put sensitive data (passwords, tokens, PII) in analytics headers.
Last modified on April 30, 2026