Skip to content

Configure a Custom Model Provider in Codex

Configure a custom Codex model provider safely, match its wire protocol and model catalog, protect credentials, and verify the provider before editing code.

MGMCSA Guru Team August 23, 2026 2 min read
Codex config.toml defining a custom model provider

Codex supports named model providers in ~/.codex/config.toml, but a custom base URL is not enough. The endpoint must support the protocol, streaming events, tool calls, and model metadata Codex expects.

Check compatibility first

Look for a provider-specific Codex integration page. Confirm these items:

Provider compatibility checks

Protocol Responses or another wire API explicitly supported by Codex and the provider
Model ID Exact current API identifier
Authentication Provider key method documented for Codex
Model catalog Required models.json or equivalent metadata
Tools Streaming and tool-call behavior needed by Codex

An endpoint described as OpenAI-compatible may implement only Chat Completions. That does not establish full Codex compatibility.

Back up the configuration

Copy these files before changing them:

~/.codex/config.toml
~/.codex/models.json

The same files may affect Codex CLI, the Codex IDE extension, and the ChatGPT desktop app in that environment.

Add the provider block

A provider-specific guide should supply the exact fields. The structure generally includes a selected model and a matching named provider:

model = "provider-model-id"
model_provider = "myprovider"

[model_providers.myprovider]
name = "My provider"
base_url = "https://provider.example/api"
wire_api = "responses"

Do not copy the example URL or protocol literally. Replace them with values documented by the provider. Add authentication and a model catalog only in the form its current Codex guide requires.

Use a provider-specific setup when available

DeepSeek publishes a Codex setup that uses deepseek-v4-flash, the Responses API, and a custom model catalog. Follow DeepSeek V4 with Codex rather than adapting an old Chat Completions example.

For another provider, use its official Codex page or test the endpoint in an isolated Codex configuration before changing your default.

Verify before editing

Restart Codex after saving the configuration. Check the startup model and send a read-only request from a small repository. Confirm the request in the provider’s logs or usage page.

Common failures:

  • A protocol or stream error often means wire_api does not match the endpoint.
  • A model-not-found response means the model ID or catalog is stale.
  • A login prompt can mean the custom authentication settings did not apply.
  • Missing tools can mean the provider implements basic text generation but not the features Codex needs.

Custom Codex provider checklist

  • Provider-specific Codex documentation located
  • Existing Codex files backed up
  • Exact model ID and wire protocol verified
  • Credential stored outside version control
  • Read-only request confirmed in provider logs

Frequently asked questions

Can Codex use a custom model provider?

Yes. Codex config.toml supports named model provider blocks. The provider still needs an API protocol and tool behavior compatible with the Codex features you use.

Does any OpenAI-compatible endpoint work?

No. OpenAI compatibility can refer to Chat Completions, Responses, or only a subset of either API. Match the provider's documented Codex integration instead of assuming compatibility from its marketing label.

What is wire_api?

wire_api tells Codex which request protocol to use. Current provider integrations such as DeepSeek's Codex guide use responses. Copy the value from the provider's current Codex documentation.

Why might Codex need models.json?

A custom model catalog describes model limits and capabilities that Codex cannot infer from a model name. Some providers publish a catalog as part of their setup.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.