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

# Responses

> The OpenAI Responses API shape, with the same automatic memory.

`POST /v1/responses` serves the OpenAI Responses API shape over the same memory wrapper
as [Chat](/api-reference/chat): relevant memories are recalled and injected before the
model runs, and the turn is stored back afterwards.

```python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="anona_live_YOUR_KEY",
    base_url="https://api.anonalabs.com/v1",
    default_headers={"X-Anona-Space-Id": "support-bot"},
)

resp = client.responses.create(
    model="gpt-4o-mini",
    instructions="Answer in one sentence.",
    input="What plan am I on?",
)
print(resp.output_text)
```

## Request

```bash theme={null}
POST https://api.anonalabs.com/v1/responses
Authorization: Bearer anona_live_...
Content-Type: application/json
```

```json theme={null}
{
  "model": "gpt-4o-mini",
  "space_id": "support-bot",
  "instructions": "Answer in one sentence.",
  "input": "What plan am I on?",
  "max_output_tokens": 512
}
```

| Field               | Type            | Default            | Description                                                                                                           |
| ------------------- | --------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------- |
| `input`             | string or array | required           | A string, or the array form `[{ "role": ..., "content": ... }]` where `content` is a string or a list of typed parts. |
| `instructions`      | string          | none               | Becomes the system prompt. The memory block is prepended to it.                                                       |
| `model`             | string          | deployment default | Optional. Omit to use whatever model this deployment serves.                                                          |
| `stream`            | boolean         | `false`            | Emit the typed Responses event stream.                                                                                |
| `max_output_tokens` | integer         | none               | Optional.                                                                                                             |
| `temperature`       | float           | none               | Optional.                                                                                                             |

All [memory tunables](/api-reference/chat#memory-tunables) apply here, in the body or as
`X-Anona-*` headers. Content parts without text (images, tool results) are skipped
when building the memory query.

## Response

```json theme={null}
{
  "id": "resp_...",
  "object": "response",
  "status": "completed",
  "model": "gpt-4o-mini",
  "output": [
    {
      "id": "msg_...",
      "type": "message",
      "status": "completed",
      "role": "assistant",
      "content": [{ "type": "output_text", "text": "You're on the Scale plan.", "annotations": [] }]
    }
  ],
  "output_text": "You're on the Scale plan.",
  "usage": { "input_tokens": 42, "output_tokens": 9, "total_tokens": 51 },
  "memories_injected": 3,
  "space_id": "support-bot"
}
```

`memories_injected` and `space_id` are the Anona additions, and also arrive as the
`X-Anona-Memories-Injected` and `X-Anona-Space-Id` response headers.

## Streaming

`"stream": true` emits the typed Responses event sequence, each event numbered with
`sequence_number`:

```
response.created
response.in_progress
response.output_item.added
response.content_part.added
response.output_text.delta      ← one per token
response.output_text.done
response.content_part.done
response.output_item.done
response.completed
```

```python theme={null}
with client.responses.stream(
    model="gpt-4o-mini",
    input="What plan am I on?",
) as stream:
    for event in stream:
        if event.type == "response.output_text.delta":
            print(event.delta, end="")
```

The final `response.completed` event carries the full response object, including token
usage. As on Chat, a failure before the first token is a normal JSON error with a real
status code; the turn is recorded and billed after the stream ends.
