PL Log inOpen Studio
Preview version. Model catalog, prices, calculator and docs are live. Generation goes live at launch.

Codex CLI with Kadraris

Docs: every page

Codex CLI is OpenAI's coding agent for the terminal. It connects to Kadraris through the MCP server. Codex keeps its own model for writing code, and Kadraris adds a set of tools on top:

  • video, image and music generation,
  • cost estimates and your balance,
  • a chat tool for getting a second opinion from Claude, Gemini or DeepSeek.

Everything runs on one key and draws from one balance.

Setup in four steps

1. Create a key for Codex

  1. Go to the dashboard and open API keys.
  2. Call the key codex and give it a Monthly limit, the most the agent is ever allowed to spend (for example 15 dollars).
  3. Click Create key and copy the sk-kd-... value.

2. Put the key in an environment variable

Codex never writes keys into its config. You tell it the name of a variable, and it reads the key from there.

macOS and Linux:

bash
echo 'export KADRARIS_API_KEY="sk-kd-..."' >> ~/.zshrc   # Linux: often ~/.bashrc
source ~/.zshrc

Windows PowerShell:

powershell
[Environment]::SetEnvironmentVariable("KADRARIS_API_KEY", "sk-kd-...", "User")

On Windows, open a new terminal window afterwards, otherwise the variable is not there yet. To confirm, run echo $env:KADRARIS_API_KEY (PowerShell) or echo $KADRARIS_API_KEY (macOS, Linux).

3. Register the MCP server

The command is identical on all systems:

bash
codex mcp add kadraris --url https://kadraris.com/mcp --bearer-token-env-var KADRARIS_API_KEY

If you prefer editing the config yourself, add this to ~/.codex/config.toml (on Windows: %USERPROFILE%\.codex\config.toml):

toml
[mcp_servers.kadraris]
url = "https://kadraris.com/mcp"
bearer_token_env_var = "KADRARIS_API_KEY"

bearer_token_env_var holds the name of the variable, never the key itself. When Codex connects, it sends Authorization: Bearer followed by whatever that variable contains.

4. Test the connection

bash
codex mcp list
codex mcp get kadraris

The output should list a server called kadraris pointing at https://kadraris.com/mcp. Now launch codex and ask:

text
Call get_balance on the kadraris server and tell me how much I have left.

A reply with an amount means the setup is complete.

Using Kadraris as the Codex model itself

This is not possible at the moment. Codex does allow a custom provider through [model_providers] in config.toml, but OpenAI's current documentation lists "responses" as the only accepted wire_api, which means Codex talks to the Responses API at /v1/responses. Kadraris has two chat formats, /v1/chat/completions (OpenAI style) and /v1/messages (Anthropic style), and no /v1/responses. So the following config:

toml
# WILL NOT WORK: Kadraris has no /v1/responses endpoint
[model_providers.kadraris]
name = "Kadraris"
base_url = "https://kadraris.com/v1"
env_key = "KADRARIS_API_KEY"
wire_api = "responses"

gets a 404 on the very first request. Alternatives that do work:

GoalOption
Make videos and images while working in CodexThe Kadraris MCP server, as set up above
Consult other models from inside CodexThe MCP server's chat tool
A terminal agent paid per token from your Kadraris balanceClaude Code, which runs over /v1/messages
An editor that runs on Kadraris modelsCursor, Cline, Roo Code, Continue, OpenCode or Aider, see Integrations

Codex's own usage is billed as before, through your ChatGPT account or OpenAI key.

Example requests for Codex

  • "This repo's landing page needs a hero image. Get 16:9 estimates from Nano Banana Pro and GPT Image 2.5, use the cheaper one, and save the result as public/img/hero.webp."
  • "Generate a 5-second vertical 9:16 clip in Seedance 2.5 of rain running down a café window. Tell me the price before you start."
  • "Use the chat tool to ask claude-sonnet-5 if this database migration is safe, then show me both answers side by side."
  • "Which video models can do 1080p, and how much is a 10-second clip in each?"

Current prices: Seedance 2.5 from $0.261 per second, Nano Banana Pro from $0.07 per image, GPT Image 2.5 $0.05 per image.

The generate tool waits at most 45 seconds for a video. When the clip takes longer, Codex receives a task id and follows up with get_task. Result links expire after a while, so ask Codex to save the file into the project.

Permanent instructions

Codex picks up AGENTS.md from your repository. Download the prepared Kadraris version and add your own lines to it, such as "always state the cost before generating". How to do that: AGENTS.md file.

Troubleshooting

What happensWhy, and the fix
The kadraris server will not connectThe terminal does not have KADRARIS_API_KEY. After SetEnvironmentVariable, open a new window; on macOS/Linux run source ~/.zshrc
401The key was copied incorrectly or has been revoked
402Not enough balance, top up
403The key used up its monthly limit
404 after adding model_providersCodex is calling /v1/responses, which Kadraris does not offer. Delete [model_providers.kadraris] and use MCP
Codex ignores the toolsName them explicitly: "use the generate tool from the kadraris server"