apyhub
Back

Chat Completion with Qwen3.8 Flash 27B

What it does

Chat Completion generates a text response from a chat-style message list. Send a model and a messages array with one or more entries, each with a role of system, user, or assistant and a content string. You can also set stream to true for streamed output, and max_tokens to control the length of the reply.

Use Chat Completion when you need a conversational LLM endpoint for assistants, drafting, classification, or controlled text generation inside your app. The request format is simple and keeps the conversation history explicit, so you can build prompts from your own application state and send exactly the context you want the model to use.

The response schema is open-ended, so the exact payload depends on the model and runtime. In practice, you should treat the result as the completion object returned by the model call and parse it according to your integration requirements. This makes Chat Completion suitable for workflows where you want to route user input to an LLM and handle the generated text in your own code.

POST
Generate a Qwen text chat completion
https://api.eu.apyhub.com/flonno/chat-completion-with-qwen3-8-flash-27b/chat/completions

QUICKSTART

GUIDE

Quickstart

Create a chat completion with the required model and messages.

curl -X POST "https://api.eu.apyhub.com/flonno/chat-completion-with-qwen3-8-flash-27b/chat/completions" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-27b",
    "messages": [
      {
        "role": "user",
        "content": "Hello, how are you?"
      }
    ],
    "max_tokens": 256
  }'

What you'll get back

A JSON object. The generated text is in choices[0].message.content.

{
  "id": "chatcmpl-3e13a3a3f428b2a7",
  "object": "chat.completion",
  "created": 1791873923,
  "model": "qwen3.8-27b",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": "I'm doing well, thank you for asking! How are you doing today? Is there anything specific I can help you with?",
        "refusal": null,
        "role": "assistant"
      }
    }
  ],
  "usage": {
    "completion_tokens": 27,
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "prompt_tokens": 15,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "total_tokens": 42
  }
}
TRY ITLIVE · 1 ATOM
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

Generates a text chat completion from the messages you provide. You send a model name and an array of chat messages, and the endpoint returns the model's reply along with token usage.

Request Body

ParameterTypeMandatoryDescription
modelStringYesModel identifier to use for the completion, e.g. qwen3.8-27b.
messagesObject ArrayYesChat message list. Must contain at least 1 item.
messages[].roleENUMYesMessage role. Allowed values: system, user, assistant.
messages[].contentStringYesMessage text content.
max_tokensIntegerNoMaximum number of tokens to generate. Default: 128. Minimum: 1.
streamBooleanNoWhether to stream the response. Default: false.

Additional model-specific parameters are accepted and passed through to the model.

Response

Returns a JSON object. The reply text is in choices[0].message.content.

FieldTypeDescription
idStringUnique identifier for the completion.
objectStringObject type, always chat.completion.
createdIntegerUnix timestamp (seconds) when the completion was created.
modelStringModel that generated the completion.
choicesObject ArrayList of generated completions.
choices[].indexIntegerPosition of the choice in the list.
choices[].finish_reasonStringWhy generation stopped: stop (natural end) or length (hit max_tokens).
choices[].logprobsObjectLog probability data. null unless the model returns it.
choices[].message.roleStringAlways assistant.
choices[].message.contentStringThe generated text.
choices[].message.refusalStringRefusal message if the model declined to answer, otherwise null.
usage.prompt_tokensIntegerTokens in the input messages.
usage.completion_tokensIntegerTokens in the generated reply.
usage.total_tokensIntegerSum of prompt and completion tokens.
usage.completion_tokens_details.reasoning_tokensIntegerTokens used for internal reasoning, 0 for non-reasoning models.
usage.prompt_tokens_details.cached_tokensIntegerPrompt tokens served from cache.

The response may include extra fields depending on the model.

Notes

  • max_tokens defaults to 128, so longer replies are cut off with finish_reason: "length". Increase it for longer output.
  • Include earlier user and assistant turns in messages to keep conversation context. The endpoint does not store history between calls.
  • With stream: true, the reply is returned incrementally instead of as one JSON 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.