Skip to main content
OpenAI Codex and the OpenAI CLI use OPENAI_BASE_URL to determine the API endpoint. Set this to https://api.tokios.com along with your Tokios key, and Codex routes to your local model through the Tokios tunnel.

Prerequisites

Set up the environment

codex-windows.cmd
set OPENAI_BASE_URL=https://api.tokios.com
set OPENAI_API_KEY=sk-tokios-YOUR_KEY_HERE
codex --model gemma-tunnel
Replace gemma-tunnel with the exact model name you registered in the Tokios dashboard.

Using the OpenAI Python SDK

If you prefer to call your local model programmatically, initialize the OpenAI client with the Tokios base URL and your API key:
openai_tokios.py
import openai

client = openai.OpenAI(
    base_url="https://api.tokios.com/v1",
    api_key="sk-tokios-YOUR_KEY_HERE",
)

response = client.chat.completions.create(
    model="gemma-tunnel",
    messages=[{"role": "user", "content": "Explain async/await in Python"}],
)
print(response.choices[0].message.content)
The OpenAI Python SDK requires the base URL to end with /v1. The Tokios endpoint is https://api.tokios.com/v1.