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.

Agentic harness support is experimental. The API is built for chat, reasoning, tool/function calls, and structured output. Full support for agentic coding harnesses — Cline, Cursor, and similar autonomous tool-loop agents — is still in progress and may be unreliable. We're working on it for a future release.

Base URL
https://api.lucidquery.com

Every endpoint lives under /v1.

SDK base_url
https://api.lucidquery.com/v1

The SDK appends /chat/completions itself.

Get your API key

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
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-swiftGeneral

Fast everyday work, high-volume apps, and lightweight agents.

300K ctx2.5015.00
lucidquery-agi-01-frontierFlagship

Deep reasoning, research, code review, and long multi-step tasks.

300K ctx4.5022.00

Additional specialized models are also reachable via GET /v1/models. The AGI 01 family above is recommended for general use.

Endpoint

Chat completions

POST/v1/chat/completions

Generate 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

modelrequired
string

The model id, e.g. lucidquery-agi-01-frontier.

messagesrequired
array

The conversation so far. Each item has a role (system, user, assistant, or tool) and content.

max_tokensoptional
integer

Maximum tokens to generate. Alias: max_completion_tokens. Defaults to the model's limit.

temperatureoptional
number

Sampling temperature. Higher values produce more varied output.

streamoptional
boolean

When true, partial deltas are sent as server-sent events and the stream ends with data: [DONE].

stream_optionsoptional
object

Streaming options. { "include_usage": true } appends a final chunk carrying token usage.

response_formatoptional
object

Set { "type": "json_object" } to force valid JSON output. See JSON mode below.

toolsoptional
array

Function/tool definitions the model may call, in the OpenAI tool-calling format.

tool_choiceoptional
string | object

Controls whether — and which — tool is called.

Example response

A non-streaming completion:

200 · application/json
{
  "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.

Python
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].

text/event-stream
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.

text/event-stream
# 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.

Python
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 answer

Responses

Response headers

Every API response carries an id and your current rate-limit standing.

x-request-id

Unique id for the request. Quote it when contacting support.

x-ratelimit-limit-requests

Your request allowance for the current minute.

x-ratelimit-remaining-requests

Requests left in the current minute.

x-ratelimit-limit-tokens

Your token allowance for the current minute.

x-ratelimit-remaining-tokens

Tokens left in the current minute.

Response headers
x-request-id: req_3f9a2c8b1d4e…
x-ratelimit-limit-requests: 100
x-ratelimit-remaining-requests: 99
x-ratelimit-limit-tokens: 1000000
x-ratelimit-remaining-tokens: 999985

Limits

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.

Requests / minute
100
Requests / day
2,000
Tokens / minute
1,000,000
Tokens / day
10,000,000

Errors

Errors

Errors use standard HTTP status codes and an OpenAI-shaped body: an error object with message, type, param, and code.

401 · application/json
{
  "error": {
    "message": "API key is required.",
    "type": "authentication_error",
    "param": null,
    "code": "unauthorized"
  }
}
400invalid_request_error

Malformed body or an unsupported parameter value.

401authentication_error

Missing or invalid API key.

402insufficient_quota

Not enough credits to serve the request.

429rate_limit_error

A per-key request or token rate limit was reached.

500 / 502server_error

An internal error, or the inference backend failed.

Endpoint

List models

GET/v1/models

Returns the catalog of available model ids in the OpenAI list format.

curl https://api.lucidquery.com/v1/models \
  -H "Authorization: Bearer $LUCIDQUERY_API_KEY"