Core AI Coding Tools

Codex CLI

OpenAI’s official terminal agent, using the Responses protocol.

1Install

Requires Node.js 22 or later. Skip this if Codex is already installed.

Terminal
npm install -g @openai/codex
codex --version

2Configure access

YOUR_API_KEY in the examples is a placeholder and will not work as copied. Sign in to pick one of your keys and fill it into every example on this page.

Sign in to fill in key

Codex uses config.toml to configure custom providers. Replace YOUR_API_KEY with your API key, or choose a key at the top of the page to fill it in automatically.

Manual setup: put the top-level keys at the beginning of ~/.codex/config.toml and the keyvia section at the end, preserving other content
model_provider = "keyvia"

[model_providers.keyvia]
name = "KeyVia"
base_url = "https://api.keyvia.cc/v1"
experimental_bearer_token = "YOUR_API_KEY"
wire_api = "responses"
requires_openai_auth = false
Or run this in your terminal to merge and back up config.toml.bak. Nothing is downloaded.
node - <<'EOF'
const fs = require("fs"), path = require("path")
const file = path.join(require("os").homedir(), ".codex", "config.toml")
fs.mkdirSync(path.dirname(file), { recursive: true })
let lines = []
if (fs.existsSync(file)) {
  fs.copyFileSync(file, file + ".bak")  // Back up the existing file
  lines = fs.readFileSync(file, "utf8").split(/\r?\n/)
}
// Remove top-level model_provider and the old [model_providers.keyvia] section; preserve other content
let top = true, skip = false
lines = lines.filter(line => {
  const table = line.match(/^\s*\[([^\]]+)\]/)
  if (table) { top = false; skip = ["model_providers.keyvia", "model_providers.easyapi", "model_providers.dtrading"].includes(table[1].trim()); return !skip }
  if (skip) return false
  return !(top && /^\s*(model_provider)\s*=/.test(line))
})
while (lines.length && !lines[0].trim()) lines.shift()
while (lines.length && !lines[lines.length - 1].trim()) lines.pop()
const head = ["model_provider = \"keyvia\"", ""]
const tail = ["", "[model_providers.keyvia]", "name = \"KeyVia\"", "base_url = \"https://api.keyvia.cc/v1\"", "experimental_bearer_token = \"YOUR_API_KEY\"", "wire_api = \"responses\"", "requires_openai_auth = false", ""]
fs.writeFileSync(file, [...head, ...lines, ...tail].join("\n"))
console.log("Merged into " + file + " (original backed up as config.toml.bak)")
console.log("Setup complete. Go to your project directory and run codex to start.")
EOF

Field reference

base_url includes /v1; wire_api = "responses" selects the Responses protocol. The key’s group must support OpenAI. Setup does not assign a default model and preserves existing client model settings.

3Verify

Open your project directory and run codex. If it can read the project and respond, setup is complete.

  • For 401 / 403 / 429 errors, see Error codes.
  • If a model is unavailable, check the Model catalog for the exact model name, then confirm the key’s group supports OpenAI.
KeyVia Logo
KeyVia

One API for full-power Claude, GPT, Gemini and other leading AI models at ultra-low prices.

© 2026 KeyVia. All rights reserved.