apyhub
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
http://localhost:8080/dosvak/chat-completions
QUICKSTARTGUIDE

Quickstart

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

curl -X POST "http://localhost:8080/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

ParameterTypeMandatoryDescription
modelStringNoModel name. Default: Qwen/Qwen3-0.6B.
top_pNumberNoNucleus sampling value. Must be between 0 and 1.
streamBooleanNoWhether to stream the response. Default: false.
messagesObject ArrayYesChat messages to send. Must contain at least 1 item. Each item requires role and content.
messages[].roleENUMYesMessage role. Allowed values: system, user, assistant, tool.
messages[].contentStringYesMessage content.
max_tokensIntegerNoMaximum number of tokens to generate. Default: 256. Must be between 1 and 8192.
temperatureNumberNoSampling 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.

ParameterTypeMandatoryDescription
idStringNoCompletion identifier.
modelStringNoModel used for the response.
usageObjectNoToken usage information. Contains total_tokens, prompt_tokens, and completion_tokens.
usage.total_tokensIntegerNoTotal tokens used.
usage.prompt_tokensIntegerNoPrompt tokens used.
usage.completion_tokensIntegerNoCompletion tokens used.
objectStringNoResponse object type.
choicesObject ArrayNoArray of completion choices.
choices[].indexIntegerNoChoice index.
choices[].messageObjectNoMessage returned for the choice. Contains role and content.
choices[].message.roleStringNoRole of the returned message.
choices[].message.contentStringNoReturned message content.
choices[].finish_reasonStringNoReason the generation stopped.
createdIntegerNoCreation timestamp.

Headers

Name
Type
Description
x-rapidapi-proxy-secretOPTIONAL
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.