GPT API with live pricing, Chat Completions and the Responses API
Call GPT models through the OpenAI Chat Completions and Responses APIs with the official SDKs or Codex CLI, and reach Claude and Gemini on the same endpoint.
If your code, framework or app already calls OpenAI, it can call Lovely Router: set the base URL to https://lovelyrouter.com/v1 and use your Lovely Router key where the OpenAI API key went. GPT models are served over Chat Completions and the Responses API, the API Codex CLI uses. Every other text model, Claude and Gemini included, also answers Chat Completions, so one OpenAI-compatible client reaches all three vendors on one prepaid balance.
Hand it to your AI agent
Copy this prompt into Claude Code, Cursor, Codex or any coding agent. It tells the agent where the docs are and how to use your API key.
Integrate models from Lovely Router into this project through the OpenAI Chat Completions and Responses APIs. - Docs (read first): https://lovelyrouter.com/docs/models/openai.md - Use the official OpenAI SDK with base URL https://lovelyrouter.com/v1 (or set OPENAI_BASE_URL=https://lovelyrouter.com/v1). Endpoints: POST /v1/chat/completions and POST /v1/responses, unchanged from OpenAI. - GET https://lovelyrouter.com/v1/models lists every model id with its price; pick one there, do not guess ids. - Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys. - Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large. - Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt. My task: <describe what you want to build or get>
How it works
Get a key
Sign up, top up from $5 and create a key in API keys. The same key calls every model, the data tools and the browser agent.
Set two variables
The OpenAI SDKs, and most apps built on them, read
OPENAI_BASE_URLandOPENAI_API_KEY. Set them tohttps://lovelyrouter.com/v1and your key. If an app asks for an API host and appends/v1itself, enterhttps://lovelyrouter.com.Call a GPT model
The request body passes through unchanged, so OpenAI's API reference applies to every parameter.
Shellcurl https://lovelyrouter.com/v1/chat/completions \ -H "Authorization: Bearer $LOVELY_API_KEY" \ -H "content-type: application/json" \ -d '{ "model": "gpt-6.1-sol", "messages": [ {"role": "system", "content": "Answer in one sentence."}, {"role": "user", "content": "What does a load balancer do?"} ] }'
GPT API pricing, live
| Model | Context | Input | Output | Cache read |
|---|---|---|---|---|
| GPT-6 Astra gpt-6-astra | 1.05M | $10.00 | $50.00 | $1.00 |
| GPT-6.1 Sol gpt-6.1-sol | 1.05M | $2.00 | $10.00 | $0.10 |
| GPT-6 Sol gpt-6-sol | 1.05M | $2.00 | $10.00 | $0.20 |
| GPT-6.1 Terra gpt-6.1-terra | 1.05M | $1.00 | $5.00 | $0.05 |
| GPT-5.6 Sol gpt-5.6-sol | 400K | $2.00 | $10.00 | $0.20 |
| GPT-5.6 Terra gpt-5.6-terra | 400K | $2.00 | $12.00 | $0.20 |
| GPT-5.6 Luna gpt-5.6-luna | 400K | $0.20 | $1.20 | $0.02 |
USD per 1M tokens, live from the catalog.
Prices are in US dollars per million tokens, straight from the catalog. client.models.list() returns the same list with prices and needs no key. GPT models are served in the gpt-value channel group; the model marketplace shows live availability and status shows hour-by-hour availability per channel group.
One OpenAI-compatible API for three vendors
| Family | Example ids | Where vendor options work best |
|---|---|---|
| GPT | gpt-6.1-sol, gpt-6-astra, gpt-6.1-terra, gpt-5.6-terra, gpt-5.6-luna | Chat Completions or Responses, both native |
| Claude | claude-sonnet-5.5, claude-opus-5.5 | Anthropic Messages, for cache_control and thinking settings |
| Gemini | gemini-3.1-pro, gemini-3-flash | The Gemini API, for thinkingConfig |
Changing vendors is a change to the model field. A model called outside its native format is served by a channel that converts the request for it, so options that only one vendor defines are only certain to work in that vendor's own API. Image models answer the Images API: see image generation.
The Responses API and Codex CLI
GPT models are also served at POST /v1/responses, the API Codex CLI and the Agents SDK use. Same base URL, same key; client.responses.create() works as is. Add Lovely Router to Codex as a model provider:
model = "gpt-6.1-sol"
model_provider = "lovely"
[model_providers.lovely]
name = "Lovely Router"
base_url = "https://lovelyrouter.com/v1"
env_key = "LOVELY_API_KEY"
wire_api = "responses"Codex sends a prompt_cache_key for each session, so every turn of a session stays on the channel that holds its prompt cache. Two things to know about the Responses API here:
- Send the whole conversation. Responses are not stored:
GET,DELETEand cancel on/v1/responses/{id}return404, andprevious_response_idonly works while the conversation stays on one channel. Send the full history ininputwith"store": false, as Codex does. - GPT models only. Other models return
404withnot served in responses format; call them with Chat Completions or their own API.
Chat Completions details
The gateway adds stream_options.include_usage: true to every streaming request, so the last chunk before data: [DONE] has an empty choices array and the call's usage. Check that choices is non-empty before reading a delta.
tools, tool_choice, parallel_tool_calls and response_format pass through unchanged.
GPT-5 and GPT-6 models reason before they answer. Set reasoning_effort, and cap total output with max_completion_tokens, which includes reasoning tokens. The reasoning itself is not returned.
GPT models cache long prefixes automatically. usage.prompt_tokens_details.cached_tokens is billed at the cache-read price, and a stable prompt_cache_key per conversation raises the hit rate and keeps the conversation on one channel.
Not served: embeddings, audio, image variations, legacy Completions, Assistants, files, batches, fine-tuning and moderation. Those paths return 404.
Recipes
Change OPENAI_BASE_URL and OPENAI_API_KEY, restart, and check the first calls in Logs.
Use the config above, export LOVELY_API_KEY, and run codex. A key with a spend limit keeps a long session inside a budget.
Loop over gpt-6.1-sol, claude-sonnet-5.5 and gemini-3.1-pro with the same client and compare answers and usage.
The gateway already retries across channels, so a 429 or 502 means the problem outlasted several attempts. Set max_retries=5 on the client so the SDK retries 429 and 5xx a few more times with backoff.
client.images.generate() with gpt-image-2 works on the same client, at a flat price per image.
What you pay
GPT models are billed per token: uncached input, cached input at the cache-read price, and output with reasoning tokens included, each at the model's price per million tokens. GPT models have no separate cache-write charge. Every channel group bills at list price today, so each GPT model costs what OpenAI lists. The charge is computed from the usage the model reports and taken from your prepaid balance within seconds.
You top up once and spend across every product; there is no subscription. Requests rejected before they reach a model, and attempts the gateway retried elsewhere, are not charged. See pricing for everything else the key can buy.
Frequently asked questions
Is this an OpenAI-compatible API?+
Yes. Lovely Router serves Chat Completions, the Responses API and the Images API in OpenAI's format at https://lovelyrouter.com/v1. The official OpenAI SDKs work with only the base URL and key changed.
Does Codex CLI work with Lovely Router?+
Yes. Add Lovely Router as a model provider in ~/.codex/config.toml with wire_api = "responses" and a GPT model. Older configs with wire_api = "chat" must be changed, because current Codex versions no longer accept it.
Can I call Claude and Gemini with the OpenAI SDK?+
Yes. Every text model in GET /v1/models currently accepts Chat Completions. For Claude-only or Gemini-only options such as cache_control or thinkingConfig, use their native APIs with the same key.
Are embeddings or audio available?+
No. Embeddings, audio, image variations, Assistants, files, batches, fine-tuning and moderation return 404. Chat Completions, Responses and image generations and edits are served.
How are reasoning tokens billed?+
They are counted in usage.completion_tokens and billed at the output rate. max_completion_tokens caps output and reasoning together.
For every parameter and header, read the OpenAI guide. To see what failover does with a failing channel, read Rate limits & failover.