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
| Parameter | Type | Required | Description |
|---|---|---|---|
model | String | Yes | The model ID, e.g. zai-org/GLM-5.3. |
input | String or Array | Yes | The prompt. A string, or an array of {role, content} message items for multi-turn. |
instructions | String | No | System instructions for the model. |
max_output_tokens | Integer | No | Maximum number of tokens to generate. |
temperature | Number | No | Sampling temperature (0.0-2.0). Defaults to 1.0. |
top_p | Number | No | Nucleus sampling parameter (0.0-1.0). Defaults to 1.0. |
stream | Boolean | No | Stream the response as SSE events. Defaults to false. |
reasoning | Object | No | Reasoning control, e.g. {"effort": "low"}. See Reasoning Models. |
tools | Array | No | Tool definitions. See Function Calling & Tools. |
tool_choice | String or Object | No | Tool choice strategy. |
store | Boolean | No | Accepted 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-bufferText 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
| Parameter | Type | Required | Description |
|---|---|---|---|
model | String | Yes | The model ID, e.g. zai-org/GLM-5.3. |
prompt | String or Array | Yes | The prompt(s) to complete. A string, an array of strings, or an array of token IDs. |
max_tokens | Integer | No | Maximum number of tokens to generate. Defaults to 16. |
temperature | Number | No | Sampling temperature (0.0-2.0). Defaults to 1.0. |
top_p | Number | No | Nucleus sampling parameter (0.0-1.0). Defaults to 1.0. |
n | Integer | No | Number of completions to generate. Defaults to 1. |
stream | Boolean | No | Stream the response as SSE chunks. Defaults to false. |
stop | String or Array | No | Stop sequences, as a string or array of strings. |
suffix | String | No | Text that follows the completion, for fill-in-the-middle style prompts. |
echo | Boolean | No | Echo the prompt back before the completion. Defaults to false. |
logprobs | Integer | No | Include log probabilities for the logprobs most likely tokens. |
presence_penalty | Number | No | Penalty for token presence (-2.0 to 2.0). Defaults to 0.0. |
frequency_penalty | Number | No | Penalty for token frequency (-2.0 to 2.0). Defaults to 0.0. |
seed | Integer | No | Random seed for reproducible outputs. |
user | String | No | Identifier 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.