AI API: connecting and requests
How to connect to Lumean language and image models over the OpenAI and Anthropic protocols. Base URL, key, endpoints, streaming, limits and errors.
The AI API is an entry point to language and image models, separate from orders. It speaks the OpenAI and Anthropic protocols, so any client that works with OpenAI or Anthropic will do: SDKs, curl, Cursor, Claude Code, Codex CLI, opencode. You don't change the client code, only the base URL and the key.
Image generation is covered in AI API: images. Prices and spending are covered in AI API: prices and spending.
Base URL
| Client | Base URL |
|---|---|
| OpenAI SDK, curl, Cursor, Codex CLI, opencode, Continue, Cline | https://api.lumean.app/v1 |
| Anthropic SDK, Claude Code | https://api.lumean.app (no /v1) |
The Anthropic SDK and Claude Code append /v1/messages themselves. If you give them a URL with
/v1, the path is doubled and the request gets 404.
The AI API doesn't live under /api/public like orders do. It lives directly under /v1.
Key
Any API key from My API keys works, the same one you use for orders. The key's
permissions (orders.read and others) aren't checked here. The only requirement is that the "AI"
checkbox is on in the key settings. It's on for a new key. With the checkbox off, the request gets
401 not_a_gateway_key.
Send the key in one of these headers:
Authorization: Bearer <key>
x-api-key: <key>OpenAI clients send Authorization themselves, Anthropic clients send x-api-key.
In the key settings you can set a monthly AI spending limit. The calendar month is counted in UTC.
When spending reaches the limit, requests get 402 key_budget_exceeded until the next month
starts.
Payment
The AI API is paid only from the LUMC balance, at the model's price per token or per call.
Subscription tokens and quotas aren't spent here. If the balance runs short, the request gets 402
insufficient_quota. More in AI API: prices and spending.
Models
Pass the model name in the model field, for example gpt-image-2.5-sunburst or
claude-opus-5-5. The catalog with prices and descriptions is on the Models page.
From code, you can get the model list in two ways:
GET /v1/modelsis a list in the OpenAI shape: name, kind (chatorimage), context size and the response ceiling. It has no prices.GET /api/public/ai/modelsis the same list with current prices and model capabilities. It's described in the reference below.
Current AI model prices
Endpoints
| Method and path | What it does |
|---|---|
POST /v1/chat/completions | OpenAI-format chat. Supports streaming, tools (function calling), response_format and image input |
POST /v1/responses | OpenAI Responses format, used by Codex CLI |
POST /v1/messages | Anthropic Messages format, used by Claude Code and the Anthropic SDK |
POST /v1/messages/count_tokens | Estimates the number of input tokens. Free |
GET /v1/models, GET /v1/models/{id} | The model list, or one model |
POST /v1/images/generations | An image from a description |
POST /v1/images/edits | An image from a description and reference images |
Every response carries an X-Request-Id header. If you write to support about a specific request,
include it.
First request
curl https://api.lumean.app/v1/chat/completions \
-H "Authorization: Bearer $LUMEAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [{"role": "user", "content": "Hi! Tell me a joke."}]
}'The response is in the OpenAI shape, and token usage is in the usage field:
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "gpt-5.4",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "…"},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 14, "completion_tokens": 52, "total_tokens": 66}
}The model name in the example is for illustration. Use a model from the catalog.
Connecting apps and SDKs
Ready-made settings with your key are in your dashboard, in the AI connection section, and on each model's page. The same settings in general form:
OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(base_url="https://api.lumean.app/v1", api_key="LUMEAN_API_KEY")
reply = client.chat.completions.create(
model="<model>",
messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)OpenAI SDK (JavaScript)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.lumean.app/v1", apiKey: "LUMEAN_API_KEY" });Anthropic SDK (Python): the URL has no /v1:
from anthropic import Anthropic
client = Anthropic(base_url="https://api.lumean.app", api_key="LUMEAN_API_KEY")Claude Code: environment variables, the URL has no /v1:
export ANTHROPIC_BASE_URL=https://api.lumean.app
export ANTHROPIC_AUTH_TOKEN=<key>
export ANTHROPIC_MODEL=<model>
export ANTHROPIC_SMALL_FAST_MODEL=<model>Codex CLI: the ~/.codex/config.toml file:
model = "<model>"
model_provider = "lumean"
[model_providers.lumean]
name = "Lumean"
base_url = "https://api.lumean.app/v1"
env_key = "LUMEAN_API_KEY"
wire_api = "responses"opencode: the opencode.json file:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lumean": {
"npm": "@ai-sdk/openai-compatible",
"name": "Lumean",
"options": { "baseURL": "https://api.lumean.app/v1", "apiKey": "{env:LUMEAN_API_KEY}" },
"models": { "<model>": { "name": "<name>" } }
}
}
}Cursor: Settings → Models. Paste the key into the OpenAI API Key field, turn on Override OpenAI
Base URL and enter https://api.lumean.app/v1, then add the model name.
Continue: the config.yaml file:
models:
- name: Lumean
provider: openai
model: <model>
apiBase: https://api.lumean.app/v1
apiKey: <key>Cline and Roo Code: use the "OpenAI Compatible" provider. Set Base URL to
https://api.lumean.app/v1, then enter the key and the model name.
Streaming and long responses
With stream: true the response arrives in parts (SSE), as with OpenAI and Anthropic. An
OpenAI-format stream ends with the line data: [DONE].
If the model hasn't started responding within 20 seconds, the stream still opens: you get 200,
and then a : ping line every 15 seconds until the response appears. This is a service SSE comment.
Standard SDKs and EventSource skip it, and a hand-written stream parser must skip lines that
start with :.
An error after the stream has opened arrives as an event in the stream itself, without
data: [DONE]. The SDK will throw an exception, but it won't retry the request on its own.
Warning
Without streaming, the full response arrives only after the model finishes. If generation takes
longer than two minutes, an intermediate proxy on the api.lumean.net mirror may drop the
connection. Turn on stream: true for long responses.
Reasoning effort
The client sets how much the model reasons before answering, in the request body. The AI API passes this field to the provider unchanged.
| Format | Field | Values |
|---|---|---|
POST /v1/messages | "output_config": {"effort": "low"} | low, medium, high, xhigh, max |
POST /v1/responses | "reasoning": {"effort": "low"} | per the model's documentation |
POST /v1/chat/completions | "reasoning_effort": "low" | per the model's documentation |
Reasoning is paid as output tokens, so a high level costs noticeably more. For Claude models,
/v1/messages is more reliable: in /v1/chat/completions the field may get lost when the request
is translated to the provider's format.
What's not supported
- The provider's built-in tools that it bills separately: web search, page fetching, code
execution,
mcp_servers. In/v1/responsesand/v1/messagessuch a request gets400unsupported_tool. Regular tools (function calling) and the agents' client-side tools (bash,text_editor,computer,apply_patchand similar) work. - Response storage in
/v1/responses: responses aren't saved, soprevious_response_id,conversationandbackground: trueget400unsupported_parameter. Pass the whole conversation ininput. - Expensive service modes: in
/v1/responsesand/v1/messagesservice_tieraccepts onlyauto,default,flexandstandard_only. ngreater than 1 for images.- If a model doesn't work in the chosen format, the request gets
404endpoint_not_supported. Use/v1/chat/completionsthen.
Limits
| Limit | Value | Response |
|---|---|---|
| Requests per minute for one key | 300 | 429 rate_limit_exceeded and a Retry-After header |
| Concurrent requests for one key | limited | 429 concurrent_requests_limit_exceeded and a Retry-After header |
| Request body size | 32 MiB | 413 request_too_large |
| Model response without streaming | the response must start within 300 seconds | 502 upstream_timeout |
Errors
Errors come in the OpenAI shape:
{
"error": {
"message": "No API key provided. Send it as `Authorization: Bearer <key>` or `X-API-KEY: <key>`.",
"type": "authentication_error",
"param": null,
"code": "missing_api_key"
}
}On /v1/messages they come in the Anthropic shape: {"type": "error", "error": {"type": "…", "message": "…"}}.
| Code | code | Cause | What to do |
|---|---|---|---|
401 | missing_api_key | No key in the request | Send the key in Authorization: Bearer or x-api-key |
401 | unknown_key, key_inactive, key_expired | The key isn't found, is off or has expired | Check the key in My API keys |
401 | not_a_gateway_key | The "AI" checkbox is off for the key | Turn it on in the key settings |
402 | insufficient_quota | Not enough LUMC on the balance | Top up the balance |
402 | key_budget_exceeded | The key used up its monthly limit | Raise the key's limit or wait for the next month |
400 | invalid_request_body, missing_required_parameter | The request body is invalid or lacks a required field | Fix the request using the message text |
400 | unsupported_parameter, unsupported_tool | The parameter or tool isn't supported | See the "What's not supported" section |
400 | context_length_exceeded | The conversation doesn't fit the model's context | Shorten the conversation or pick a model with a bigger context |
404 | model_not_found, model_disabled | The model doesn't exist or is temporarily off | Pick another model from the catalog |
404 | endpoint_not_supported | The model doesn't work in this format | Use /v1/chat/completions |
413 | request_too_large | The body is larger than 32 MiB | Reduce the attachments |
429 | rate_limit_exceeded, concurrent_requests_limit_exceeded | The key's limit is exceeded | Wait Retry-After seconds |
429 | provider_keys_cooling | The model's provider has a temporary cap | Retry later or pick another model |
502 | upstream_timeout, upstream_error | The model's provider didn't respond or returned an error | Retry the request |
503 | gateway_at_capacity, catalog_unavailable, quota_check_unavailable | Temporary overload | Retry in a few seconds |
Errors that occur only with images are listed in AI API: images.
This page for AI
Updated 12/01/2026 · API version 1.0.0