apyhub
ARTIFICIAL INTELLIGENCE · SMART GENERATION

Advanced Chat Completion Generation API

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.

POST
Create chat completion
https://api.eu.apyhub.com/llmapi-gateway/chat-completions-api/v1/chat/completions

QUICKSTART

GUIDE

Quickstart

Create a small non-streaming chat completion through APYHub.

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

{
  "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
  }
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
tools
messages*
messages-1*

About this endpoint

What it does

Creates an OpenAI-compatible chat completion through LLMAPI's unified multi-provider gateway.

Request

AttributeTypeRequiredDescription
modelStringYesModel identifier, for example zaya1-8b, or another model listed in the LLMAPI dashboard.
messagesArrayYesConversation messages with role and content.
max_tokensIntegerNoMaximum number of generated tokens.
temperatureNumberNoSampling temperature.
streamBooleanNoSet to true for an event stream; use false in the APYHub playground.
toolsArrayNoOpenAI-compatible tool definitions.
response_formatObjectNoOptional structured-output configuration.
X-LLMAPI-RegionStringNoPreferred processing region.

Additional OpenAI-compatible request fields are forwarded to LLMAPI.

Response

For non-streaming requests, returns an OpenAI-compatible JSON object containing id, model, created, choices, and usage. Each choice contains an assistant message and a finish_reason. Usage includes token and cost accounting when available.

Errors

Authentication, model, validation, provider, and rate-limit errors are returned with their upstream HTTP status and structured error body.

Headers

Name
Type
Description
X-LLMAPI-RegionOPTIONAL
string

Body

Name
Type
Description
bodyREQUIRED
object
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.