Responses

Create a response

Creates a response using an OpenAI-compatible request body. Use model ids returned by GET /models.

This endpoint is a text-only subset. Send input as text or supported text messages, and optionally instructions. Read generated text from output[].content[] entries whose type is output_text.

Supported controls are max_output_tokens, temperature, top_p and stream. store must be false. Tools, image/file inputs, structured-output controls, previous_response_id and reasoning controls are not supported. Include history in each request; use Chat Completions when you need its additional controls.

With stream: true, consume named SSE events. Collect delta from response.output_text.delta. The terminal response is in response.completed, response.incomplete or response.failed; inspect its status, usage and error or incomplete details. The stream ends with data: [DONE]. A disconnected stream without a terminal event is not a successful completion.

Python: stream a Responses answer

Use Python 3.9+ and install requests (python -m pip install requests). Set TEXTCORTEX_API_KEY and TEXTCORTEX_MODEL in your environment; choose a model from GET /models. Save and run each example as a separate Python script. These calls use your account's funding. Network/read timeouts raise exceptions; there are no automatic retries. Already printed text is provisional until the completion checks pass. A read timeout is not an overall generation deadline.

import json
import os
import requests

headers = {"Authorization": f"Bearer {os.environ['TEXTCORTEX_API_KEY']}"}
model = os.environ["TEXTCORTEX_MODEL"]  # Choose an ID from GET /models.
base = "https://api.textcortex.com/v1"


def events(response):
    """Decode SSE frames, including comments and multiline data."""
    response.encoding = "utf-8"
    data = []
    for line in response.iter_lines(decode_unicode=True):
        if line == "":
            if data:
                yield "\n".join(data)
                data = []
        elif line.startswith("data:"):
            data.append(line[5:].removeprefix(" "))
    if data:
        raise RuntimeError("Stream ended inside an event")

payload = {"model": model, "input": "Explain an API in one sentence.",
           "store": False, "stream": True}
terminal = None
done = False
with requests.post(base + "/responses", headers=headers,
                   json=payload, stream=True, timeout=(10, 120)) as response:
    response.raise_for_status()
    for data in events(response):
        if data == "[DONE]":
            done = True
            break
        event = json.loads(data)
        event_type = event.get("type")
        if "error" in event or event_type == "error":
            raise RuntimeError(event)
        if event_type == "response.output_text.delta":
            print(event["delta"], end="", flush=True)
        elif event_type in ("response.completed", "response.incomplete", "response.failed"):
            terminal = event["response"]
            if event_type != "response.completed" or terminal.get("status") != "completed":
                raise RuntimeError(terminal.get("error") or terminal.get("incomplete_details") or terminal)
if not done or terminal is None:
    raise RuntimeError("Stream disconnected before successful completion")
print("\nUsage:", terminal.get("usage"))

The SSE event name is also present in JSON type. Text arrives in response.output_text.delta; final usage belongs to the terminal response. response.incomplete and response.failed are not successful completion.

post/responses

Request

  • Base URL
    https://api.textcortex.com/v1
  • Auth
    HTTP bearer

Request body

instructionsstring nullable
max_output_tokensinteger nullable
modelstring required

Model id returned by GET /models. A -thinking or -non-thinking id that names a variant of another model — claude-5-sonnet-thinking beside claude-5-sonnet, kimi-k2p7-code-non-thinking beside kimi-k2p7-code — is deprecated and is subject to deployment-specific compatibility settings. The announced sunset target was 2026-09-09; do not rely on these aliases being accepted. The reasoning-only minimax-m3-thinking model is the exception: it is the whole model rather than a variant of one, so it is not deprecated and has no base id to move to. Use the base model id. This endpoint has no reasoning control, so the model's default applies; use POST /chat/completions with reasoning_effort if you need to choose.

storefalse nullable

Set to false or omit. Stored responses are not supported by this endpoint.

streamboolean nullable
temperaturenumber nullable
top_pnumber nullable

Example request

{
  "model": "gpt-6-luna"
}

Response

Response object

created_atinteger required
idstring required
modelstring required
object'response' required
outputobject[] required
statusstring required

Changes

No recorded changes to this operation across all 13 revisions of this API.