# Codex Integration Guide --- ## Overview AxonHub can act as a drop-in replacement for OpenAI endpoints, letting Codex connect through your own infrastructure. This guide explains how to configure Codex and how to combine it with AxonHub model profiles for flexible routing. ### Key Points - AxonHub performs AI protocol/format transformation. You can configure multiple upstream channels (providers) and expose a single OpenAI-compatible interface for Codex. - You can aggregate Codex requests from the same conversation by configuring `server.trace.extra_trace_headers`. ### Prerequisites - AxonHub instance reachable from your development machine. - Valid AxonHub API key with project access. - Access to Codex (OpenAI compatible) application. - Optional: one or more model profiles configured in the AxonHub console. ### Configure Codex 1. Edit `${HOME}/.codex/config.toml` and register AxonHub as a provider: ```toml model = "gpt-5" model_provider = "axonhub-responses" [model_providers.axonhub-responses] name = "AxonHub using Chat Completions" base_url = "http://127.0.0.1:8090/v1" env_key = "AXONHUB_API_KEY" wire_api = "responses" query_params = {} ``` 2. Export the API key for Codex to read: ```bash export AXONHUB_API_KEY="" ``` 3. Restart Codex to apply the configuration. #### Trace aggregation by conversation (optional) If Codex sends a stable conversation identifier header (for example `Conversation_id`), you can configure AxonHub to use it as a fallback trace header in `config.yml`: ```yaml server: trace: extra_trace_headers: - Conversation_id ``` #### Testing - Send a sample prompt; AxonHub's request logs should show a `/v1/chat/completions` call. - Enable tracing in AxonHub to inspect prompts, responses, and latency. ### Working with Model Profiles AxonHub model profiles remap incoming model names to provider-specific equivalents: - Create a profile in the AxonHub console and add mapping rules (exact name or regex). - Assign the profile to your API key. - Switch active profiles to alter Codex behavior without changing tool settings.
Model Profiles
Model Profiles
#### Example - Request `gpt-4` → mapped to `deepseek-reasoner` for getting more accurate responses. - Request `gpt-3.5-turbo` → mapped to `deepseek-chat` for reducing costs. ### Troubleshooting - **Codex reports authentication errors**: ensure `AXONHUB_API_KEY` is exported in the same shell session that launches Codex. - **Unexpected model responses**: review active profile mappings in the AxonHub console; disable or adjust rules if necessary. ### Related Documentation - [Tracing Guide](tracing.md) - [Chat Completions](../api-reference/unified-api.md#openai-chat-completions-api) - README sections on [Usage Guide](../../../README.md#usage-guide)