If your application must restrict which models a caller can select, do not use the AI SDK’s model-ID autocomplete list as the enforcement boundary. In the documented @ai-sdk/openai-compatible example, accepting IDs outside that list is intentional.
This matters when a model ID comes from configuration, a request field, or a user-selectable setting rather than a literal you type in the editor.
What the autocomplete example actually promises
The AI SDK’s “Including model ids for auto-completion” section defines four types:
| Type | Where the documentation uses that family of ID |
|---|---|
ExampleChatModelIds |
chatModel(id) |
ExampleCompletionModelIds |
completionModel(id) |
ExampleEmbeddingModelIds |
embeddingModel(id) |
ExampleImageModelIds |
imageModel(id) |
Each union combines named string literals with (string & {}). The four types are then supplied to createOpenAICompatible in chat, completion, embedding, image order. The language-model section also documents provider(id) and languageModel(id) as chat-model constructors.
The example’s comment makes the intended tradeoff explicit: model.chatModel offers autocomplete from ExampleChatModelIds “while still allowing free-form strings as well.” The named entries are suggestions, not an exhaustive permitted set. Treat those IDs as documentation examples, not as a current catalog for your endpoint.
Separate three different questions
A review of model selection should distinguish:
- Does the editor suggest this ID, or does the type accept it? The documented example deliberately accepts free-form strings.
- Does this application permit the selection? That is an application-policy decision, not established by the autocomplete example.
- Can this endpoint successfully serve the requested operation with this account? Neither a suggested ID nor constructing a model object proves that.
The engineering consequence is straightforward: a caller-supplied string can fit the documented type without belonging to your intended application allowlist. Even replacing the permissive union with a narrower TypeScript type does not, by itself, add a runtime membership check to external input.
That is a boundary argument, not a claim that the SDK or a provider has no other controls.
Put the restriction before model construction
For an application that requires restricted selection, I would use this flow:
- Select a trusted provider configuration and the intended model family first. Keep policy specific to that combination rather than maintaining one undifferentiated list of IDs.
- Treat an externally supplied model ID as unvalidated input. Check that it is a string and an exact member of the application’s approved set.
- Reject an unapproved value before passing it to
chatModel,completionModel,embeddingModel, orimageModel. Do not silently forward it just because the SDK type accepts it. - Pass only the validated value into the appropriate factory. Keep remote request handling separate: locally allowed does not mean remotely available or authorized.
These are proposed application controls, not a built-in AI SDK allowlist feature documented on this page.
A useful test plan would include an approved ID, an unlisted but plausible ID, a non-string input, and an ID approved for a different provider or model family. For rejected inputs, check both the application error and the absence of an outgoing model request. Separately test the approved path against the intended endpoint; that answers a different question from whether local policy rejected bad input.
No compiler check or endpoint request was run for this article. The source is the AI SDK OpenAI Compatible Providers documentation, captured September 13, 2026, with no supplied publication date; this is not a claim of a newly released feature.
Keep autocomplete for developer convenience. Use an explicit runtime check when “these are the suggested IDs” needs to become “these are the only selections this application permits.”