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

# POST /v1/responses — OpenAI Responses API format

> Create model responses using the OpenAI Responses format, which supports multi-turn context management, conversation compaction, and reasoning natively.

The `/v1/responses` endpoint implements OpenAI's Responses API format — a newer alternative to Chat Completions that was designed with multi-turn context management in mind. Rather than sending the full conversation history on every request, you can reference a previous response by ID and let the API manage context for you. Anyone relays these requests to whichever upstream channel supports the Responses format; not all models and channels support this endpoint, so verify that your configured channel handles it before using it in production.

## Endpoints

| Method | Path                    | Description                                    |
| ------ | ----------------------- | ---------------------------------------------- |
| `POST` | `/v1/responses`         | Create a model response                        |
| `POST` | `/v1/responses/compact` | Create a response with conversation compaction |

## Authentication

```
Authorization: Bearer YOUR_TOKEN
```

## Difference from Chat Completions

The Chat Completions format (`/v1/chat/completions`) requires you to send the complete conversation history on every request. The Responses format manages context server-side: you send a `previous_response_id` and the API retrieves the prior context automatically. The `/v1/responses/compact` variant additionally compacts the conversation history before processing, which reduces token usage for long conversations.

<Note>
  Not all upstream channels support the Responses format. If you receive a `503` error, the channel backing your model does not handle this endpoint. Use `/v1/chat/completions` as a fallback.
</Note>

## Request parameters

<ParamField body="model" type="string" required>
  The model identifier to use. Anyone routes the request to the configured upstream channel for this model.
</ParamField>

<ParamField body="input" type="string | object[]" required>
  The input for the model. Can be a plain string or an array of structured input parts with `type` fields (`input_text`, `input_image`, `input_file`).
</ParamField>

<ParamField body="instructions" type="string | object">
  System-level instructions for the model, equivalent to a `system` message in Chat Completions.
</ParamField>

<ParamField body="previous_response_id" type="string">
  The ID of a prior response. When set, the model uses the prior response's context as the conversation history, so you do not need to resend the full message list.
</ParamField>

<ParamField body="stream" type="boolean" default="false">
  When `true`, the response is returned as a stream of server-sent events.
</ParamField>

<ParamField body="stream_options" type="object">
  Options that apply only when `stream` is `true`.

  <Expandable title="stream_options properties">
    <ParamField body="stream_options.include_usage" type="boolean" default="false">
      When `true`, the final SSE chunk includes a `usage` field with token counts.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature between `0` and `2`.
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling probability mass between `0` and `1`.
</ParamField>

<ParamField body="max_output_tokens" type="integer">
  The maximum number of tokens the model may generate in the response.
</ParamField>

<ParamField body="reasoning" type="object">
  Controls reasoning behavior for models that support it.

  <Expandable title="reasoning properties">
    <ParamField body="reasoning.effort" type="string">
      Reasoning effort level: `"low"`, `"medium"`, or `"high"`.
    </ParamField>

    <ParamField body="reasoning.summary" type="string">
      Whether to include a summary of reasoning in the response.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="tools" type="object[]">
  Tools available to the model. Supports function tools and MCP-style tool configurations.
</ParamField>

<ParamField body="tool_choice" type="string | object" default="auto">
  Controls how the model selects tools. `"none"`, `"auto"`, `"required"`, or a specific function object.
</ParamField>

<ParamField body="truncation" type="string | object">
  Controls how the model handles context that exceeds its context window. Pass `"auto"` to let the model decide.
</ParamField>

<ParamField body="context_management" type="object">
  Advanced context management options, including compaction strategy settings for the `/v1/responses/compact` endpoint.
</ParamField>

<ParamField body="metadata" type="object">
  Key-value metadata to attach to the response. Values must be strings; maximum 16 pairs.
</ParamField>

<ParamField body="top_logprobs" type="integer">
  The number of most likely tokens to return at each position, with log probabilities. Between `0` and `20`.
</ParamField>

<ParamField body="max_tool_calls" type="integer">
  Maximum number of tool calls the model may make in a single response.
</ParamField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.anyone.ai/v1/responses \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.4",
      "input": "Summarize the concept of entropy in thermodynamics.",
      "instructions": "You are a physics professor. Keep explanations concise."
    }'
  ```

  ```python Python (openai SDK) theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_TOKEN",
      base_url="https://api.anyone.ai/v1",
  )

  response = client.responses.create(
      model="gpt-5.4",
      input="Summarize the concept of entropy in thermodynamics.",
      instructions="You are a physics professor. Keep explanations concise.",
  )

  print(response.output_text)
  ```

  ```javascript JavaScript (openai SDK) theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: "YOUR_TOKEN",
    baseURL: "https://api.anyone.ai/v1",
  });

  const response = await client.responses.create({
    model: "gpt-5.4",
    input: "Summarize the concept of entropy in thermodynamics.",
    instructions: "You are a physics professor. Keep explanations concise.",
  });

  console.log(response.output_text);
  ```
</CodeGroup>

**Multi-turn with `previous_response_id`:**

```bash cURL theme={null}
# First turn
curl https://api.anyone.ai/v1/responses \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": "What is the speed of light?"
  }'

# Second turn — reference the first response by its ID
curl https://api.anyone.ai/v1/responses \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": "How does that relate to Einstein'\''s theory of relativity?",
    "previous_response_id": "resp_abc123"
  }'
```

**Conversation compaction:**

```bash cURL theme={null}
curl https://api.anyone.ai/v1/responses/compact \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": "Continue our discussion.",
    "previous_response_id": "resp_abc123"
  }'
```

The `/v1/responses/compact` endpoint compacts the prior conversation context before generating the next response, reducing token usage for long multi-turn sessions.
