The gateway speaks the OpenAI API, so most clients work after you change two settings: the base URL and the API key. This page shows how to configure the common SDKs, use virtual models and routing configs, attach metadata, and read errors.

How it works

Every request goes to https://app.manylayers.io/v1 and carries a credential in the Authorization header. The gateway authenticates the caller, applies your organization’s policies, picks a provider for the requested model, and returns the answer in the shape your client expects. Console and admin routes live on https://app.manylayers.io, not on the /v1 host.

Connection settings

Key fields

  • Base URL: The gateway serves the OpenAI surface under /v1. The Anthropic SDK adds /v1 itself, so give it the URL without the suffix.
  • Credential: Send an API key (ml-...), a personal access token (ml_pat_...) or a virtual account token (ml_vat_...) as Authorization: Bearer <token>. If that header is absent the gateway falls back to x-api-key, which the Anthropic SDK sends by default; Authorization wins when both are present, and neither is forwarded to the provider. The gateway also accepts OIDC JWTs from your identity provider. See Authentication and Credentials.
  • Model: A name returned by GET /v1/models, or a virtual model, which is callable by name but not listed there. A name your team isn’t allowed to use is refused.

Send a request

The Anthropic SDK’s api_key is sent as x-api-key, which the gateway accepts. If you prefer a bearer token, auth_token="ml-..." (or default_headers={"Authorization": "Bearer ml-..."}) works too. See Anthropic Messages API for the full translation rules.

Stream a response

Set "stream": true to receive Server-Sent Events in the usual OpenAI chunk format.
When an output guardrail applies to a streamed request, the gateway holds the stream until the guardrail finishes and sets X-ManyLayers-Guardrails-Output: buffered-streaming. You still receive SSE, but the first token arrives later.

Common configurations

A routing config with model_types can be called by name as the model. Real model names always win over a config with the same name.
To apply a config to a request for a regular model, name it (by id or name) in a header. An unknown config returns 400 unknown_config.
See Routing for strategies and virtual models.
Send a flat JSON object in X-ManyLayers-Metadata. The gateway stores it on the request trace, and conditional routing and guardrail rules can match on it.
Limits: 8 KB, 64 keys, values up to 512 bytes. Nested objects and arrays are ignored. A malformed header is treated as no metadata. Conditional-routing when.metadata rules match string values only, so a number or boolean never matches. To track your own users with this header, see End Users.
Send X-Session-Id (or the OpenAI user field) to make sticky-session and canary routing send a conversation to the same place.
GET /v1/models returns the models your credential may use. Each entry has the standard OpenAI fields plus provider and source. For a workspace-bound credential it lists that workspace’s models as a bare name plus an account/model address. Virtual models are callable by name but not listed.
GET /v1/models/{model} returns one entry, or 404 model_not_found if the model doesn’t exist or you can’t use it.

Errors

Every /v1 error uses the OpenAI error envelope, so SDKs raise their usual exception types:
param is included when a specific request field caused the error. /v1/messages returns the Anthropic shape ({"type": "error", "error": {"type": "authentication_error", "message": "...", "code": "invalid_api_key"}}) for every error, including authentication failures; the gateway code is kept in error.code. See Anthropic Messages API. On a policy refusal the response carries X-ManyLayers-Limit (the level whose limit was hit) and, when waiting helps, Retry-After in seconds. The gateway sends no X-RateLimit-* headers. For which request parameters each provider honours, see OpenAI Compatibility.

Next steps

Request & Response Headers

Every header the gateway reads and returns.

Endpoints

The full list of supported /v1 paths.

Anthropic Messages API

Use the Anthropic SDK or Claude Code against any provider.

Routing

Fallback, load balancing and virtual models.