Inference

Create chat completion

Sends a chat prompt to a model and returns a completion. Supports both streaming (server-sent events) and non-streaming response modes. Use the model field to target a base model by its model_name. Optional sampling parameters include temperature, top_p, top_k, max_tokens, presence_penalty, and repetition_penalty. Total tokens (prompt + completion) must not exceed the model's context window.

post/chat/completions

Request

  • Base URL: https://console.hyperstack.cloud/ai/api/v1
  • URL: https://console.hyperstack.cloud/ai/api/v1/chat/completions
  • Auth: API key in header api_key

Request body

modelstring required

Model identifier. Use the model_name from List base models for base models, or the model_name from List owned models for fine-tuned or imported models.

streamboolean

When true, returns the response as a stream of server-sent events, yielding tokens as they are generated. When false (default), waits for the full completion before returning.

stream_optionsobject

Options that control streaming behaviour, such as whether to include token usage in the final stream chunk.

max_tokensinteger

Maximum number of tokens to generate. Defaults to the model's maximum if omitted.

temperaturenumber

Sampling temperature controlling randomness. Lower values produce more deterministic output; higher values increase variety.

top_pnumber

Nucleus sampling threshold. Only tokens comprising the top top_p probability mass are considered. Set to null to disable.

top_kinteger

Limits sampling to the top_k most probable tokens at each step. Set to -1 to disable.

presence_penaltynumber

Penalizes tokens that have already appeared in the output, encouraging topic variety.

repetition_penaltynumber

Multiplier applied to the logit of previously generated tokens to reduce repetition. Values above 1.0 penalize repeats; values below 1.0 encourage them.

Example request

{
  "model": "Llama-3.3-70B-Instruct",
  "messages": [
    {
      "role": "user",
      "content": "Reply with exactly: OK"
    }
  ],
  "stream": false
}

Response

createdinteger

Unix timestamp of when the completion was created.

idstring

Unique identifier for this completion.

modelstring

Model that generated the completion.

objectstring

Always "chat.completion".

Example response

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "This is a minimalist, pixel-art style image depicting a serene sunset or sunrise over a mountain range.\n\nThe key elements are:\n\n*   **The Sky:** The background features a smooth gradient, transitioning from a deep purple at the top to a warm orange-pink near the horizon. This creates a calm, atmospheric effect.\n*   **The Sun:** A large, bright, off-white circle representing the sun is positioned just above the horizon, partially obscured by the mountains.\n*   **The Mountains:** Two simple, dark purple, triangular mountain silhouettes dominate the lower half of the image. They are rendered in a low-resolution, pixelated style, giving the scene a retro video game aesthetic.\n\nThe overall composition is balanced and tranquil, with the sun acting as a central focal point. The use of simple shapes and a limited color palette emphasizes the peacefulness of the scene.",
        "role": "assistant"
      }
    }
  ],
  "created": 1736932200,
  "id": "a1b2c3d4e5f6789012345678901234ab",
  "model": "qwen/qwen3-vl-8b-instruct",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 177,
    "prompt_tokens": 91,
    "total_tokens": 268
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.