API reference
The LucidQuery API
A single, OpenAI-compatible endpoint for every LucidQuery model. If you already use the OpenAI SDK, point the base URL at us and your existing code keeps working — streaming, tool calls, and JSON mode included.
Coding agentically? The API covers chat, reasoning, tool and function calls, and structured output. For maximal performance in agentic coding, run our models inside LucidCode, our terminal-native coding agent.
Explore LucidCodehttps://api.lucidquery.comEvery endpoint lives under /v1.
https://api.lucidquery.com/v1The SDK appends /chat/completions itself.
Auth
Authentication
Authenticate every request with a Bearer token in the Authorization header. Keys look like sk_lucidquery_… and are created in your dashboard. Keep them server-side — never ship a key in client code.
curl https://api.lucidquery.com/v1/chat/completions \
-H "Authorization: Bearer $LUCIDQUERY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "lucidquery-agi-01-swift", "messages": [{ "role": "user", "content": "Hi" }] }'A missing or invalid key returns 401 with an authentication_error.
Quickstart
Your first request
Install the OpenAI SDK, set the base URL and your key, then stream a completion.
from openai import OpenAI
client = OpenAI(
api_key="lq_live_...",
base_url="https://api.lucidquery.com/v1",
)
stream = client.chat.completions.create(
model="lucidquery-agi-01-frontier",
messages=[{"role": "user", "content": "Explain quantum error correction."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")Models
Models
The AGI 01 family covers general and flagship intelligence. Switch models with a single string; pricing is per million tokens, billed from your prepaid balance.
lucidquery-agi-01-swiftGeneralFast everyday work, high-volume apps, and lightweight agents.
300K ctx€2.50€15.00lucidquery-agi-01-frontierFlagshipDeep reasoning, research, code review, and long multi-step tasks.
300K ctx€4.50€22.00Additional specialized models are also reachable via GET /v1/models. The AGI 01 family above is recommended for general use.
Endpoint
Chat completions
/v1/chat/completionsGenerate a model response for a conversation. Returns a chat.completion object, or a stream of chat.completion.chunk events when stream is true.
Request body
modelrequiredThe model id, e.g. lucidquery-agi-01-frontier.
messagesrequiredThe conversation so far. Each item has a role (system, user, assistant, or tool) and content.
max_tokensoptionalMaximum tokens to generate. Alias: max_completion_tokens. Defaults to the model's limit.
temperatureoptionalSampling temperature. Higher values produce more varied output.
streamoptionalWhen true, partial deltas are sent as server-sent events and the stream ends with data: [DONE].
stream_optionsoptionalStreaming options. { "include_usage": true } appends a final chunk carrying token usage.
response_formatoptionalSet { "type": "json_object" } to force valid JSON output. See JSON mode below.
toolsoptionalFunction/tool definitions the model may call, in the OpenAI tool-calling format.
tool_choiceoptionalControls whether — and which — tool is called.
Example response
A non-streaming completion:
{
"id": "chatcmpl_8f0c2a…",
"object": "chat.completion",
"created": 1781214488,
"model": "lucidquery-agi-01-frontier",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Hello!" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 15, "completion_tokens": 3, "total_tokens": 18 }
}Structured output
JSON mode
Set response_format: { "type": "json_object" } to guarantee the model returns a single valid JSON object. Describe the shape you want in the prompt; for best results include an example of the target JSON.
The engine expects the word jsonsomewhere in the prompt. If it's missing, we add a minimal instruction for you automatically — so a bare json_object request still works.
from openai import OpenAI
client = OpenAI(
api_key="sk_lucidquery_...",
base_url="https://api.lucidquery.com/v1",
)
resp = client.chat.completions.create(
model="lucidquery-agi-01-swift",
messages=[
{"role": "system", "content": "Extract the city and country as JSON."},
{"role": "user", "content": "I live in Lyon, France."},
],
response_format={"type": "json_object"},
)
print(resp.choices[0].message.content)
# {"city": "Lyon", "country": "France"}Supported types: json_object and text.
Streaming
Streaming responses
With stream: true, tokens arrive as server-sent events. Each line is a chat.completion.chunk with a delta; the stream terminates with data: [DONE].
data: {"id":"chatcmpl_8f0c2a…","object":"chat.completion.chunk","created":1781214488,"model":"lucidquery-agi-01-frontier","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl_8f0c2a…","object":"chat.completion.chunk","created":1781214488,"model":"lucidquery-agi-01-frontier","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]By default no usage is sent (matching OpenAI). Opt in with stream_options: { "include_usage": true } to receive a final chunk whose choices is empty and whose usage is populated.
# with stream_options: { "include_usage": true }, a final chunk carries usage:
data: {"id":"chatcmpl_8f0c2a…","object":"chat.completion.chunk","model":"lucidquery-agi-01-frontier","choices":[],"usage":{"prompt_tokens":15,"completion_tokens":3,"total_tokens":18}}
data: [DONE]Extension
Reasoning
A LucidQuery extension: set thinking: trueto receive the model's reasoning trace alongside its answer (most useful with lucidquery-agi-01-frontier). The trace is returned as reasoning_content on the message. include_reasoning and reasoning: { "enabled": true } are accepted aliases.
resp = client.chat.completions.create(
model="lucidquery-agi-01-frontier",
messages=[{"role": "user", "content": "Prove that sqrt(2) is irrational."}],
extra_body={"thinking": True},
)
print(resp.choices[0].message.reasoning_content) # the model's reasoning
print(resp.choices[0].message.content) # the final answerResponses
Response headers
Every API response carries an id and your current rate-limit standing.
x-request-idUnique id for the request. Quote it when contacting support.
x-ratelimit-limit-requestsYour request allowance for the current minute.
x-ratelimit-remaining-requestsRequests left in the current minute.
x-ratelimit-limit-tokensYour token allowance for the current minute.
x-ratelimit-remaining-tokensTokens left in the current minute.
x-request-id: req_3f9a2c8b1d4e…
x-ratelimit-limit-requests: 100
x-ratelimit-remaining-requests: 99
x-ratelimit-limit-tokens: 1000000
x-ratelimit-remaining-tokens: 999985Limits
Rate limits
Limits are enforced per API key over rolling windows. Exceeding one returns 429 with a rate_limit_error. The defaults below apply to new keys.
Errors
Errors
Errors use standard HTTP status codes and an OpenAI-shaped body: an error object with message, type, param, and code.
{
"error": {
"message": "API key is required.",
"type": "authentication_error",
"param": null,
"code": "unauthorized"
}
}400invalid_request_errorMalformed body or an unsupported parameter value.
401authentication_errorMissing or invalid API key.
402insufficient_quotaNot enough credits to serve the request.
429rate_limit_errorA per-key request or token rate limit was reached.
500 / 502server_errorAn internal error, or the inference backend failed.
Endpoint
List models
/v1/modelsReturns the catalog of available model ids in the OpenAI list format.
curl https://api.lucidquery.com/v1/models \
-H "Authorization: Bearer $LUCIDQUERY_API_KEY"