Integration and examples

GPT API through CLODEx

A Python application needs an API client; Codex needs a provider configured for Responses. This guide shows both and separates the model, the ChatGPT application and your CLODEx key.

GPT, ChatGPT and the gateway

GPT is a model family, ChatGPT is an application, and CLODEx is a separate gateway with its own balance. Requests here follow CLODEx billing. A ChatGPT subscription is not CLODEx API credit, and a CLODEx key is not an OpenAI dashboard credential.

Issue a key for your application and select an exact model available to it: gpt-6.2-astra, gpt-6.2-sol, gpt-6-astra, gpt-6.1-sol, gpt-5.6-sol, gpt-5.6-terra and gpt-5.6-luna are separate IDs, not quality settings on one model. Install the openai Python package in your application environment.

Create an application key · Coding model catalog

Select the protocol your client uses

Keep Chat Completions if that is the contract your application already implements. Codex uses Responses. Moving between them changes input fields, response parsing and tool handling, not just the endpoint URL.

ClientRequestResult
Chat Completionsmessages; /v1/chat/completionschoices[].message and finish_reason
Responses / Codexinput; /v1/responsesoutput items and status

A complete Python Responses example

Set CLODEX_API_KEY and CLODEX_MODEL in the protected process environment first. The example performs one billable text request, without tools or automatic retries. It checks completion and text instead of treating HTTP 200 as proof of success.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["CLODEX_API_KEY"],
    base_url="https://clodex.xyz/v1",
    timeout=60.0,
    max_retries=0,
)
response = client.responses.create(
    model=os.environ["CLODEX_MODEL"],
    input="Reply with one word: ready",
    stream=False,
)
if response.status != "completed" or not response.output_text.strip():
    raise RuntimeError(f"Incomplete text response: {response.status}")
print(response.output_text)
print(response.usage)

Codex configuration from our documentation

Install official Codex, back up ~/.codex/config.toml and merge the block below. Preserve your projects, MCP settings and approval policy. Do not duplicate an existing provider section. env_key names the environment variable; it is not the secret itself.

This is a minimal manual CLI setup. The Codex App installer in /docs also installs a model catalog. Keep its real model_catalog_json path if already configured; a literal /ABSOLUTE/PATH placeholder is not a working catalog location.

Fully restart the application or VS Code after setting the environment. An existing process may not inherit a new variable. Inspect provider and model with /status before working on a repository. Do not disable sandboxing or command approval to make an integration test pass.

# Merge into ~/.codex/config.toml; do not overwrite other settings.
model = "gpt-5.6-sol"
model_provider = "clodex"

[model_providers.clodex]
name = "Clodex"
base_url = "https://clodex.xyz/v1"
wire_api = "responses"
env_key = "CLODEX_API_KEY"
supports_websockets = false
requires_openai_auth = false

OS-specific Codex installers · Codex setup and troubleshooting

Measure the whole agent task

A coding task can make several requests, repeatedly sending history and tool results. Compare the actual charge for the same task and the proportion of patches that pass tests, not only a rate per token.

Model rates, available routes and account constraints are shown in the catalog and dashboard. This guide promises neither a fixed latency nor free Codex inference.

CLODEx rates · Chat Completions example

Documentation and example scope

Connection settings follow CLODEx documentation. Examples target the stated protocol; they are not recorded inference results and do not promise identical features across models. A successful generation request can incur a charge.

Client configuration · API protocols

Frequently asked questions

Why is choices absent?

Responses uses output items and a status. The Python SDK provides output_text for text. A Chat Completions parser cannot consume the raw Responses body unchanged.

Is a new key required for each model?

Not necessarily. One key can access several models, subject to key and group restrictions. A different model name does not grant access by itself.

Can the key go in a browser app?

No. Browser JavaScript and network traffic expose it. Send model requests through your backend, which checks user authorization and limits.

Connect CLODEX API to your application

One key-management layer, compatible endpoints and several LLM families for apps, agents and developer tools.