
Using OpenAI Codex with PayPerQ
Run OpenAI Codex — the CLI, IDE extension, and desktop app — with a pay-per-use PayPerQ API key instead of a ChatGPT subscription. Works with GPT models out of the box, and even Claude, Gemini, and GLM with one extra config line. Fully tested and verified.
What is Codex?
Codex is OpenAI's AI coding agent. It reads your codebase, writes and edits files, runs shell commands, executes tests, and iterates until the job is done — all from your terminal (codex), your IDE, or the Codex desktop app. It's OpenAI's answer to Claude Code, and it has become one of the most popular coding agents available.
Normally, Codex wants you to sign in with a ChatGPT Plus/Pro account ($20–$200/month) or plug in an OpenAI platform API key. But Codex also supports custom model providers — and PayPerQ is a drop-in one. That means you can run Codex on pure pay-per-use pricing: no subscription, no monthly commitment, topped up with a credit card or crypto.
We didn't just read the docs — we verified this end-to-end. Using Codex CLI v0.136.0 pointed at PayPerQ, Codex completed real agentic coding tasks: it read files, wrote new modules, ran the tests with node, and reported results — with streaming, reasoning, and token accounting all working normally. And not just with GPT models: with one extra config line (explained below), we ran the same agentic tasks with Claude Sonnet 5, Gemini 3 Flash, and GLM 5.2 inside Codex.
Why This Works (and Why It Didn't Use To)
In February 2026, Codex dropped support for the classic Chat Completions API. Custom providers now must speak the OpenAI Responses API (wire_api = "responses" is the only supported value). Most OpenAI-compatible gateways only offer /chat/completions, which forces users through translation proxies like LiteLLM.
PayPerQ serves the Responses API natively at https://api.ppq.ai/v1/responses — so Codex plugs in directly, with no proxy, no translation layer, and no extra software.
Step by Step Set Up
1. Install Codex
Using npm:
bashnpm install -g @openai/codex
Using brew (macOS):
bashbrew install --cask codex
2. Get Your PayPerQ API Key
Navigate to ppq.ai/api-docs and copy your API key. You'll need this to authenticate your requests.
3. Add PayPerQ to Your Codex Config
Open (or create) ~/.codex/config.toml and add:
tomlmodel = "gpt-5.3-codex" model_provider = "ppq" [model_providers.ppq] name = "PayPerQ" base_url = "https://api.ppq.ai/v1" env_key = "PPQ_API_KEY" wire_api = "responses"
That's the whole integration — six lines of provider config.
Already use Codex with a ChatGPT login? Put the PPQ setup in a profile instead, so you can switch on demand:
toml[profiles.ppq] model = "gpt-5.3-codex" model_provider = "ppq" [model_providers.ppq] name = "PayPerQ" base_url = "https://api.ppq.ai/v1" env_key = "PPQ_API_KEY" wire_api = "responses"Then launch with
codex --profile ppqwhen you want pay-per-use, and plaincodexfor your normal account.
4. Set Your API Key
Add your key to your shell environment (e.g. in ~/.zshrc or ~/.bashrc):
bashexport PPQ_API_KEY="sk-YOUR_API_KEY_HERE"
No codex login needed — with a custom provider and env_key, Codex skips the ChatGPT sign-in entirely.
5. Run Codex
bashcodex "explain this codebase to me"
Or run a hands-free task:
bashcodex exec --full-auto "add input validation to the API routes and run the tests"
6. Verify Your Setup
Ask Codex to do something small, then check your usage history at ppq.ai/account-activity — you'll see each Codex request with its exact cost.

What We Verified
We tested this integration against a live PayPerQ account before publishing:
- Full agentic loop — Codex created a
fib.jsmodule, ran it withnode, confirmed the test passed, and summarized the result. File edits, shell commands, and sandboxed execution all worked through PayPerQ. - Streaming and reasoning — responses stream token-by-token, and reasoning models report their thinking-token usage correctly.
- Multiple models — codex-tuned models (
gpt-5.3-codex), general GPT models (gpt-5.4-mini), and — with the one-line config tweak below —claude-sonnet-5,gemini-3-flash-preview, andglm-5.2all completed tool-calling tasks. - Real cost accounting — every request showed up in PayPerQ usage history with token counts and cost. The small tasks in our test session cost fractions of a cent each.
Which Models Can You Use?
PayPerQ carries the full OpenAI lineup, including the codex-tuned agentic models. Some good choices for Codex:
gpt-5.3-codex— the latest codex-tuned model, our recommended defaultopenai/gpt-5.2-codexandopenai/gpt-5.1-codex-max— earlier codex generationsopenai/gpt-5.1-codex-mini— budget option for lighter tasksgpt-5.6-sol,openai/gpt-5.5,openai/gpt-5.4— general flagship modelsclaude-sonnet-5,gemini-3-flash-preview,glm-5.2— yes, really — see the bonus section below
Switch models per-run with the -m flag:
bashcodex -m "openai/gpt-5.1-codex-mini" "fix the failing test"
To see the current list of every model on PayPerQ:
bashcurl https://api.ppq.ai/v1/models
Bonus: Run Claude, Gemini, and GLM Inside Codex
Here's something most guides get wrong: they'll tell you non-OpenAI models don't work in Codex. Out of the box, that's true — point Codex at Claude and you get this error:
textNo endpoints found that support the native `namespace` tool type.
The cause: Codex ships its experimental multi-agent tools as a namespace-type tool, a Responses API feature only OpenAI's own endpoint understands. Other model providers reject the whole request because of that one tool.
The fix turns out to be a single config line. Disable Codex's multi-agent feature and every other tool serializes as a standard function tool that any model can use:
tomlmodel = "claude-sonnet-5" model_provider = "ppq" [features] multi_agent = false [model_providers.ppq] name = "PayPerQ" base_url = "https://api.ppq.ai/v1" env_key = "PPQ_API_KEY" wire_api = "responses"
With that config we verified full agentic runs — file creation, shell commands, test execution — with:
claude-sonnet-5— Anthropic's latest Sonnetgemini-3-flash-preview— Google's fast multimodal modelglm-5.2— Z.ai's open-weight coding model
The only thing you give up is Codex's built-in multi-agent orchestration (spawning sub-agents), which is a niche feature. Everything else — the shell tool, file edits, web search — keeps working. You don't need the flag for OpenAI models, but it's harmless to leave on if you switch between models a lot.
Known Limitations
We believe in honest integration guides, so here is exactly where the edges are:
- Non-OpenAI models require
multi_agent = false. Without it, Claude/Gemini/GLM requests fail with thenamespacetool error described above. With it, you lose Codex's sub-agent spawning feature for those sessions. - Desktop app model switching. The Codex desktop app reads the same
~/.codex/config.toml, so the PayPerQ provider works there too — but the app's UI model picker currently doesn't let you change models for custom providers mid-session. Set your model in the config file (or use profiles). - No ChatGPT-specific features. Cloud tasks tied to a ChatGPT account (Codex Cloud) require OpenAI sign-in and aren't routed through custom providers. Everything local — the CLI, agentic runs, IDE usage — works.
If you'd rather use a coding agent designed around Claude from the start, see our guides for Claude Code, OpenCode, Cline, and Aider.
What is PayPerQ?

PayPerQ is a pay-per-query AI service that gives you instant access to hundreds of chat, image, video, and audio AI models in one place. Unlike traditional ChatGPT subscription that charges $20+ per month, PPQ users pay only for what they use—averaging just $4 a month.
Account registration optional. No monthly commitments. Privacy focused. Credit cards and all major cryptos accepted. Just top up with as little as 10 cents and start using premium AI immediately.
Why Use PayPerQ?
- Access hundreds of AI models from all major providers in one place
- Pay per use - no subscriptions, no wasted money on unused credits
- No registration required - start using AI in seconds
- Start small - top up with as little as 10 cents
- Privacy-first - conversational data stored locally by default
- Average cost: ~1 cent per query
Getting Started
- Visit ppq.ai
- Top up your balance (crypto or credit card, as little as 10 cents)
- Select your model and start chatting
No account creation needed—just fund and go.
Problems?
Please contact us through the customer communication chatbot in the bottom right or in our telegram channel!