Skip to main content
The Toolken Gateway API is a transparent pass-through proxy that sits between your application and the LLM provider. You point your existing SDK at the Toolken gateway URL instead of the provider URL — everything else stays the same. The gateway adds cost attribution and usage recording without altering the request or response.

Base URL

The base URL depends on which SDK you are using: If you are sending raw HTTP requests, always include the full path: https://gateway.toolken.ai/v1/chat/completions, https://gateway.toolken.ai/v1/messages, etc. Provider routing is automatic based on the path and model name.

Two keys on every request

Every request requires two credentials: The gateway validates X-Toolken-Key, then strips it before forwarding so the provider never sees it.

Supported endpoints

No endpoint is invented or proxied speculatively. Only the paths listed above are accepted.

Provider detection

The gateway detects the upstream provider in this order:
  1. Explicit X-Toolken-Provider header (e.g. X-Toolken-Provider: gemini) — always wins
  2. Path: /v1/messages always routes to Anthropic
  3. Model name prefix (e.g. gpt-*, o1-* to OpenAI; claude-* to Anthropic; gemini-* to Google)
  4. Error — cannot determine provider; attach X-Toolken-Provider or include a recognizable model name

Attribution headers

Optional headers let you tag each request for cost breakdown in the Toolken dashboard. See Headers for the full reference.

Errors

When the gateway itself cannot forward the request (invalid key, timeout, rate limit, etc.) it returns a JSON error body in the standard OpenAI-compatible shape. See Errors for the full list of codes.