UnieAI Studio

API Compatibility

Use the OpenAI, Responses, and Anthropic-compatible Runtime endpoints and understand UnieAI extensions, streaming metadata, and upstream differences.

UnieAI Runtime exposes an OpenAI-compatible interface. Most OpenAI SDK and HTTP clients need only a different base URL, API key, and model slug. Compatibility depends on the implemented endpoint and the selected base model's upstream capabilities; it is not a guarantee of complete feature parity with every OpenAI API.

Basic configuration

ItemValue
Runtime Base URLhttps://your-runtime-domain/v1
AuthenticationAuthorization: Bearer YOUR_API_KEY
Model identifierBase-model or custom-model slug

An API key belongs to the personal or organization workspace where it was created and does not grant additional model access.

curl https://your-runtime-domain/v1/chat/completions \
  -H "Authorization: Bearer $UNIEAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-model-slug","messages":[{"role":"user","content":"Hello"}]}'

Public endpoints

EndpointCompatibility and purpose
GET /v1/modelsModels accessible to the key
POST /v1/chat/completionsOpenAI Chat Completions with streaming
POST /v1/responsesCommon Responses text, image, and function-tool structures translated to Chat Completions
POST /v1/messagesAnthropic Messages translation
POST /v1/embeddingsEmbeddings for models with embedding capability
POST /v1/audio/transcriptionsMultipart transcription for a capable model
POST /v1/audio/speechText-to-speech for a TTS-capable model
POST /v1/parserUnieAI document parsing
POST /v1/kb/searchUnieAI knowledge-base Hybrid Search
POST /v1/feedbackRating with optional custom-model memory creation
GET /healthRuntime liveness, outside the /v1 prefix

For some unimplemented POST /v1/* JSON or multipart endpoints, Runtime transparently forwards to the selected model's upstream. A valid key, a model, and a forwardable upstream connection are required.

Passthrough support and response shape belong to the upstream provider. Passthrough traffic currently bypasses Runtime wallet reservation and settlement. Do not treat it as a formally supported or metered UnieAI endpoint.

Chat Completions

ParameterMeaning
modelRequired model slug
messagesRequired OpenAI message array
streamUses SSE when true
temperatureRandomness; range and default depend on the upstream model
max_tokensMaximum output; Runtime also recognizes max_completion_tokens and max_output_tokens
top_pNucleus-sampling cumulative probability mass
top_kKeeps only the k most likely next tokens; not a native named OpenAI SDK argument
stopStop string or list; upstream support varies
tools / tool_choiceFunction calling, subject to model and upstream support

Non-standard fields can be accepted, ignored, or rejected upstream. Pass top_k through extra_body in the Python OpenAI SDK:

response = client.chat.completions.create(
    model="your-model-slug",
    messages=[{"role": "user", "content": "Propose three options"}],
    temperature=0.7,
    max_tokens=800,
    extra_body={"top_k": 40},
)

Qwen thinking

chat_template_kwargs.enable_thinking is specific to the Qwen base-model family. It applies to a Qwen base model and to a custom model built from a Qwen base model; family matching is case-insensitive.

{
  "model": "your-qwen-based-model",
  "messages": [{"role":"user","content":"Analyze this step by step"}],
  "chat_template_kwargs": {"enable_thinking": true}
}
  • true explicitly enables thinking.
  • false explicitly disables it.
  • An explicit request value takes precedence over the platform or custom-model default for that request.
  • A non-Qwen upstream can ignore or reject the field.

Streaming responses

stream: true uses text/event-stream. Standard text arrives in Chat Completions chunks and ends with data: [DONE].

A custom model can also emit UnieAI metadata chunks, including rag_metadata, rag_iteration_metadata, api_metadata, mcp_metadata, mysql_metadata, skills_metadata, memory_metadata, websearch_metadata, agent_metadata, and guardrail_metadata.

Text-only clients should ignore chunks without choices[].delta.content. Clients rendering citations, tool timelines, or guardrail decisions can parse the relevant metadata and should ignore unknown fields for forward compatibility.

Responses and Anthropic compatibility

Responses API

POST /v1/responses translates instructions, text and image input, function calls and outputs, temperature, top_p, and function tools. Responses built-in tool types without Chat Completions semantics, such as some web_search, local_shell, or custom tools, can be skipped.

Anthropic Messages

POST /v1/messages translates Anthropic messages, content blocks, tools, and tool choice into the internal Chat Completions flow. Stop reasons, usage, and streaming events are mapped back to Anthropic shapes, but provider-specific fields are not guaranteed to survive unchanged.

Response headers

HeaderMeaning
x-request-idRuntime request ID
x-unieai-billing-amount-centsSettled charge in cents
x-unieai-billing-amount-micro-usdSettled charge in micro-USD
x-unieai-balance-after-centsPost-settlement balance in cents
x-unieai-balance-after-micro-usdPost-settlement balance in micro-USD
x-unieai-billing-currencyBilling currency
x-unieai-guardrail-blockedtrue when blocked by guardrails
x-unieai-passthrough1 for an unimplemented endpoint forwarded upstream

Not every response has every header, particularly errors, unbilled flows, and output guardrail decisions made after streaming starts.

Errors and troubleshooting

{"error":{"code":"unauthorized","message":"Invalid API key","request_id":"req_abc123","details":{}}}
HTTP statusCommon cause
400Invalid request shape or parameter
401Missing, invalid, disabled, or expired key
402Insufficient available wallet balance
403The key's workspace cannot access the model or asset
404Unknown model slug or endpoint
429Key rate limit or period quota exhausted
500 / 502Runtime, dependency, or upstream failure

For Model not found, put the slug shown on the custom model's Overview in model, not its display name. Request logs are under Operate → Request logs.