model field of an incoming request against a registered model row, so an account with a perfect credential and no models answers model_not_found for everything.
You can register models by name, and for some providers you must. Where the provider’s API can enumerate them, ManyLayers asks it instead: the set of models differs per account, names are long and versioned, and a typo is otherwise not discovered until a request fails at the gateway.
In the console this is the second step of Gateway → Providers → Add account (Models Selection), and Add Model on an existing account. The endpoints below are what the console calls.
These are control-plane endpoints on
https://app.manylayers.io, not on the /v1 data plane. Authenticate with a session or a personal access token (Authorization: Bearer ml_pat_…); a personal access token is bound to the workspace it was issued for, and a session caller names the workspace with workspace_id when it has more than one. Discovery makes one call upstream per request, and saving a selection clears the resolver’s cache for the workspace. Neither is on the request path.The flow
api_key (a pasted key, sealed at rest) or secret_reference, never both. See Credentials. Single models can also be added with POST /admin/gateway/providers/{id}/models.
What this gateway can talk to
Lists the provider types this build can register, whether each can be asked for its models, its default endpoint, and the models the console offers before a credential exists. The console’s provider and model choosers both read it, so they cannot drift from what the API will accept. Types that are addressed differently also carryrequires_region (AWS accounts), requires_project (Vertex), requires_upstream_workspace (Claude Platform on AWS) and api_versions (Cartesia). A type with no default_base_url is either addressed by region or project (the Bedrock family, SageMaker and Vertex), where a base URL is an optional override, or must be given one (for example azure, databricks, snowflake_cortex, cloudera, and self_hosted when its models carry no URL).
models here are suggestions, not entitlements. Only the provider knows what a given account may call; discovery is what asks it. See Providers for the types.
Discovering models
Resolves the provider’s stored credential and makes one authenticated call to its model listing, through the same credential injector the request path uses, so a listing that succeeds proves the credential real traffic would present is accepted. It needsgateway.models.read and times out after 15 seconds.
configured and enabled describe what this account already does, so a console renders its checkboxes in the state the gateway is actually in. A price is filled in from the provider’s own listing when it gives one, otherwise from the published list price when the gateway knows the model.
Which providers can be asked
Azure, Vertex and the others above have no listing the gateway can call with the account’s credential: an Azure deployment name is chosen by whoever created it, Vertex enumerates per project and location, and the rest document registering models by ID. For these the console offers its suggested models, and you register anything else by name. A
self_hosted account with no URL of its own has no one server to ask (400 missing_base_url); give each model its server’s URL.
Failure modes
The resolved secret never appears in a response, an error or a log line.
Testing a selection
Discovery says what an account lists. This says what it serves, by sending one real, minimal request per model through the same adapter, the same credential injector and the same base URL live traffic uses. It needsgateway.models.manage, since it spends the account’s credential. In the console it is the Test Connection button.
The two are not the same fact, and the gap between them is what nothing else catches: a listing carries models the organization is not entitled to, models retired behind the listing, and models whose name is right for a different account. Each of those is a 404 at request time, hours after someone saved the selection.
PUT.
The three outcomes
skipped is a state of its own rather than a failure, because “we did not ask” and “we asked and it said no” have opposite fixes. A model is skipped when:
- its type is anything other than
chat,completion,embeddingorrerank(on providers other than the four speech-only ones, which use their own free checks); - the provider cannot serve that endpoint (for example an embedding model on a chat-only provider);
- the account is Azure, which calls a deployment rather than a model name.
/v1/chat/completions, /v1/completions, /v1/embeddings and /v1/rerank respectively. A model with no model_type is treated as chat, the same reading the model rows use. Speech-only providers (ElevenLabs, Deepgram, Cartesia, Smallest AI) are checked against a free listing or voice lookup rather than by synthesizing or transcribing anything. Bedrock and Vertex accounts are probed like the rest: the account’s region and project are part of the address.
Stages
stage is the coarse reason behind a failed, so identical failures group into one thing to fix rather than N rows to read:
Each entry is a billed request against your own account, so a batch is capped at 50 models (
too_many_models), at most five run at once, each is bounded at 20 seconds, and the whole batch at 90. The console probes a longer selection in successive batches.max_tokens by name is retried once with max_completion_tokens, so a working model is not reported as broken over the probe’s own request shape.
Failure modes
The resolved secret never appears in a response, an error or a log line, and a provider that quotes the key back in its own error message is not passed through verbatim.
Choosing models
Applies a whole selection in one transaction: a named model that is not registered is created, and one that is has its enabled flag, display name and (for self-hosted and Cloudera models) URL and server brought into line. It needsgateway.models.manage.
provider_model_name is accepted as a synonym for model_name. gateway_model_name, display_name, model_type, context_window, input_price_per_1k and output_price_per_1k are optional. model_type is one of completion, chat (the default), embedding, rerank, moderation, audio_transcription, audio_translation, audio_speech, image, video, responses or decision, on any provider type. Only chat, embedding, rerank, audio_speech and audio_transcription are served from a workspace account; the others are stored as tags and answer 404 model_not_found at request time. enabled defaults to true: selecting a model means serving it.
Pricing
A model registered with no price is costed at zero for ever, which reads downstream as free rather than as unpriced. An omitted price (both0) therefore falls back to the model’s published list price when the gateway knows it, written into the row so the number is visible and editable. Pass an explicit price only if your rate differs, and 0 only if the model really is free. To change prices later, PATCH /admin/gateway/providers/{id}/models/{modelID} takes input_price_per_1k and output_price_per_1k together.
Validation
A rejected selection writes nothing. A gateway name is a name callers have hardcoded, so this endpoint will not move one: register the new name and retire the old one, or use
PATCH /admin/gateway/providers/{id}/models/{modelID} with provider_model_name to repoint the existing name at a different upstream model.
After saving
The resolver caches “what does this name resolve to, in this workspace”, credential and all, for thirty seconds. Saving a selection drops that workspace’s cache, so a model you have just enabled serves immediately and one you have just disabled stops immediately, rather than somewhere in the next half minute. A request for a model that is disabled, or was never registered, fails at the gateway withmodel_not_found and is never sent upstream. The two are deliberately indistinguishable to the caller.
Isolation and permissions
Every route here is scoped to the caller’s organization and workspace, in the SQL rather than by a comparison afterwards. A provider in another workspace is404, not 403: a distinguishable “forbidden” would confirm that a guessed id names something real.
Permissions: gateway.models.read to list and discover, gateway.models.manage to select, test and delete; gateway.providers.manage to create accounts and credentials. An account can also be restricted to named users, teams or virtual accounts under Access Control; see Model resolution.