> ## Documentation Index
> Fetch the complete documentation index at: https://docs.derestricted.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Responses

> Generate text using the stateless Responses request format.

This endpoint accepts Responses-style text input and returns Responses-style output. Every request must contain the context needed for that turn.

<ParamField header="Authorization" type="string" required>
  `Bearer` followed by your derestricted API key.
</ParamField>

<ParamField body="model" type="string" default="derestricted-llm">
  Use `derestricted-llm`.
</ParamField>

<ParamField body="input" type="string or array" required>
  A text prompt or an array of input/history items. Arrays are limited to 2,000
  items.
</ParamField>

<ParamField body="instructions" type="string">
  Optional instructions for the current request.
</ParamField>

<ParamField body="max_output_tokens" type="integer">
  Output allowance. The shared 65,536-token hard cap and credit reservation
  rules apply.
</ParamField>

<ParamField body="stream" type="boolean" default="false">
  Set to `true` for Responses SSE events.
</ParamField>

<ParamField body="tools" type="array">
  Client-provided tool definitions. Hosted OpenAI tools are not provided.
</ParamField>

## Example

<CodeGroup>
  ```bash cURL theme={"system"}
  curl https://api.derestricted.ai/v1/responses \
    -H "Authorization: Bearer $DERESTRICTED_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "derestricted-llm",
      "instructions": "Give a concise, practical answer.",
      "input": "How can I make an HTTP handler idempotent?",
      "max_output_tokens": 8192
    }'
  ```

  ```python Python theme={"system"}
  import os
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.derestricted.ai/v1",
      api_key=os.environ["DERESTRICTED_API_KEY"],
  )
  response = client.responses.create(
      model="derestricted-llm",
      input="How can I make an HTTP handler idempotent?",
      max_output_tokens=8192,
  )
  print(response.output_text)
  ```
</CodeGroup>

The JSON response contains `output` items and `usage`. SDK helpers such as `output_text` collect text from the output items. Check response status and incomplete/error information before treating the result as complete.

## Streaming

```javascript theme={"system"}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.derestricted.ai/v1",
  apiKey: process.env.DERESTRICTED_API_KEY,
});

const stream = await client.responses.create({
  model: "derestricted-llm",
  input: "Explain the purpose of a database transaction in one paragraph.",
  max_output_tokens: 8192,
  stream: true,
});

for await (const event of stream) {
  if (event.type === "response.output_text.delta") {
    process.stdout.write(event.delta);
  } else if (event.type === "response.failed" || event.type === "error") {
    console.error("Generation failed:", event);
  }
}
```

Clients should handle `response.completed`, `response.incomplete`, and `response.failed` terminal events, as well as `error` events and transport failures. Keepalive comments do not contain output.

## Conversation state and unsupported controls

`previous_response_id` is ignored. Send prior messages, function calls, and function outputs explicitly in `input`; a response ID does not let the server reconstruct a previous turn.

`store`, `background`, `include`, `reasoning`, `prompt_cache_key`, `prompt_cache_retention`, `truncation`, and `text.verbosity` are ignored. There are no response retrieval, deletion, background polling, or separate cancellation endpoints. To stop a stream, close its HTTP connection.

Web search, file search, code interpreter, image generation, and other provider-hosted tools are not offered. Tool definitions being accepted by the request parser does not guarantee that provider-specific or freeform tool types work with the deployed model. Prefer ordinary client-executed functions and validate model outputs. `text.format.type: "json_schema"` is rejected while structured output is disabled.
