Skip to main content
OpenAI Codex talks to Tokios through the Responses API. Add Tokios as a model provider in ~/.codex/config.toml, point it at https://api.tokios.com/v1, and Codex runs against your own local model — on Ollama, LM Studio, or any OpenAI-compatible backend — from anywhere, down your private tunnel.

Prerequisites

Configure Codex

Set your Tokios key in the environment, then add a Tokios provider and profile to ~/.codex/config.toml:
~/.codex/config.toml
wire_api = "responses" and disable_response_storage = true are both required. Tokios serves the Responses surface statelessly, so Codex must not rely on server-side response storage.
Then run Codex with the Tokios profile:
Replace gemma-tunnel with the public model name you registered in the console.

Using the OpenAI Python SDK

To call your local model programmatically with the OpenAI SDK, point the client at the Tokios base URL:
openai_tokios.py
The OpenAI SDK’s base URL must end with /v1. The Tokios endpoint is https://api.tokios.com/v1.

Troubleshooting

Your sk-tok-… key is missing or wrong. Confirm OPENAI_API_KEY is set in the environment and that env_key = "OPENAI_API_KEY" in config.toml matches. Check the key on the Keys tab — it was shown only once at creation.
The model in your config.toml profile does not match any deployment name. Check the Models tab for the exact name you registered — it is case-sensitive.
The connector for that deployment is offline or at its concurrency cap. Check the Connectors tab — the connector needs to show as Online, and the machine running it needs to still be up.
Confirm you are passing --profile tokios on the command line. Without the flag, Codex uses its default profile, which points at OpenAI’s hosted API. You can also set default_profile = "tokios" under [general] in config.toml to make it the default.

Next steps

Compatible clients

See base URL and key setup for other OpenAI- and Anthropic-compatible clients.

API keys

Create, scope, and rotate sk-tok-… keys for teammates and agents.