APIQIKAPIQIK
Docs
Guides

Messages and Generation Parameters

Organize multi-turn messages and understand common parameters such as temperature, max_tokens, and stream.

Chat Completions represents a conversation as a chronological messages array. Each message has a role and content; longer histories usually consume more input tokens.

Message roles

RolePurposeExample
systemSet the assistant's identity, tone, boundaries, and output rules.“You are a product classifier that returns only JSON.”
userEnd-user questions, tasks, or supplied information.“Classify this review as positive or negative.”
assistantPrevious model replies for conversation continuity.Save and resend the previous model message.
toolResults returned after the application executes an external tool.A JSON string returned by a weather API.

Multi-turn conversation

{
  "model": "deepseek-chat",
  "messages": [
    {
      "role": "system",
      "content": "You are a technical support assistant. Provide actionable steps."
    },
    {
      "role": "user",
      "content": "My request returns 401. What should I check?"
    },
    {
      "role": "assistant",
      "content": "First check the Authorization header and whether the API key is valid."
    },
    {
      "role": "user",
      "content": "What format should the header use?"
    }
  ]
}

The API does not automatically remember previous requests. Your application stores relevant messages and resends them when multi-turn context is needed.

Common generation parameters

ParameterTypePurposeRecommendation
modelstringSelect the target model.Use the exact catalog identifier.
messagesarrayProvide the task and conversation context.Keep only relevant information.
temperaturenumberAdjust output randomness.Use lower values for factual extraction and higher values when appropriate for creative tasks.
max_tokensintegerLimit output tokens.Leave enough room for the answer while controlling cost and latency.
streambooleanEnable incremental output.Recommended for interactive products; handle disconnections.
toolsarrayDescribe external tools available to the model.Expose only tools needed for the current task.

Context management

  • Keep system instructions short and specific; avoid repeating the same rule in multiple places.
  • Summarize older messages in long conversations, retaining recent interactions and key facts.
  • For RAG, inject only relevant passages and clearly mark source boundaries.
  • Reserve output tokens: input plus expected output must fit the model's context window.
  • Do not assume every model supports identical parameters or roles.