Use Case:
| Suitable for users who want to use MaiToken models in the terminal or local Codex client for code understanding, code modification, and Agent tasks. |
|---|
Codex custom model providers use the Responses protocol. Since MaiToken provides the Responses API, set Base URL to https://api.maitoken.net/v1 and Codex will automatically call /v1/responses. |
|---|
1. Verify the Responses API Is Available
Select the test command for your OS and replace the MaiToken Key and Model ID with your actual values.
macOS / Linux
export MAITOKEN_API_KEY="<Your MaiToken Key>"export MAITOKEN_MODEL="<Model ID>" curl -sS https://api.maitoken.net/v1/responses \ -H "Authorization: Bearer $MAITOKEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"'"$MAITOKEN_MODEL"'","input":"Reply OK only","stream":false}'Windows PowerShell
$env:MAITOKEN_API_KEY="<Your MaiToken Key>"$env:MAITOKEN_MODEL="<Model ID>" $headers = @{ Authorization = "Bearer $env:MAITOKEN_API_KEY"} $body = @{ model = $env:MAITOKEN_MODEL input = "Reply OK only" stream = $false} | ConvertTo-Json Invoke-RestMethod ` -Method Post ` -Uri "https://api.maitoken.net/v1/responses" ` -Headers $headers ` -ContentType "application/json" ` -Body $body| If the endpoint returns a normal response object or output text, you can proceed with configuration. If it returns 404, verify the exact path of the MaiToken Responses API first. Endpoints that only support Chat Completions cannot be used with this configuration. |
|---|
2. macOS / Linux Configuration
Check Codex: Open a terminal and run
codex --version. If the command is not found, install Codex according to its installation instructions first.Set API Key for Current Session: Run the following command:
export MAITOKEN_API_KEY="<Your MaiToken Key>"This environment variable expires when you close the current terminal window. Using temporary environment variables during testing is safer.
- Create Configuration Directory: Run the following command:
mkdir -p ~/.codex- Open Global Configuration: Run the following command:
nano ~/.codex/config.tomlYou must edit the global configuration file in your user home directory—do not write this into a project's .codex/config.toml.
- Paste Configuration: Paste the following into
config.tomland replace<Model ID>with the exact ID shown in your model restriction list.
model = "<Model ID>"model_provider = "maitoken" [model_providers.maitoken]name = "MaiToken"base_url = "https://api.maitoken.net/v1"env_key = "MAITOKEN_API_KEY"wire_api = "responses"Save File: In nano, press
Control + O, press Enter to confirm, and then pressControl + Xto exit.Launch Codex: Navigate to a test project directory and run
codex. After startup, confirm that the current model shows the Model ID you configured.
10.3 Windows PowerShell Configuration
- Set API Key: Open PowerShell and run the following command:
$env:MAITOKEN_API_KEY="<Your MaiToken Key>"- Create Configuration Directory: Run the following command:
New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex"- Open Configuration File: Run the following command:
notepad "$env:USERPROFILE\.codex\config.toml"Paste the following into the configuration file:
model = "<Model ID>"model_provider = "maitoken" [model_providers.maitoken]name = "MaiToken"base_url = "https://api.maitoken.net/v1"env_key = "MAITOKEN_API_KEY"wire_api = "responses"- Launch Codex: Save the configuration file, return to the same PowerShell window where you set the API Key, navigate to your test project, and run
codex.
| Field | Value |
|---|---|
| Config File | macOS/Linux: ~/.codex/config.toml; Windows: %USERPROFILE%\.codex\config.toml |
model |
<Model ID> |
base_url |
https://api.maitoken.net/v1 |
env_key |
MAITOKEN_API_KEY |
wire_api |
responses |
How to Test After Setup
Test Basic Chat: Enter
"Reply OK only". Receiving a normal reply confirms that your API Key, Base URL, and Model ID are basically correct.Test Project Reading: Open a test project and enter
"Please list the top-level files in the current directory first without modifying any files."Test Agent: After receiving the directory listing, ask the Agent to create a new file named
test-maitoken.txtcontaininghello. Do not run initial tests on a real production project.
Troubleshooting
| Issue | Suggested Fix |
|---|---|
| 401 / Unauthorized | Ensure MAITOKEN_API_KEY is set in the same terminal window where you launch codex, and check for extra spaces before or after the Key. |
| 404 /responses | Make sure base_url ends at /v1. If your platform's Responses API uses a path other than /v1/responses, adjust it according to the actual API documentation. |
model_not_found |
Copy the exact Model ID from the model restriction list and confirm that the model supports the Responses format. |
| Basic replies work but tool calling fails | The model or gateway may not fully support Responses tool calling—switch to a model that supports coding Agents and tool calling. |
