> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unifically.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat Completions API

> OpenAI-compatible chat completions for all supported LLM models

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.

<Info>
  All [LLM models](/models/llm/overview) support this endpoint, including Cursor, OpenAI, and Anthropic models.
</Info>

## Create Chat Completion

**POST** `/v1/chat/completions`

### Request

```bash theme={null}
curl -X POST https://api.unifically.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "openai/gpt-5.4",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in one paragraph."}
    ]
  }'
```

### Request Parameters

<ParamField body="model" type="string" required>
  Model identifier in `provider/model-name` format. See [Available LLM Models](/models/llm/overview).
</ParamField>

<ParamField body="messages" type="array" required>
  Array of message objects with `role` (`system`, `user`, or `assistant`) and `content` (string or content parts array).
</ParamField>

<ParamField body="stream" type="boolean">
  If `true`, the response is streamed using server-sent events. Default: `false`.
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature between `0` and `2`. Higher values produce more random output.
</ParamField>

<ParamField body="max_tokens" type="integer">
  Maximum number of tokens to generate in the completion.
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling parameter. Alternative to temperature.
</ParamField>

<ParamField body="stop" type="string | array">
  Up to four sequences where the model stops generating further tokens.
</ParamField>

<ParamField body="tools" type="array">
  List of tools the model may call. Each tool requires a `type` and function definition.
</ParamField>

<ParamField body="tool_choice" type="string | object">
  Controls which (if any) tool is called. Options: `none`, `auto`, `required`, or a specific tool.
</ParamField>

<ParamField body="response_format" type="object">
  Set `{ "type": "json_object" }` to enable JSON mode when supported by the model.
</ParamField>

### Response

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "chatcmpl-abc123",
    "object": "chat.completion",
    "created": 1710000000,
    "model": "openai/gpt-5.4",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "Quantum computing uses quantum bits..."
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 28,
      "completion_tokens": 64,
      "total_tokens": 92
    }
  }
  ```
</ResponseExample>

### Streaming Response

When `stream: true`, the API returns `text/event-stream` chunks in OpenAI format:

```bash theme={null}
curl -X POST https://api.unifically.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4-6",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'
```

Each chunk is a `data:` line containing a partial completion object, ending with `data: [DONE]`.

***

## Supported Models

| Model                         | Provider  |
| ----------------------------- | --------- |
| `cursor/composer-2.5`         | Cursor    |
| `cursor/composer-2.5-fast`    | Cursor    |
| `openai/gpt-5.4-mini`         | OpenAI    |
| `openai/gpt-5.4-nano`         | OpenAI    |
| `openai/gpt-5.4`              | OpenAI    |
| `openai/gpt-5.5`              | OpenAI    |
| `anthropic/claude-sonnet-4-6` | Anthropic |
| `anthropic/claude-opus-4-6`   | Anthropic |
| `anthropic/claude-opus-4-7`   | Anthropic |
| `anthropic/claude-opus-4-8`   | Anthropic |

See individual model pages under [LLM Models](/models/llm/overview) for details.

***

## SDK Compatibility

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

```python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.unifically.com/v1"
)

response = client.chat.completions.create(
    model="openai/gpt-5.4",
    messages=[{"role": "user", "content": "Hello!"}]
)
```

```typescript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.UNIFICALLY_API_KEY,
  baseURL: "https://api.unifically.com/v1",
});

const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4-6",
  messages: [{ role: "user", content: "Hello!" }],
});
```
