Authentication

The ways to send your key in request headers.

Every model endpoint needs your key in a request header. Create keys on API Keys.

Works on every endpoint:

Authorization: Bearer sk-xxxxxxxxxxxxxxxx

The sk- prefix is optional.

Other forms

For compatibility with vendor SDKs, some endpoints also accept:

Header / parameterEndpointsNotes
x-api-key: sk-xxxxxxxxxxxxxxxx/v1/messages, /v1/modelsThe Anthropic SDK form, usually with anthropic-version: 2023-06-01
x-goog-api-key: sk-xxxxxxxxxxxxxxxxGemini native /v1beta/models/..., /v1/modelsThe Google SDK form
?key=sk-xxxxxxxxxxxxxxxxGemini native /v1beta/models/..., /v1/modelsIn the URL, where logs can capture it; not recommended
# Anthropic format
curl https://tokenfunc.com/v1/messages \
  -H "x-api-key: sk-xxxxxxxxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-sonnet-4-5", "max_tokens": 256, "messages": [{"role": "user", "content": "Hello"}]}'

Key limits

When you create or edit a key you can set these limits; requests beyond them are rejected:

LimitWhen exceeded
Quota cap401 once the key's quota is used up
Allowed models403 for models the key may not use
IP allowlist403 for requests from other IPs
Expiry401 after expiry
GroupOnly the group's models are available; 403 if the group is not available to your account or has been retired

Security advice

  • A key is a payment credential: whoever holds it can spend your balance.
  • Use one key per tool or project and give it a quota cap when it makes sense.
  • Never put keys in frontend code, commit them, or paste them in chats. Call the API from the browser only through your own backend.
  • If a key may have leaked, delete or disable it on API Keys right away.