Skip to content

Codex CLI Guide

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

bash
npm install -g @openai/codex

Verify installation:

bash
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:

toml
model = "gpt-4o"

[model_providers.default]
name = "default"
base_url = "https://hboom.ai/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

bash
export OPENAI_API_KEY="your-api-key"

Windows (PowerShell)

powershell
setx OPENAI_API_KEY "your-api-key"

4. Start Codex

Navigate to your project:

bash
cd your-project

Launch:

bash
codex

5. Basic Usage

1. Interactive Mode

bash
codex

Example prompt:

Write a Python web scraper

2. Single Command

bash
codex "Write a login API"

3. Specify a Model

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

4. Image Input (Multimodal)

bash
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

toml
model = "gpt-4o"

[model_providers.main]
base_url = "https://hboom.ai/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

hboom AI