apyhub
Back
▣ ARTIFICIAL INTELLIGENCE · SMART GENERATION

Chat Completion Generation API

What it does

Chat Completions lets you send a list of messages and get a model-generated assistant reply back in the same OpenAI-style format. It is built for conversational applications that need a structured response shape and familiar parameters like model, temperature, top_p, max_tokens, and stream.

Send one or more messages with a role and content, and the service returns a completion object with an id, model, created timestamp, usage counts, and a choices array. Each choice includes the generated message with its role and content, plus a finish_reason so you can handle truncation or completion states in your client logic.

Use Chat Completions when you need to add AI chat to support workflows, internal assistants, content drafting, or task-oriented agents. The response format is predictable, which makes it easier to log, store, and render in applications that already follow chat-style request and response patterns.

POST
OpenAI-style chat completions
https://api.eu.apyhub.com/dosvak/chat-completions

QUICKSTART

GUIDE

Quickstart

Send a single chat-completions request with one user message.

curl -X POST "https://api.eu.apyhub.com/dosvak/chat-completions" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }'

What you'll get back

Returns a JSON object with fields like id, model, object, created, usage, and choices. The choices array contains the assistant message, including message.role and message.content.

{
  "id": "chatcmpl-123",
  "model": "Qwen/Qwen3-0.6B",
  "object": "chat.completion",
  "created": 1710000000,
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 24,
    "total_tokens": 36
  },
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello!"
      },
      "finish_reason": "stop"
    }
  ]
}
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*
messages*
messages-1*

About this endpoint

What it does

Sends a chat-completions request using an OpenAI-style message array and returns a JSON object containing the generated completion metadata and choices. The request is sent in the body, and the response includes the completion id, model, usage, object, choices, and created fields.

Request Body

ParameterTypeDescription
modelStringModel name. Default: Qwen/Qwen3-0.6B.
top_pNumberNucleus sampling value. Must be between 0 and 1.
streamBooleanWhether to stream the response. Default: false.
messagesObject ArrayChat messages to send. Must contain at least 1 item. Each item requires role and content.
messages[].roleENUMMessage role. Allowed values: system, user, assistant, tool.
messages[].contentStringMessage content.
max_tokensIntegerMaximum number of tokens to generate. Default: 256. Must be between 1 and 8192.
temperatureNumberSampling temperature. Default: 0.7. Must be between 0 and 2.

Response

Returns a JSON object with id, model, usage, object, choices, and created fields. The usage field is an object containing total_tokens, prompt_tokens, and completion_tokens; choices is an array of objects, each with index, message, and finish_reason.

ParameterTypeDescription
idStringCompletion identifier.
modelStringModel used for the response.
usageObjectToken usage information. Contains total_tokens, prompt_tokens, and completion_tokens.
usage.total_tokensIntegerTotal tokens used.
usage.prompt_tokensIntegerPrompt tokens used.
usage.completion_tokensIntegerCompletion tokens used.
objectStringResponse object type.
choicesObject ArrayArray of completion choices.
choices[].indexIntegerChoice index.
choices[].messageObjectMessage returned for the choice. Contains role and content.
choices[].message.roleStringRole of the returned message.
choices[].message.contentStringReturned message content.
choices[].finish_reasonStringReason the generation stopped.
createdIntegerCreation timestamp.
▣ 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.