Nebul Docs

Completions & Responses API

OpenAI-compatible text generation via the Responses endpoint, with reasoning and streaming, plus the legacy Completions endpoint

The Responses endpoint (POST /v1/responses) is the OpenAI Responses API: you send an input, you get back a response object with the model's answer, usage, and reasoning details. It works with any chat model in the Model Catalog and accepts the same sampling, tool, and reasoning parameters as Chat Completions, in the Responses request shape.

The full response arrives when the model finishes, or as an SSE stream with stream: true.

Request

POST https://api.inference.nebul.io/v1/responses

Parameters

ParameterTypeRequiredDescription
modelStringYesThe model ID, e.g. zai-org/GLM-5.3.
inputString or ArrayYesThe prompt. A string, or an array of {role, content} message items for multi-turn.
instructionsStringNoSystem instructions for the model.
max_output_tokensIntegerNoMaximum number of tokens to generate.
temperatureNumberNoSampling temperature (0.0-2.0). Defaults to 1.0.
top_pNumberNoNucleus sampling parameter (0.0-1.0). Defaults to 1.0.
streamBooleanNoStream the response as SSE events. Defaults to false.
reasoningObjectNoReasoning control, e.g. {"effort": "low"}. See Reasoning Models.
toolsArrayNoTool definitions. See Function Calling & Tools.
tool_choiceString or ObjectNoTool choice strategy.
storeBooleanNoAccepted for compatibility; responses are not retrievable.

The full parameter list is in the API Reference.

Example

import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NEBUL_API_KEY"],
    base_url="https://api.inference.nebul.io/v1",
)

response = client.responses.create(
    model="zai-org/GLM-5.3",
    input="Explain quantum computing in one sentence.",
)

print(response.output_text)

For multi-turn conversations, pass the history as input items and send it with every request; OpenAI's previous_response_id continuation isn't supported, so the full history travels with each call:

{
  "model": "zai-org/GLM-5.3",
  "input": [
    { "role": "user", "content": "Say OK" },
    { "role": "assistant", "content": "OK" },
    { "role": "user", "content": "What did I say?" }
  ]
}

Response

The endpoint is synchronous: the full response arrives when the model finishes. The output array holds typed items; the answer text is in output_text content parts of message items:

{
  "id": "resp_2e52190379f64e51beb38f70b55f01c3",
  "object": "response",
  "created_at": 1791273014,
  "status": "completed",
  "model": "zai-org/GLM-5.3",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        { "type": "output_text", "text": "Quantum computing uses..." }
      ]
    }
  ],
  "usage": {
    "input_tokens": 69,
    "output_tokens": 24,
    "output_tokens_details": { "reasoning_tokens": 19 },
    "total_tokens": 93
  }
}

Usage is reported as input_tokens and output_tokens (not the Chat Completions prompt_tokens / completion_tokens naming), with cached_tokens and reasoning_tokens in the details objects. Read the answer with response.output_text in the SDKs, or by concatenating the output_text parts.

Reasoning

Reasoning models expose their effort through the reasoning object, and report the spent reasoning tokens in usage:

{
  "model": "zai-org/GLM-5.3",
  "input": "Which is larger, 9.11 or 9.8?",
  "reasoning": { "effort": "low" }
}

Accepted effort values differ per model; see Reasoning Models for the per-family details and the Model Catalog for each model's accepted values.

Streaming

Set stream: true to receive the response as Server-Sent Events as it is generated. Events arrive as event: response.created, event: response.output_text.delta, and so on, each with a JSON payload:

curl https://api.inference.nebul.io/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NEBUL_API_KEY" \
  -d '{
    "model": "zai-org/GLM-5.3",
    "input": "Tell me a short story.",
    "stream": true
  }' \
  --no-buffer

Text deltas arrive as response.output_text.delta events; the stream ends with response.completed. With the OpenAI SDK, pass stream=True and iterate the events.

Legacy Completions endpoint

POST /v1/completions is the old text-in, text-out endpoint: it takes a raw prompt and returns plain completion text instead of messages. It still works, and some libraries and older integrations expect it, but new code should use Chat Completions or the Responses endpoint above.

Parameters

ParameterTypeRequiredDescription
modelStringYesThe model ID, e.g. zai-org/GLM-5.3.
promptString or ArrayYesThe prompt(s) to complete. A string, an array of strings, or an array of token IDs.
max_tokensIntegerNoMaximum number of tokens to generate. Defaults to 16.
temperatureNumberNoSampling temperature (0.0-2.0). Defaults to 1.0.
top_pNumberNoNucleus sampling parameter (0.0-1.0). Defaults to 1.0.
nIntegerNoNumber of completions to generate. Defaults to 1.
streamBooleanNoStream the response as SSE chunks. Defaults to false.
stopString or ArrayNoStop sequences, as a string or array of strings.
suffixStringNoText that follows the completion, for fill-in-the-middle style prompts.
echoBooleanNoEcho the prompt back before the completion. Defaults to false.
logprobsIntegerNoInclude log probabilities for the logprobs most likely tokens.
presence_penaltyNumberNoPenalty for token presence (-2.0 to 2.0). Defaults to 0.0.
frequency_penaltyNumberNoPenalty for token frequency (-2.0 to 2.0). Defaults to 0.0.
seedIntegerNoRandom seed for reproducible outputs.
userStringNoIdentifier for the end user.

Example

import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NEBUL_API_KEY"],
    base_url="https://api.inference.nebul.io/v1",
)

completion = client.completions.create(
    model="zai-org/GLM-5.3",
    prompt="The capital of France is",
    max_tokens=10,
    temperature=0,
)

print(completion.choices[0].text)

Response

{
  "id": "cmpl-fe731fda-7547-4f58-948c-96f59f0288cc",
  "object": "text_completion",
  "model": "zai-org/GLM-5.3",
  "choices": [
    {
      "text": " Paris.",
      "index": 0,
      "logprobs": null,
      "finish_reason": "length"
    }
  ],
  "usage": {
    "prompt_tokens": 5,
    "completion_tokens": 2,
    "total_tokens": 7
  }
}

With logprobs set, each choice carries the generated tokens, their log probabilities, and the top alternative tokens per position. With echo: true, the prompt is included at the start of text.

On this page