OhMyGPT

App Attribution

Name your app on each request so you can break usage down by app.

Optional request headers name the app that sent a request. OhMyGPT stores them with the request, so when several apps or tools share an account you can tell their usage apart.

HeaderStored asValue
HTTP-Refererapp_urlYour app's URL. Must start with https:// or http://.
X-OhMyGPT-Titleapp_titleYour app's name.
X-OhMyGPT-Categoriesapp_categoriesFree text, stored as sent, for example cli-agent.

Apps already sending OpenRouter's headers need no change: X-OpenRouter-Title and X-Title count as X-OhMyGPT-Title, and X-OpenRouter-Categories as X-OhMyGPT-Categories. When several are present, the X-OhMyGPT-* header wins. The browser's standard Referer header is not read.

Values longer than 128 bytes are cut. An invalid value is dropped; the request itself never fails because of these headers.

curl https://api.ohmygpt.com/v1/chat/completions \
  -H "Authorization: Bearer $OHMYGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "HTTP-Referer: https://example.com" \
  -H "X-OhMyGPT-Title: Example App" \
  -H "X-OhMyGPT-Categories: cli-agent" \
  -d '{"model": "ohmygpt/mock", "messages": [{"role": "user", "content": "ping"}]}'

With the OpenAI SDKs, set the headers once on the client:

client = OpenAI(
    base_url="https://api.ohmygpt.com/v1",
    api_key=os.environ["OHMYGPT_API_KEY"],
    default_headers={"HTTP-Referer": "https://example.com", "X-OhMyGPT-Title": "Example App"},
)

Labels for your own reporting

Three more headers, plus up to 10 of your own, tag a request for cost reporting:

HeaderStored as
X-Projectproject
X-Environmentenvironment
X-Cost-Centercost_center
X-Label-<name>label.<name>, lower-cased, with - turned into _
curl https://api.ohmygpt.com/v1/chat/completions \
  -H "Authorization: Bearer $OHMYGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Project: docs-demo" \
  -H "X-Environment: staging" \
  -H "X-Cost-Center: research" \
  -H "X-Label-Team: core" \
  -d '{"model": "ohmygpt/mock", "messages": [{"role": "user", "content": "ping"}]}'

This request is stored with the labels project: docs-demo, environment: staging, cost_center: research and label.team: core. Filter by them the same way as the app labels, for example GET /v1/usage?project=docs-demo or ?label.team=core, and group by them with group_by=label:project.

Usage by end user

If you resell to your own customers, name the customer in the request body: safety_identifier or user on Chat Completions and Responses, metadata.user_id on Anthropic Messages. Filter by it with GET /v1/usage?user=customer-42, and total cost per customer with GET /v1/usage/summary?group_by=user. The value isn't echoed in each record's labels.

Usage by app

GET /v1/usage returns the values in each record's labels and filters by them. It reads your whole account, so call it with an admin key:

curl "https://api.ohmygpt.com/v1/usage?app_title=Example%20App&limit=1" \
  -H "Authorization: Bearer $OHMYGPT_API_KEY"
[
  {
    "request_id": "01a19b5d-8121-7575-9e9f-14208909f380",
    "time": "2026-11-02T08:26:00.185Z",
    "model": "ohmygpt/mock",
    "status": 200,
    "cost_credits": 0,
    "labels": {
      "app_url": "https://example.com",
      "app_title": "Example App",
      "app_categories": "cli-agent",
      "sdk_info": "curl/8.23.0"
    }
  }
]

sdk_info comes from the User-Agent header. To total cost per app, group the summary by label: GET /v1/usage/summary?group_by=label:app_title.

Was this page helpful?

Still stuck? Live chat · [email protected] · Telegram group