Gateway API
Public API families, authentication, routing, limits, and billing boundaries.
On this page
Gateway scope
The AnyPath Gateway exposes supported OpenAI-compatible, Anthropic Messages, Gemini /v1beta, and image endpoints through one AnyPath API key. It does not require callers to change provider-native request semantics for billing or routing.
Public API families
| Family | Endpoints |
|---|---|
| Model and route discovery | GET /v1/models, GET /v1/routes |
| OpenAI-compatible | POST /v1/chat/completions, POST /v1/responses |
| Anthropic Messages | POST /v1/messages, POST /v1/messages/count_tokens |
| Images | POST /v1/images/generations, POST /v1/images/edits |
Gemini /v1beta | GET /v1beta/models, GET /v1beta/models/{model}, POST /v1beta/models/{model}:generateContent, POST /v1beta/models/{model}:streamGenerateContent, POST /v1beta/models/{model}:countTokens |
Choosing a protocol
- Use Chat Completions when the client expects the OpenAI chat request shape.
- Use Responses only when the client requires Responses-specific behavior.
- Use Anthropic Messages for Claude-native request bodies, including
/v1/messages/count_tokens. - Use Gemini
/v1betafor Gemini-native request bodies and authentication styles.
Authentication
All gateway requests require an AnyPath API key. Bearer auth is accepted on the public API families:
Authorization: Bearer sk-your-api-key
Anthropic Messages also accepts x-api-key. Gemini /v1beta also accepts x-goog-api-key and ?key=.... Non-Gemini paths do not accept query-string API keys.
Routing and billing
The gateway selects from the routes available to the API key:
- Shared capacity: eligible provider capacity; requests settle in USDT after success.
- Route policy: intelligent routing by default, or specified provider when a fixed provider boundary is required. Specified provider is not a fixed provider key.
Shared-route billing uses the model’s official list price, the actual routed Provider’s current platform multiplier, and metered usage. The official list price used for charging and the provider that actually served the request may differ, and both remain in settlement evidence. Model-level or route-default buyer multipliers are not part of the public billing contract.
For intelligent routing and specified-provider keys, AnyPath selects a healthy shared route before dispatch. The public response contract stays simple: use the request ID to inspect the routing decision, provider, multiplier, and settlement evidence in Console Usage/Logs.
For conversations, continuation IDs, cache reuse, and thinking-signature style requests, AnyPath keeps route affinity while the route remains healthy and within the selected provider boundary. Operator strategy updates affect new unbound routing choices; they do not abruptly scatter an active sticky session.
Streaming is available on shared routes whose channel has passed streaming certification; streaming requests to uncertified channels fail closed with model_unavailable. Certified streams settle in the same loop as non-streaming requests — hold, terminal SSE usage evidence, then capture — and a stream that ends without usage evidence releases the hold without charging the buyer. Chat Completions streams require the client to send stream_options.include_usage: true. See Streaming.
What shared routes serve today
A shared route holds part of your balance before the request is sent, for the most that request can cost. It therefore serves requests whose cost can be bounded in advance: text input with text output, and function calling.
These are refused with 400 unsupported_request_field, and nothing is held or charged:
- image generation and image editing (
/v1/images/*) - image, audio, video and file inputs, including base64 images inside a chat request
- hosted tools that the provider runs and bills separately, such as web search or code execution
- requests that reference provider-side cached content
- request bodies of about 195 KB or more
The hold is sized from the size of the request body plus max_tokens (or the model’s output limit when you send none), so it is larger than the final charge. The difference returns to your balance when the request settles.
A non-streaming request is settled even if your client disconnects before the answer arrives, the same as a stream: the provider has already been asked and completes the generation.
Failure handling
OpenAI-compatible gateway errors use stable public error codes. Retry only temporary failures such as 429, 502, 503, and 504, and respect Retry-After when present.
An account that starts many requests at the same moment may receive 429 rate_limit_exceeded for some of them even below its per-minute limit: each account’s holds are taken one after another. Spread the requests out or retry after a short pause.
See Error Handling and Error Codes.
Next
- API Overview: endpoint-by-endpoint reference.
- Authentication: supported key headers.
- Billing: shared-route settlement.
- Streaming: SSE behavior.