> ## 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.

# Messages API

> Anthropic Messages-compatible API for all supported LLM models

The `/v1/messages` endpoint provides an **Anthropic Messages API-compatible** interface for text generation. Use the same request format as the Anthropic Messages 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 Message

**POST** `/v1/messages`

### Request

```bash theme={null}
curl -X POST https://api.unifically.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "anthropic/claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {"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="max_tokens" type="integer" required>
  Maximum number of tokens to generate before stopping.
</ParamField>

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

<ParamField body="system" type="string | array">
  System prompt providing context and instructions to the model.
</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 `1`.
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling parameter. Use either `temperature` or `top_p`, not both.
</ParamField>

<ParamField body="stop_sequences" type="array">
  Custom sequences that cause the model to stop generating.
</ParamField>

<ParamField body="tools" type="array">
  Definitions of tools the model may use. Each tool includes `name`, `description`, and `input_schema`.
</ParamField>

<ParamField body="tool_choice" type="object">
  Controls tool usage. Default: `{ "type": "auto" }`.
</ParamField>

### System Prompt Example

```bash theme={null}
curl -X POST https://api.unifically.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "openai/gpt-5.4",
    "max_tokens": 512,
    "system": "You are a helpful coding assistant. Be concise.",
    "messages": [
      {"role": "user", "content": "What is a closure in JavaScript?"}
    ]
  }'
```

### Response

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "msg_abc123",
    "type": "message",
    "role": "assistant",
    "model": "anthropic/claude-sonnet-4-6",
    "content": [
      {
        "type": "text",
        "text": "Quantum computing harnesses quantum mechanical phenomena..."
      }
    ],
    "stop_reason": "end_turn",
    "usage": {
      "input_tokens": 18,
      "output_tokens": 72
    }
  }
  ```
</ResponseExample>

### Streaming Response

When `stream: true`, the API returns `text/event-stream` with Anthropic-compatible event types (`message_start`, `content_block_delta`, `message_stop`, etc.):

```bash theme={null}
curl -X POST https://api.unifically.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "cursor/composer-2.5-fast",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'
```

***

## 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 the Anthropic SDK at Unifically by changing the base URL:

```python theme={null}
import anthropic

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

message = client.messages.create(
    model="anthropic/claude-opus-4-7",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}]
)
print(message.content[0].text)
```

```typescript theme={null}
import Anthropic from "@anthropic-ai/sdk";

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

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