Skip to main content
POST
Chat Completions API
The /v1/chat/completions endpoint provides an OpenAI-compatible interface for text generation. Use the same request format as the OpenAI Chat Completions API: swap the base URL to https://api.unifically.com and pass any supported model ID in the model field.
Every LLM model works on this endpoint except Responses-only models such as xai/grok-4.20-multi-agent-0309, which you call through /v1/responses.

Create Chat Completion

POST /v1/chat/completions

Request

Request Parameters

string
required
Model identifier in provider/model-name format. See Available LLM Models.
array
required
Non-empty array of message objects with role and content (string or content parts array). Allowed roles: system, developer, user, assistant, tool, and function. An empty array or any other role returns a 400 invalid_request_error.
boolean
If true, the response is streamed using server-sent events. Default: false.
object
Streaming options. Set { "include_usage": true } to get a final chunk with token usage. Only used when stream is true.
number
Sampling temperature between 0 and 2. Higher values produce more random output.
integer
Maximum number of tokens to generate in the completion.
integer
Accepted as an alias for max_tokens. Caps the number of generated tokens.
string
How much the model reasons before answering. Accepted by models that support it; see each model’s page for the allowed values.
number
Nucleus sampling parameter. Alternative to temperature.
string | array
Up to four sequences where the model stops generating further tokens.
array
List of tools the model may call. Each tool requires a type and function definition.
string | object
Controls which (if any) tool is called. Options: none, auto, required, or a specific tool.
object
Set { "type": "json_object" } to enable JSON mode when supported by the model.

Response

Response Fields

string
The model ID you sent in the request, for example anthropic/claude-haiku-5-5.
string | null
The reply text. null when the reply contains only tool calls.
array
Tool calls the model wants you to run. Present only when the model calls a tool.
string
The model’s reasoning text, when the model returns it. See Reasoning.
string
Why the model stopped: stop (natural end or stop sequence), length (max_tokens reached), or tool_calls (the model called a tool).A non-streaming reply that was cut short because the provider failed part-way or your balance ran out also ends with length. The delivered tokens are billed.
object
Token counts: prompt_tokens, completion_tokens, total_tokens. May also include prompt_tokens_details.cached_tokens and completion_tokens_details.reasoning_tokens when the provider reports them.

Streaming Response

When stream: true, the API returns text/event-stream. Each data: line is an OpenAI chat.completion.chunk object, and the stream ends with data: [DONE]. To get token usage on a stream, set "stream_options": {"include_usage": true}. The last chunk before [DONE] then has an empty choices array and a usage object. Without stream_options, no usage chunk is sent (same as OpenAI).
Because the usage chunk has no choices, check chunk.choices before reading the delta:
If an error happens after the stream has started, the HTTP status stays 200 and the error arrives as a data: {"error": {...}} chunk. See Error Handling.

Tool Calls

Pass tools in the standard OpenAI tools / tool_choice format:
When the model calls a tool, message.tool_calls holds the calls, content is null if there is no text, and finish_reason is tool_calls:
Run the tool, then send its result back as a message with "role": "tool" and the matching tool_call_id. When streaming, tool calls arrive as delta.tool_calls fragments. Each fragment carries an index; join the function.arguments strings that share the same index to get the full call.

Reasoning

Models that support it accept reasoning_effort. The allowed values differ by model, so check the model’s page under LLM Models. When a model returns its reasoning text, it arrives as message.reasoning_content (or delta.reasoning_content when streaming), separate from content. DeepSeek, Kimi K3, and Cursor Composer models are examples that return it. Reasoning token counts, when reported, are in usage.completion_tokens_details.reasoning_tokens.
Claude models return only the final answer on this endpoint, without the thinking text. To get Claude’s thinking, use /v1/messages with the thinking parameter.

Supported Models

See individual model pages under LLM Models for details.

SDK Compatibility

Point any OpenAI SDK at Unifically by changing the base URL: