Gateway API
The gateway base URL is https://aimux.me/v1. Every route requires Authorization: Bearer <PRODUCT_KEY>, including catalog and usage reads. Authenticate and authorize before a cache lookup. Only models and upstream resources available to the calling product key may appear in its results.
First request
Section titled “First request”The same handler is available locally at http://127.0.0.1:8787/v1/chat/completions. Use a seeded product key and its configured model. For hosted onboarding, see Getting started.
POST /v1/chat/completions HTTP/1.1Host: aimux.meAuthorization: Bearer <PRODUCT_KEY>Content-Type: application/json
{"model":"example/chat-model","messages":[{"role":"user","content":"Hello"}],"stream":false}A successful OpenAI-compatible reply contains a choices array with the assistant message. With "stream":true, the gateway returns server-sent events as they arrive. For a chat-completions stream, clients consume data: frames through the terminal [DONE] event. Treat an interrupted stream as incomplete. The gateway cannot change its HTTP status or replay output once the response is committed.
Inference endpoints
Section titled “Inference endpoints”A route requires a compatible adapter and a model configured for the calling product. The catalog exposes operations supported by its routes. An unconfigured product receives 503 upstream_unavailable on inference.
| Method and path | Routing type | Contract |
|---|---|---|
POST /v1/chat/completions |
chat | OpenAI messages and choices. Stream using SSE or return a complete JSON reply. Phase 1 starts with OpenRouter. |
POST /v1/completions |
chat | Legacy prompt-based completions on compatible models. |
POST /v1/messages |
chat | Anthropic Messages request and response format with a compatible adapter. |
POST /v1/responses |
chat | Responses API passthrough on compatible routes. JSON and capability rejection have fixture coverage. |
POST /v1/embeddings |
embedding | Return vectors for the submitted input on a compatible model such as a Voyage deployment. |
POST /v1/rerank |
rerank | Rank input documents against a query. Select a rerank-capable key even if its provider also serves embeddings. |
POST /v1/images/generations |
media | Image generation with the selected provider’s supported response format. |
POST /v1/audio/speech |
media | Text to speech. Preserve the audio content type and binary response. |
POST /v1/audio/transcriptions |
media | OpenAI-compatible multipart audio upload and transcription. Preserve multipart boundaries. |
POST /v1/videos |
media | Reserved for explicit compatible provider configurations. The default adapters do not advertise video. |
The Worker accepts requests up to 25 MiB. Check upload sizes against the deployed zone’s limits. The platform limit depends on the domain’s Cloudflare plan. For large objects, phase 8 may add direct uploads to R2 using presigned URLs. Cloudflare request limits
Model catalog
Section titled “Model catalog”An empty model allowlist permits all models otherwise available to the key. Filter catalog metadata after reading shared cached listings and before returning counts, details, or endpoint lists. A request for a hidden model must not expose its provider metadata.
| Method and path | Result |
|---|---|
GET /v1/models |
Models available to this product key. |
GET /v1/models/count |
Count from the same filtered list. |
GET /v1/models/{author}/{slug} |
Details for a permitted model. |
GET /v1/models/{author}/{slug}/endpoints |
Compatible, eligible endpoints for the model. |
GET /v1/models/user |
Bring-your-own-key model listing from the product’s eligible OpenRouter context. |
GET /v1/embeddings/models |
Filtered catalog restricted to embedding models. |
GET /v1/providers |
Providers represented in the caller’s available catalog. |
GET /v1/endpoints/zdr |
Permitted zero-data-retention endpoints from the upstream catalog. |
Credits and usage
Section titled “Credits and usage”| Method and path | Result |
|---|---|
GET /v1/credits |
Available upstream credit, where the provider gives a balance attributable to the product. Omit a shared account balance that would expose other products. |
GET /v1/usage |
Daily usage over the requested time range filtered to this product key. Distinguish upstream tokens and gateway cache hits. |
GET /v1/key |
The caller’s own key status, model permissions, and available quota information. |
Errors and cache controls
Section titled “Errors and cache controls”Return an OpenAI-shaped error for a rejected gateway request before streaming begins. The following error label and message illustrate the contract.
{"error":{"message":"No eligible upstream key is available for this product.","type":"upstream_unavailable"}}| Condition | Expected outcome |
|---|---|
| Invalid, missing, or revoked product key | Reject authentication before serving product data or making an upstream call. |
| Active key requests a disallowed model | Deny the request before sending the prompt. |
| Product-key rate limit reached | Return 429. Skipping an exhausted upstream credential is an internal routing decision. |
| Status authority unavailable | Return a service error, including for a warm response cache. |
| All eligible retries exhausted | Return an upstream service error with a sanitized message. Keep provider secrets, account details, and other products out of the response. |
A client can request KV response caching using X-Cache: on or the gateway field "cache": true. Caching is off by default and applies only to eligible completed responses. See caching and usage and the build roadmap.