Instructions
Desktop app

How to connect Codex Desktop to Apily

Connect Codex Desktop to Apily

Connect the Codex desktop app to Apily with one personal configuration: your Apily key, a local model catalog for the picker and a new local Codex chat.

Prefer the terminal? Codex CLI reads the same configuration; see the Codex CLI guide.
Tool
Codex desktop app OpenAI Responses
Base URL
https://api.apily.pro/v1
Key
apily_your-api-key

1. Install the official desktop app

  1. Install the official app from OpenAI's Codex app page.
  2. Open the installed app once.
  3. Fully quit the app before editing its configuration; save any open work first.
The current desktop app may be labeled ChatGPT. Use its Codex workspace for these instructions, not ChatGPT chat, Work Cloud or a cloud task.

2. Save the Apily model catalog

  1. Open your personal ~/.codex folder, or %USERPROFILE%\.codex on Windows. Create it if absent.
  2. Save the catalog in that folder as apily-codex-models.json using the download link: Download the model catalog.
  3. Copy the catalog’s full absolute path for model_catalog_json; do not use a relative path or ~.

3. Add your personal configuration

Use your personal ~/.codex/config.toml (%USERPROFILE%\.codex\config.toml on Windows), not the project config. If CODEX_HOME is set, use config.toml in that directory.

  1. Make a private backup of the existing configuration before editing it. If absent, create the personal directory and file.
  2. Merge this example without replacing unrelated settings or duplicating keys. Keep the top-level settings before the first [table].
    Personal config.toml
    model = "gpt-6.1-terra"
    model_provider = "apily"
    model_reasoning_effort = "low"
    model_catalog_json = "/ABSOLUTE/PATH/apily-codex-models.json"
    web_search = "disabled"
    
    [model_providers.apily]
    name = "Apily"
    base_url = "https://api.apily.pro/v1"
    wire_api = "responses"
    experimental_bearer_token = "apily_your-api-key"
    requires_openai_auth = false
    supports_websockets = false
  3. Replace the sample key in the provider table with your own Apily key. How to create a key.
  4. Replace model_catalog_json with the copied absolute path. For Windows paths, use a TOML single-quoted literal string so backslashes remain unchanged.
  5. Save the configuration file.
Keep /v1 exactly once in the base URL; do not append /responses. Preserve wire_api = "responses" and supports_websockets = false.
Protect your key. This setup stores the API key in plain text in your personal configuration. Keep the file private: never put it in a project repository, screenshots, shared exports or public backups. To keep the key outside TOML, use the environment variable option further down this guide.

4. Open a local chat

Open the Apily model catalog and current prices — Compare current prices before testing: use the lowest-cost compatible model in the supplied catalog. The example ID is not a price or availability guarantee.

  1. Reopen the desktop app.
  2. Open a local project in the Codex workspace, not a cloud task.
  3. Start a new local Codex chat.
  4. Select the chosen catalog model in a new local chat; start with Light (low) reasoning if supported.

5. Verify the connection

  1. Send this prompt in the client chat.
    Codex Desktop · prompt
    Reply with exactly OK. Do not use tools.
  2. Confirm that the client’s answer is exactly OK.
  3. In Apily, open Usage → Request log and find this paid request by time, model and API key. Inspect its Cost and cost breakdown. Open Usage.
Your Apily key belongs in the provider configuration above, not in the OpenAI API key sign-in form. Signing in to the app account is separate from this model connection and does not replace the Apily key. For an Apily-only setup, save the provider configuration before restarting the app.

6. Optional: models, catalog and environment key

The downloaded catalog adds these Apily model IDs to the Codex picker. It contains complete Codex model records, so you do not need to build a model list by hand.

  • gpt-6.1-terra — default in this guide
  • gpt-6-astra · gpt-6-luna · gpt-6.1-sol — choose it in the model picker of a new Codex chat

To change the startup model, edit the top-level model value to a catalog ID. Start a new local chat after changing the model or provider.

When you get an updated catalog, replace the file at the same path and restart Codex. Leave model_catalog_json pointing to that file. Existing chats may keep their previous model, so start a new chat after the change.

Use a Codex catalog, not a raw API model list. Apily's /v1/models returns a general API inventory, while Codex expects a different catalog format. Do not point model_catalog_url at that endpoint or save its response as the catalog.

In a managed environment, replace only the experimental_bearer_token line inside the existing Apily provider table with:

Remove experimental_bearer_token; do not configure both methods. Pass APILY_API_KEY securely to the process that actually launches Codex. A variable set only in a terminal is not visible to an app opened from the Dock, the Start menu or an already running editor. Fully restart the app after updating its launch environment.

config.toml · model_providers.apily
env_key = "APILY_API_KEY"

Codex CLI on the same computer reads the same personal configuration. Open your project directory and run codex. Use /status to check the provider and model, and /model to choose a catalog model. Windows, WSL and remote machines have their own home directories; configure the environment where Codex actually runs.

Troubleshooting

SymptomCauseFix
TOML parse error or duplicate keyA key or table is defined twice, or the quotes are wrong.Keep one definition of each key and table. Use a plain-text editor and straight quotes, and single-quoted literal strings for Windows paths.
Models missing from the pickerCodex cannot read the catalog.Check that the file exists at the absolute model_catalog_json path, that the setting comes before all table headers and that the file is JSON, not HTML or .json.txt. Restart the app.
Wrong model or providerThe provider is not set at the top level, or a launch override wins.Confirm the top-level model_provider = "apily" and a matching [model_providers.apily] table. Quit and reopen the app, start a new local chat and remove conflicting launch overrides.
WebSocket or streaming errorThe connection tries WebSockets, or a proxy breaks streaming.Keep supports_websockets = false to stream over HTTPS. Check your network and proxy, then retry in a new chat.
404 Not foundhttps://api.apily.pro/v1 — The Base URL must include /v1 exactly once and must not end in /responses. Keep wire_api set to responses.Base URL: https://apily.pro/v1 — every request must land on a path Apily serves (/chat/completions, /responses, /models, …).
401 Missing API keyNo auth header was sent.Apily accepts Authorization: Bearer … and x-api-key: ….
401 Invalid API keyKey copied with stray spaces, truncated, or revoked.Copy the entire key from API in your Apily account, including the apily_ prefix, without extra spaces.
403 Email not verifiedYour Apily account's email address isn't verified yet.Verify your email from the banner in the Apily app, then retry.
402 Insufficient balanceYour token balance can't cover the request's estimated cost.Top up your balance on the Billing page in your Apily account.
503 Model temporarily unavailableThe model exists, but no upstream provider is reachable right now.Retry in a moment — it usually recovers within a minute. Switch models if it keeps happening.

Return to your previous provider

  1. Fully quit the app before editing its configuration; save any open work first.
  2. Restore only the settings changed for Apily from your private backup. Without a backup, remove only the added Apily table and restore your previous top-level model, provider, catalog, reasoning and web-search values; do not delete the Codex directory or credentials.
  3. Reopen the desktop app.

Official sources

Codex desktop app · Connect Codex to a gateway · Configuration reference

Need help?Setup guides