# Chat completions API

The primary text-generation endpoint for IFM chat and reasoning models, fully compatible with the OpenAI Chat Completions API. New to the API? Follow the [Quickstart](https://docs.ifm.ai/docs/quickstart.md) to make your first call.

`POST https://api.ifm.ai/v1/chat/completions`

## Parameters

For quotas and failure handling, see [Limits](https://docs.ifm.ai/docs/limits.md) and [Errors](https://docs.ifm.ai/docs/errors.md).

| Parameter | Type | Status | Notes |
| --- | --- | --- | --- |
| model | string | Required | e.g. IFM/K2-Horizon-375B-A23B, IFM/Jais-3-MoVA-36B-A4B |
| messages | array | Required | system / user / assistant / tool roles. Text content only. |
| temperature | float | Supported | 0–2, default 0.7. Use ≤0.3 for agentic workloads. |
| top_p | float | Supported | 0–1, default 1. Prefer this or temperature, not both. |
| max_tokens | int | Supported | Cap on completion length. Defaults to remaining context. |
| stop | string \| array | Supported | Up to 4 stop sequences. |
| seed | int | Supported | Best-effort determinism for identical requests. |
| stream | bool | Supported | SSE streaming — see [Streaming](https://docs.ifm.ai/docs/streaming.md). |
| tools / tool_choice | array \| str | Supported | Standard OpenAI function schema — no changes needed. |
| frequency_penalty | float | Supported | Accepted for compatibility but has no effect. |
| logprobs | bool | Supported | Accepted for compatibility; not returned. |
| reasoning_effort | string | Extended | "low" · "medium" · "high", default "high". Per-family behavior differs — see [Reasoning](https://docs.ifm.ai/docs/reasoning.md). |
| response_format | object | Extended | { "type": "json_object" } for guaranteed JSON. K2 Horizon also accepts a json_schema for structured output. |

## Response

```
{
  "id": "chatcmpl-acd8436fe38e4520",
  "model": "IFM/K2-Horizon-375B-A23B",
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "\nHello! Is there anything I can help you with today?",
      "reasoning_content": "The user just says hello, with no request. Respond warmly and…",
      "reasoning": "The user just says hello, with no request. Respond warmly and…",
      "tool_calls": []
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 11,
    "completion_tokens": 214,
    "total_tokens": 225,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "completion_tokens_details": { "reasoning_tokens": 184 }
  }
}
```

_Last updated: September 2, 2026_
