Skip to main content

Guide to Using Codex CLI with AGIPower

Codex CLI is an open-source programming assistant from OpenAI that runs in your local terminal. It can read, modify, and run code within a directory you choose. Built with Rust, it is fast and efficient, and is continuously improved on GitHub. By integrating with AGIPower, you gain access to more model options instead of being limited to the official OpenAI API.
OpenAI has explicitly positioned Responses as the next-generation unified interface. Chat Completions is still available, but it is no longer the preferred choice for new projects. Codex will follow this direction as well—treating Chat Completions as a compatibility option and gradually migrating to Responses (the configuration in this article uses Responses).Note the OpenAI-compatible setting: base_url=“https://api.agipower.ai/v1”.

Configuration Options

Install Codex CLI

npm/pnpm

Configure Environment Variables

Add your AGIPower API Key to your shell configuration file:
Make sure to replace sk-xxx with your actual AGIPower API Key. You can obtain an API Key in the AGIPower Console.

Configure Codex

Create or modify the Codex configuration file ~/.codex/config.toml:
  • model_provider: Use AGIPower as the model provider
  • model: The model to use; can be any model supported by AGIPower
  • base_url: The base URL of the AGIPower API
  • env_key: The name of the environment variable that stores the API Key
  • wire_api: Use the Responses protocol (recommended)

Start Using It Immediately

After configuration, reload your shell configuration and start Codex:
After adding the environment variable to your shell configuration file, you won’t need to set it manually each time. The configuration will apply automatically every time you open a new terminal.

Supported Models

You can freely switch the model field in config.toml to any model supported by AGIPower.
Below are some recommended models with strong coding performance: For more models, see the AGIPower model list.

Responses-Compatible Models (Fetched on 2026-01-29)

The list below is fetched from the AGIPower model list (Responses filter). Use that link for the latest updates.

Model slug list (Responses)

Troubleshooting

Common Issues

API Key Error

Issue: You are told the API Key is invalid or unauthorized. Solutions:
  • Check whether the environment variable AGIPower_API_KEY is set correctly
  • Use echo $AGIPower_API_KEY to verify the environment variable value
  • Confirm the API Key is active and that you have sufficient balance
  • Verify the API Key format starts with sk-

Connection Failure

Issue: Codex CLI cannot connect to the AGIPower service. Solutions:
  • Check that your network connection is working
  • Verify that base_url in config.toml is correctly set to https://api.agipower.ai/v1
  • Confirm your firewall settings are not blocking outbound connections
  • Try curl https://api.agipower.ai/v1/models to test connectivity

Environment Variable Not Taking Effect

Issue: Even after setting the API Key, it still says it is not configured. Solutions:
  • Reopen the terminal window, or run source ~/.zshrc or source ~/.bashrc to reload the configuration
  • Confirm the environment variable is set correctly: echo $AGIPower_API_KEY
  • Make sure you added it to the correct shell configuration file (.zshrc for zsh, .bashrc for bash)

Configuration File Path Issue

Issue: Changes to the configuration file do not take effect. Solutions:
  • Confirm the configuration file path is ~/.codex/config.toml
  • If the directory does not exist, create it first: mkdir -p ~/.codex
  • Check that the configuration file syntax is correct (TOML format)
  • Use cat ~/.codex/config.toml to verify the file contents

Model Unavailable

Issue: A model is reported as unavailable or unsupported. Solutions:
  • Visit the AGIPower model list to confirm the model is available
  • Check that the model slug is spelled correctly
  • Try another recommended model to test
  • Confirm your account has permission to access the model

Advanced Configuration

Configure Models of Different Sizes

You can switch between different model sizes in config.toml based on your task requirements:
Balanced Setup
Performance-First Setup
Cost-Optimized Setup
If you run into any issues during use, or if you have suggestions or feedback, feel free to contact us via:For more contact methods and details, please visit our Contact page.