---
title: Advanced Chat Completion Generation API
slug: chat-completions-api
url: https://apyhub.com/llmapi-gateway/service/chat-completions-api
provider: LLMAPI
categories: [Artificial Intelligence, Smart Generation]
tags: [chat-completions, llm, conversational-ai, tool-calling, streaming, multimodal]
auth: api_key
version: 1.0.0
service_type: sync
endpoints: 1
atoms: 100
mcp: true
---

# Advanced Chat Completion Generation API

Create chat responses with tool calls, streaming, web search, and structured output. Returns choices plus token counts and per-request cost usage.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/llmapi-gateway/chat-completions-api/v1/chat/completions` | What it does Creates an OpenAI-compatible chat completion through LLMAPI's unified multi-provider g… | 100 |

## Endpoint reference

### Create chat completion

`POST https://api.eu.apyhub.com/llmapi-gateway/chat-completions-api/v1/chat/completions` · 100 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `n` | body | integer | no |  |
| `seed` | body | integer | no |  |
| `stop` | body | string | no |  |
| `model` | body | string | yes |  |
| `tools` | body | array of object | no |  |
| `top_p` | body | number | no |  |
| `stream` | body | boolean | no | Default: `false`. |
| `messages` | body | array of object | yes |  |
| `messages[].role` | body | string | yes |  |
| `messages[].content` | body | string | yes |  |
| `max_tokens` | body | integer | no |  |
| `temperature` | body | number | no |  |
| `tool_choice` | body | string | no |  |
| `presence_penalty` | body | number | no |  |
| `frequency_penalty` | body | number | no |  |
| `parallel_tool_calls` | body | boolean | no |  |
| `X-LLMAPI-Region` | header | string | no |  |

#### Quickstart

Create a small non-streaming chat completion through APYHub.

```bash
curl -X POST "https://api.eu.apyhub.com/llmapi-gateway/chat-completions-api/v1/chat/completions" \\
  -H "apy-token: $APY_TOKEN" \\
  -H "Content-Type: application/json" \\
  -d '{
    "model": "zaya1-8b",
    "messages": [
      {"role": "user", "content": "Reply with exactly: Hello from LLMAPI"}
    ],
    "max_tokens": 24,
    "stream": false
  }'
```

#### Response shape

```json
{
  "id": "chatcmpl_...",
  "model": "zaya1-8b",
  "choices": [
    {
      "message": {"role": "assistant", "content": "Hello from LLMAPI"},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
```

## About

## What it does
Chat Completions lets you create a model-driven chat response from a message list. Send a required `model` and `messages`, then tune generation with options like `temperature`, `top_p`, `max_tokens`, `stream`, `n`, `stop`, `seed`, and penalties for presence or frequency.

Use it when you need a single API surface for conversational AI, structured output, tool calling, or search-augmented responses. The request schema also supports `tools`, `tool_choice`, `parallel_tool_calls`, `web_search`, `plugins`, `response_format`, `guardrails`, and `image_config`, so you can adapt the same endpoint to text-only chats, JSON-shaped responses, or multimodal workflows that include images in messages.

The response includes an `id`, `model`, `created` timestamp, and a `choices` array. Each choice returns a `message` or streaming `delta` payload with fields such as `role`, `content`, `reasoning`, `tool_calls`, `annotations`, and `tool_call_id`, plus `finish_reason` for completion status.

You also get a `usage` object with token and cost breakdowns, including `prompt_tokens`, `completion_tokens`, `reasoning_tokens`, `cached_tokens`, and cost fields for input, output, reasoning, web search, audio input, cached input, and request total. That makes Chat Completions suitable for production systems that need both model output and accounting data.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/llmapi-gateway/service/chat-completions-api
