Build with one endpoint.
GPTDev API speaks the OpenAI format. Codex CLI, Cursor, Cline, Continue and the official SDKs work by changing two settings: the base URL and the key. Both /v1/responses and /v1/chat/completions are supported, with streaming, tools, images and reasoning.
/v1. If a tool adds /v1 by itself it still works, we handle the double path.Running in three steps.
- 1
- 2Point your tool hereSet the base URL and key. Any OpenAI compatible tool or SDK reads them.
export OPENAI_BASE_URL="https://api.gptdevapi.com/v1" export OPENAI_API_KEY="sk-gd-your-key"
- 3Make a requestCall any model by its id. Codex CLI works with the config from Tool setup.
codex --model gpt-6.2-sol "explain this repo"
Authentication.
Every request needs your key. Send it as a Bearer token. The x-api-key header also works for tools that only support that.
Authorization: Bearer sk-gd-your-key
Each key can have its own model list, spend limit, requests per minute limit and expiry date. Edit these from the API keys page.
Tool setup.
Pick your tool. Replace sk-gd-your-key with your own key.
npm i -g @openai/codex, then add a provider to the config file. On Windows the file is %USERPROFILE%\.codex\config.toml. Run codex in any folder.model_provider = "gptdev" model = "gpt-6.2-sol" model_reasoning_effort = "medium" [model_providers.gptdev] name = "GPTDev API" base_url = "https://api.gptdevapi.com/v1" experimental_bearer_token = "sk-gd-your-key" wire_api = "responses" requires_openai_auth = false
experimental_bearer_token with env_key = "GPTDEV_API_KEY" and export that variable.Your first request.
Codex CLI uses the Responses API. Older tools use Chat Completions. Both are billed the same way.
curl https://api.gptdevapi.com/v1/responses \
-H "Authorization: Bearer $GPTDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol",
"input": "Refactor fetchUser to async/await"
}'RUN shows a sample response. It does not call the API or use your balance.
Main parameters
Streaming.
Set stream to true. Tokens arrive as server sent events, same format as OpenAI.
Responses API
event: response.created
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"async "}
...
event: response.completed
data: {"type":"response.completed","response":{"usage":{...}}}Chat Completions
Chunks end with data: [DONE]. To get token counts in the stream, send "stream_options": {"include_usage": true} and read the last chunk before DONE.
data: {"choices":[{"delta":{"content":"async "}}]}
data: {"choices":[{"delta":{"content":"function"}}]}
...
data: {"choices":[],"usage":{"prompt_tokens":1284,"completion_tokens":212}}
data: [DONE]Reasoning effort.
Models think before answering. Higher effort gives better answers on hard problems and uses more tokens.
{
"model": "gpt-6.2-sol",
"input": "Find the race condition in this file",
"reasoning": { "effort": "high" }
}In Codex CLI set model_reasoning_effort in config.toml, or switch with /model inside a session. Reasoning tokens show up in your usage log and are billed like other tokens.
Errors.
Errors use the OpenAI shape, so SDKs raise their usual exceptions. Check error.code to see what happened.
{
"error": {
"message": "Insufficient balance. Redeem a coupon at /dashboard/balance",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_balance"
}
}Retry 429, 502 and 503 with backoff. Do not retry 400, 401, 402, 403 or 404 without changing the request.
Rate limits.
Limits are counted per key, per minute. Your account also has a total across all keys.
Models.
Use these ids exactly. GET /v1/models returns the same list with context sizes.
Prices for each model are on the Models page.
Billing.
Simple: one price per model, per million tokens.
Common problems.
/v1, or has a typo. Copy it from the top of this page.requires_openai_auth = false and make sure model_provider = "gptdev" is at the top level of config.toml, above any [section].