Skip to main content
This guide walks you through using Codex CLI locally and connecting it to the hboom API.

1. What is Codex CLI

Codex CLI is a local terminal AI coding assistant that helps you with:
  • Code generation
  • Code modification
  • Automated command execution
  • Project analysis
Once installed, use it directly in your terminal.

2. Prerequisites

1. Install Node.js

Recommended: Node.js 20 or higher Download: https://nodejs.org

2. Install Codex CLI

npm install -g @openai/codex
Verify installation:
codex --version

3. Configure API

Codex uses a config file for API connection.

1. Config File Location

Default paths:
  • Windows:
C:\Users\<username>\.codex\config.toml
  • macOS / Linux:
~/.codex/config.toml

2. Basic Configuration

Edit config.toml:
model = "gpt-4o"

[model_providers.default]
name = "default"
base_url = "https://betarouter.com/v1"
env_key = "OPENAI_API_KEY"
Fields:
  • model: model name to use
  • base_url: API address (must include /v1)
  • env_key: environment variable name for the API key

3. Set API Key

macOS / Linux

export OPENAI_API_KEY="your-api-key"

Windows (PowerShell)

setx OPENAI_API_KEY "your-api-key"

4. Start Codex

Navigate to your project:
cd your-project
Launch:
codex

5. Basic Usage

1. Interactive Mode

codex
Example prompt:
Write a Python web scraper

2. Single Command

codex "Write a login API"

3. Specify a Model

codex -m gpt-4o "Optimize this code"

4. Image Input (Multimodal)

codex --image "./demo.png"
Analyze and process image content.

6. Troubleshooting

401 / 403 Error

Check:
  • Is the API Key correct?
  • Did the environment variable take effect?

404 Error

Check:
  • Is the API address correct?
  • Does it include the /v1 path?

Model Unavailable

Check:
  • Is the model name correct?
  • Does your account have access to this model?

7. Advanced Configuration

Multiple Models

model = "gpt-4o"

[model_providers.main]
base_url = "https://betarouter.com/v1"
env_key = "OPENAI_API_KEY"

[models]
gpt-4o = { provider = "main" }
gpt-4.1 = { provider = "main" }

8. Best Practices

  • Use environment variables for API keys (more secure)
  • Use consistent model naming for easier switching
  • Use separate configs per project
  • Regularly check usage and logs

9. Summary

After completing the setup, you can:
  • Use AI coding in your local terminal
  • Connect to a unified API service
  • Flexibly switch between models