The Easy Rule
- If you are configuring MCP, OTel, or the CostHawk API, use a CostHawk access token with
COSTHAWK_API_KEY. - If you are configuring an OpenAI, Anthropic, or Google SDK/client, use a wrapped key and change the base URL to the CostHawk proxy.
Two Different CostHawk Credentials
Both credentials may look likech_sk_.... Do not identify them by prefix alone.
| Credential | Created In | Used For | Send It To | Do Not Send It To |
|---|---|---|---|---|
| CostHawk access token | Browser login or Dashboard → Access Setup → MCP + OTel Tokens | MCP, OTel ingest, CostHawk API auth | COSTHAWK_API_KEY or Authorization: Bearer ... to CostHawk API routes | Provider SDKs and direct OpenAI/Anthropic/Google endpoints |
| Wrapped key | Dashboard → Access Setup → Wrapped Proxy Keys | OpenAI / Anthropic / Google model requests through CostHawk proxy | Authorization: Bearer ch_sk_... or provider SDK api_key against https://costhawk.ai/api/proxy/{provider} | Direct provider endpoints |
How To Use A Wrapped Key
Create a wrapped key
Go to Access Setup, then open Wrapped Proxy Keys. When prompted, paste your real provider inference key. CostHawk stores that real key behind the wrapped key.
Keep provider and proxy aligned
An Anthropic wrapped key must use the Anthropic proxy. An OpenAI wrapped key must use the OpenAI proxy.
Change your SDK base URL
Replace the provider’s base URL with
https://costhawk.ai/api/proxy/{provider}.Wrapped keys sit in front of real inference-capable provider keys. Admin or read-only provider keys belong in Admin API Sync, not in proxy traffic.
Wrong vs Right
Wrong
This will fail, because the wrapped key is being sent directly to the provider:Right
This works, because the base URL points to the CostHawk proxy:Proxy Endpoints
| Provider | Base URL | Typical Auth |
|---|---|---|
| OpenAI | https://costhawk.ai/api/proxy/openai | Authorization: Bearer ch_sk_... |
| Anthropic | https://costhawk.ai/api/proxy/anthropic | Authorization: Bearer ch_sk_... |
| Google Gemini | https://costhawk.ai/api/proxy/google | Authorization: Bearer ch_sk_... or x-goog-api-key: ch_sk_... |
Provider-Specific Setup
OpenAI Proxy
OpenAI SDK examples and endpoint details
Anthropic Proxy
Anthropic SDK examples and endpoint details
Google Gemini Proxy
Google Gemini proxy setup and request format
When Not To Use Wrapped Keys
- If you want fast org-level visibility with no app code changes, start with Admin API Sync.
- If you want Claude Code / Codex analytics and assistant-native tools, use MCP.
- If you need CostHawk API auth, see Authentication.
