Before You Start
| If you are doing this | Use this credential | Where it goes |
|---|---|---|
| MCP, OTel ingest, or CostHawk API auth | CostHawk access token | COSTHAWK_API_KEY or Authorization: Bearer ... to CostHawk routes |
| OpenAI / Anthropic / Google model requests through CostHawk | Wrapped key | Provider SDK api_key or Authorization header, plus CostHawk proxy base URL |
If you are trying to send a wrapped key directly to Anthropic, OpenAI, or Google, stop and switch to the CostHawk proxy first. See Wrapped Keys.
Access Tokens
CostHawk uses access tokens to authenticate requests to the API and MCP server. Tokens are scoped to your account and can be created and revoked from your dashboard. For MCP users, the recommended path is browser login:Creating a Token
- Go to your CostHawk dashboard
- Start at Access Setup or go directly to Settings → Access Tokens
- Click Create Token
- Give your token a descriptive name (e.g., “Claude Code - Work Laptop”)
- Copy the token immediately - you won’t be able to see it again
Access tokens may be prefixed with
ch_sk_, but so are wrapped keys. The prefix alone does not tell you which endpoint to use.Token Security
Best practices:- Use environment variables to store tokens
- Create separate tokens for different environments (dev, staging, prod)
- Rotate tokens periodically
- Revoke tokens you no longer need
Revoking a Token
If a token is compromised or no longer needed:- Go to Access Setup or Settings → Access Tokens in your dashboard
- Find the token in the list
- Click the trash icon to revoke it
Using Tokens
MCP Server
Set theCOSTHAWK_API_KEY environment variable in your MCP configuration:
API Requests
Include the token in theAuthorization header:
Error Responses
| Status Code | Meaning |
|---|---|
401 | Missing or invalid token |
403 | Token doesn’t have required permissions |
429 | Rate limit exceeded |
Wrapped Keys Are Different
Wrapped keys are not covered by the auth flow above.- Access tokens authenticate you to CostHawk
- Wrapped keys authenticate provider traffic to the CostHawk proxy
