Connect Codex to Model.sale.
Use one prepaid Model.sale key in Codex CLI, Codex App or VS Code. The connection uses the Responses protocol, keeps the secret local and charges the same wallet as the rest of your API usage.
https://api.model.sale/v1 as the base URL and select a model returned by /v1/models.Before you start
- Sign in at model.sale and create an API key under API Keys. The full secret is shown once.
- Deposit funds in Billing, or use the one-time Telegram test credit if your account is eligible.
- Open
GET https://api.model.sale/v1/modelsand choose a model whose status is live. Do not guess a model ID or silently substitute another model. - Have the Codex client installed, then choose either the environment-variable method or the TOML configuration below.
Option A — local environment variable
This is the simplest setup for Codex CLI and works well for local development. The value is read by the client at runtime rather than being embedded in the command.
mkdir -p "$HOME/.config/model-sale"
umask 077
read -rsp "Model.sale API key: " MODEL_SALE_API_KEY; echo
printf 'export MODEL_SALE_API_KEY=%q\n' "$MODEL_SALE_API_KEY" > "$HOME/.config/model-sale/env"
chmod 600 "$HOME/.config/model-sale/env"
unset MODEL_SALE_API_KEY
source "$HOME/.config/model-sale/env"Add the final source line to ~/.zshrc or ~/.bashrc if you want it loaded in new shells. Restart Codex after changing the environment.
Option B — Codex custom provider
Codex supports a custom provider in ~/.codex/config.toml. Keep the key outside this file and reference it through env_key.
[model_providers.model_sale]
name = "Model.sale"
base_url = "https://api.model.sale/v1"
env_key = "MODEL_SALE_API_KEY"
wire_api = "responses"If you already have a config, back it up before editing. Select model_sale as the provider in the client and choose a live model from the catalog. The exact UI label can differ between Codex releases.
Codex App and VS Code
- Open the provider or custom endpoint settings in the app or extension.
- Set the base URL to
https://api.model.sale/v1. - Choose Responses as the wire protocol when the client asks for one.
- Set the API-key environment variable to
MODEL_SALE_API_KEY; do not paste the secret into a project file. - Restart the app or reload the VS Code window, then select a live model.
Model.sale exposes the standard Responses path at /v1/responses. The client must preserve the requested model ID and should show an error if that model is unavailable.
Verify with a minimal request
Run this from the same shell in which Codex will run. The example uses a small prompt to avoid spending more than necessary.
curl https://api.model.sale/v1/responses \
-H "Authorization: Bearer $MODEL_SALE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.6-luna","input":"Reply exactly: OK"}'| Check | Expected result |
|---|---|
| Status | 200 with a Responses JSON object. |
| Request ID | x-model-sale-request-id is present. Keep it when contacting support. |
| Usage | Input/output usage appears in the response or Usage page and the reservation is settled. |
| Balance | The wallet decreases by the displayed charge; unused reservation is released. |
Streaming
For streaming clients, set stream: true. Events are flushed as they arrive and the terminal usage event is needed for exact settlement.
Reasoning
Only request reasoning effort values shown by the current model capability. Unsupported values can be rejected before dispatch.
Limits
API-key RPM, TPM, concurrency and spend caps still apply. A request is never switched to a cheaper model to fit a limit.
Troubleshooting
| Symptom | What to check |
|---|---|
401 unauthorized | Confirm the variable is loaded in the client process, the key starts with ms_live_ and it was not revoked. Never print the full key to logs. |
402 or insufficient balance | Top up the wallet and check available versus temporarily reserved balance. The initial reservation is released after terminal usage. |
404 model not found | Refresh /v1/models and copy the exact live model ID. Do not append provider-specific aliases. |
429 rate or spend limit | Wait for the limit window, reduce parallel requests or update the key limits in the dashboard. |
| No model in the client | Restart Codex, verify wire_api = "responses", check the base URL has no duplicate /v1, and test the curl request first. |
| Stream stops early | Retry once, record the request ID and check Usage. A disconnect is not a reason to resend repeatedly; duplicate work can be charged separately. |
Rollback and key hygiene
To roll back, restore your saved ~/.codex/config.toml, remove ~/.config/model-sale/env, and remove the source line from your shell profile. Revoke the key from API Keys if the machine was shared or the secret may have been copied.
Model.sale stores request metadata needed for billing and operations, not your prompt or response body. Keep your own client logs equally careful: disable verbose request logging when it could include authorization headers or model content.
FAQ
Is this an OpenAI API key?
No. Use a Model.sale key and the Model.sale base URL. The Responses wire format is compatible with Codex clients, but the credential belongs to your Model.sale account.
Can I use any model name?
Use only IDs returned by /v1/models. The catalog changes as validation and availability change; unavailable models are not accepted for customer traffic.
Where can I see what I spent?
Open Usage after the request. It shows the endpoint, model, status, token usage, charge and request ID without storing prompt content.