wire_api = "responses")が必須だが、Codexに内蔵されているOllamaプロバイダーはlocalhostまでしか対応しておらず、別のマシン上のモデルを指定することはできない。Tokiosは/v1/responsesを処理し、バックエンド向けにChat Completions形式へ変換するため、Ollama、llama.cpp、vLLM、LM Studioが稼働するリモートマシンも通常のhttpsエンドポイント経由でCodexのプロバイダーとして機能する。
This page assumes you already have Tokios and Codex working together — see Use OpenAI Codex with your own local models for the full config.toml walkthrough. Read on if your model lives on a different machine than the one running Codex, or if you’re troubleshooting a provider that won’t connect.
前提条件
- A connector installed and paired next to the model — on whichever machine that is, not the one running Codex
- A registered deployment name for that model
- A Tokios API key (
sk-tok-…) - Codex CLI installed on the machine where you run
codex
Codexの設定方法
モデルが自分の近くにある場合でもネットワーク越しにある場合でも、プロバイダー設定内容は同一だ。場所の違いを問題にしなくて済むのはTokiosのおかげである。~/.codex/config.tomlでは以下のように設定する:
~/.codex/config.toml
gemma-tunnel with the deployment name you registered for the remote model — not its local upstream model id, and not a localhost address.
ローカルホストでは動作しないのに、なぜこれが機能するのか
Codexが利用するカスタムプロバイダーにはwire_api = "responses"が必須です。Codexは設定したプロバイダーに対してResponses APIを通じて通信しますが、組み込みのOllamaプロバイダーでは localhost形式のベースURLがハードコーディングされているため、別マシン上のモデルを指すことができません。
リモートモデルがCodexのプロバイダーとして機能するためには、二つの条件が同時に満たされる必要があります。エンドポイントがResponses APIに応答できること、そしてCodexがどこから実行されても到達可能な安定した https形式のアドレスであることです。ほとんどのローカル推論サーバー(Ollama、llama.cpp、vLLM、LM Studioなど)はChat Completionsしか対応していません。Tokiosゲートウェイはコネクターの前段に配置され、Codexから送られてきた /v1/responsesリクエストをChat Completions形式に変換してバックエンドへ転送します。バックエンド側はResponses APIの存在を意識する必要がなく、Codexも localhost形式のプロバイダーを必要としません。どのマシンやネットワーク、コネクターを経由しても https://api.tokios.com/v1と通信するだけです。
disable_response_storage = trueは wire_api = "responses"と併せて必須です。TokiosはResponses APIの機能をステートレスに提供するため、Codexは各リクエスト間でサーバー側の応答情報を保存することに頼ってはいけません。正常に動作しているか確認する方法
設定したプロファイルを使って簡単なプロンプトを送信してみましょう。トラブルシューティング
401 — APIキーが存在しない、または無効である
401 — APIキーが存在しない、または無効である
Codexから送信されたキーがTokiosで認識できない状態です。
OPENAI_API_KEYに sk-tok-… 形式の正しいAPIキーが設定されているか、また codexを起動したシェル環境下でそのキーが Keysタブ上で無効化されていないかを確認してください。404 — デプロイされたモデルが見つからない
404 — デプロイされたモデルが見つからない
The
model value in [profiles.tokios] doesn’t match a registered deployment. It must be the public name you chose on the Models tab (for example, gemma-tunnel) — not the upstream model id your backend uses locally.503 — コネクターがオフラインまたは処理能力上限に達している
503 — コネクターがオフラインまたは処理能力上限に達している
The connector paired with that deployment isn’t currently connected, or it’s at its concurrency cap (
connector_unavailable / connector_busy). Check that the connector process is running on the machine next to the model and shows Online on the Connectors tab.CodexはTokiosの代わりに組み込みのプロバイダーを利用する
CodexはTokiosの代わりに組み込みのプロバイダーを利用する
Confirm you’re launching with
--profile tokios. Without a profile flag, Codex uses its default provider, not the one in [model_providers.tokios].次に行うこと
OpenAI Codexの基本的なセットアップ手順
OpenAI SDKの設定方法を含む、
config.toml の詳細な手順説明クイックスタートガイド
コネクターをペアリングし、最初のモデルを登録するまでの一連の流れです。