Skip to main content
This guide shows how to use cc-switch to connect Codex to AiToEarn’s OpenAI Chat Completions compatible endpoint. It is useful when Codex expects a Responses API style flow, while you want to use AiToEarn language model access.
If you do not have an API Key yet, read Get API Key first.
Your API Key is a private credential. Do not expose the full key in configuration screenshots, support messages, or shared logs.

Before You Start

Prepare the following:
  1. AiToEarn API Key.
  2. A working Codex installation.
  3. cc-switch. Download the version for your operating system from cc-switch releases.
AiToEarn API Keys are bound to the site where they were created. Use the matching endpoint:
SiteOpenAI Chat Completions endpoint
China sitehttps://aitoearn.cn/api/ai/chat/completions
International sitehttps://aitoearn.ai/api/ai/chat/completions
To confirm available model names, check Chat models.

Configure cc-switch

Open cc-switch and switch the top mode to codex. Switch cc-switch to codex Click the create button to add a new provider. Create a provider configuration Keep the default custom configuration type. Scroll down and fill in:
  • Provider name: use aitoearn so it is easy to recognize.
  • API Key: paste the API Key created in AiToEarn.
  • API request URL: enter the OpenAI Chat Completions endpoint that matches your API Key site.
Then open the advanced options and enable local route mapping. Fill AiToEarn provider settings and enable local routing Save the configuration.

Enable the Provider

Return to the provider list and enable the AiToEarn configuration you just created. Enable the AiToEarn provider Open settings. Open cc-switch settings Go to routing settings. Open routing settings Enable routing. After this, cc-switch handles Codex requests locally and forwards them to the AiToEarn endpoint you configured. Enable Codex routing

Verify the Setup

Keep cc-switch running, then open Codex and send a simple message. If Codex returns a normal response, it is using AiToEarn through cc-switch. If the request fails, check:
  • Whether the API Key belongs to the site used in the request URL.
  • Whether the API request URL matches the API Key site.
  • Whether the AiToEarn provider is enabled.
  • Whether cc-switch Codex routing is enabled.
  • Whether the Codex model name comes from Chat models.