Skip to content

Chat Completions ​

Chat Communications is the most commonly used dialogue entry in the text series, suitable for chat client, assistant, workflow node and text generation scenes that require streaming output.

API Path ​

MethodologyPathReturns by
POST/v1/chat/completionssynchronous JSON or SSE streaming returned.

Example request ​

bash
curl https://moonnexai.com/v1/chat/completions \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-terra",
    "messages": [
      {
        "role": "system",
        "content": "你是一个简洁的开发者助手。"
      },
      {
        "role": "user",
        "content": "写一句 API 接入成功后的欢迎语。"
      }
    ]
  }'

Common field ​

fieldAnnotations
modelModel name. First, you can confirm the available model by Model Query.
messagesMulti-cycle dialogue news array.
temperatureControls the randomity of the output.
max_tokensLimit the length of generation.
streamUse SSE streaming to return when setting true.

Message Structure ​

rolePurpose
systemSet roles, tone and boundaries.
userUser input.
assistantHistoric assistant responded.

response Processing ​

sceneTreatment
Normal ReturnReads the generated text in response and saves the request model and track information.
streaming returnsAdds to the SSE event by paragraph, closes the connection after the event has arrived.
request failedChecks the model name, API Key permission, request body format and context length.

Access Recommendations ​

  • Chat client gives priority to this API, Base URL set to https://moonnexai.com/v1.
  • Please pass only the necessary context to avoid the inclusion of irrelevant history in request.
  • Set stream: true when you want to generate side displays and process incremental content by SSE events.

Relevant Pages ​