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

# Create Responses Request (OpenAI)

> OpenAI's next-generation conversation interface, designed for reasoning models and advanced features

## Introduction

The Responses API is OpenAI's next-generation conversation interface, specifically designed for reasoning models (o-series, GPT-5 series) and advanced features. Compared to the traditional Chat Completions API, the Responses API provides more precise reasoning control, built-in tool support, and multimodal input capabilities.

## Use Cases

* Reasoning-intensive tasks: Using reasoning models like o1, o3-mini, o4-mini, GPT-5
* Web search requirements: Built-in Web Search Preview tool
* Advanced tool calls: Support for Function Call and Custom Tool Call
* Multi-turn conversation continuation: Conversation history management via `previous_response_id`

## Authentication

Bearer Token, e.g., `Bearer sk-xxxxxxxxxx`

## Request Parameters

<ParamField body="model" type="string" required>
  Model identifier, e.g., `gpt-5.5`, `o4-mini`, `o3-mini`
</ParamField>

<ParamField body="input" type="array" required>
  Input message list
</ParamField>

<ParamField body="max_output_tokens" type="integer">
  Maximum output tokens
</ParamField>

<ParamField body="stream" type="boolean">
  Enable streaming output
</ParamField>

<ParamField body="reasoning" type="object">
  Reasoning configuration, e.g., `{"effort": "high", "summary": "detailed"}`
</ParamField>

<ParamField body="tools" type="array">
  Tool list, supports Web Search and function calls
</ParamField>

<ParamField body="previous_response_id" type="string">
  Previous response ID for conversation continuation
</ParamField>

## Basic Examples

<Tabs>
  <Tab title="Simple Conversation (Non-streaming)">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "gpt-5.5",
        "max_output_tokens": 2048,
        "input": [
          {"role": "user", "content": "Briefly introduce artificial intelligence"}
        ]
      }'
    ```
  </Tab>

  <Tab title="Simple Conversation (Streaming)">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "gpt-5.5",
        "stream": true,
        "max_output_tokens": 2048,
        "input": [
          {"role": "user", "content": "Briefly introduce artificial intelligence"}
        ]
      }'
    ```
  </Tab>

  <Tab title="Python SDK">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        api_key="sk-xxxxxxxxxx",
        base_url="https://api.mixroute.ai/v1"
    )

    # Non-streaming call
    response = client.responses.create(
        model="gpt-5.5",
        max_output_tokens=2048,
        input=[
            {"role": "user", "content": "Briefly introduce artificial intelligence"}
        ]
    )

    print(response.output[0].content[0].text)

    # Streaming call
    stream = client.responses.create(
        model="gpt-5.5",
        stream=True,
        max_output_tokens=2048,
        input=[
            {"role": "user", "content": "Briefly introduce artificial intelligence"}
        ]
    )

    for event in stream:
        if event.type == "response.output_text.delta":
            print(event.delta, end="", flush=True)
    ```
  </Tab>
</Tabs>

## Advanced Features

### Web Search

<Tabs>
  <Tab title="Basic Example">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "gpt-5.5",
        "stream": true,
        "input": [
          {"role": "user", "content": "What are today'\''s news headlines?"}
        ],
        "tools": [
          {
            "type": "web_search_preview"
          }
        ]
      }'
    ```
  </Tab>

  <Tab title="Advanced Configuration">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "gpt-5.5",
        "stream": true,
        "input": [
          {"role": "user", "content": "Search for the latest AI research developments"}
        ],
        "tools": [
          {
            "type": "web_search_preview",
            "search_context_size": "high",
            "user_location": {
              "type": "approximate",
              "country": "US"
            }
          }
        ]
      }'
    ```

    **Configuration Options:**

    * `search_context_size`: Search context size, options: `low`, `medium`, `high`
    * `user_location`: User location, affects regional relevance of search results
  </Tab>
</Tabs>

### Reasoning Control

<Tabs>
  <Tab title="Auto Reasoning Summary">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "o4-mini",
        "stream": true,
        "reasoning": {
          "effort": "medium",
          "summary": "auto"
        },
        "max_output_tokens": 4096,
        "input": [
          {"role": "user", "content": "Calculate the sum of 1+2+3+...+100"}
        ]
      }'
    ```

    **Note:** `summary: "auto"` automatically generates a reasoning summary, suitable for quick results.
  </Tab>

  <Tab title="Detailed Reasoning Process">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "o4-mini",
        "stream": true,
        "reasoning": {
          "effort": "high",
          "summary": "detailed"
        },
        "max_output_tokens": 8192,
        "input": [
          {"role": "user", "content": "Prove that the square root of 2 is irrational"}
        ]
      }'
    ```

    **Reasoning Configuration Parameters:**

    * `effort`: Reasoning intensity, options: `low`, `medium`, `high`
    * `summary`: Summary mode, options: `auto`, `concise`, `detailed`
  </Tab>
</Tabs>

### Custom Function Calls

```bash theme={null}
curl -X POST "https://api.mixroute.ai/v1/responses" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -d '{
    "model": "gpt-5.5",
    "input": [
      {"role": "user", "content": "What'\''s the weather like in New York today?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get weather information for a specified city",
          "parameters": {
            "type": "object",
            "properties": {
              "city": {
                "type": "string",
                "description": "City name"
              },
              "unit": {
                "type": "string",
                "enum": ["celsius", "fahrenheit"],
                "description": "Temperature unit"
              }
            },
            "required": ["city"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'
```

### Multimodal Input

<Tabs>
  <Tab title="Image Input">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "gpt-5.5",
        "input": [
          {
            "role": "user",
            "content": [
              {
                "type": "input_text",
                "text": "What'\''s in this image?"
              },
              {
                "type": "input_image",
                "image_url": "https://api.mixroute.ai/demo/sample-image.jpg"
              }
            ]
          }
        ]
      }'
    ```
  </Tab>

  <Tab title="File Input">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/responses" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -d '{
        "model": "gpt-5.5",
        "input": [
          {
            "role": "user",
            "content": [
              {
                "type": "input_text",
                "text": "Please summarize the main content of this document"
              },
              {
                "type": "input_file",
                "file_id": "file-xxxxxxxx"
              }
            ]
          }
        ]
      }'
    ```

    <Note>
      Before using file input, you need to upload the file via the Files API to obtain a `file_id`.
    </Note>
  </Tab>
</Tabs>

### Conversation Continuation

Use `previous_response_id` to maintain context across multi-turn conversations:

```bash theme={null}
# First conversation turn
curl -X POST "https://api.mixroute.ai/v1/responses" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -d '{
    "model": "gpt-5.5",
    "input": [
      {"role": "user", "content": "My name is John, please remember my name"}
    ]
  }'

# Response returns id: "resp_abc123"

# Second conversation turn (continuing context)
curl -X POST "https://api.mixroute.ai/v1/responses" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -d '{
    "model": "gpt-5.5",
    "previous_response_id": "resp_abc123",
    "input": [
      {"role": "user", "content": "What is my name?"}
    ]
  }'
```

## Response Format

<Tabs>
  <Tab title="Non-streaming Response">
    ```json theme={null}
    {
      "id": "resp_xxx",
      "object": "response",
      "created_at": 1709123456,
      "model": "gpt-5.5",
      "status": "completed",
      "output": [
        {
          "type": "message",
          "role": "assistant",
          "content": [
            {
              "type": "output_text",
              "text": "Artificial Intelligence (AI) is a branch of computer science..."
            }
          ]
        }
      ],
      "usage": {
        "input_tokens": 25,
        "output_tokens": 150,
        "total_tokens": 175
      }
    }
    ```
  </Tab>

  <Tab title="Streaming Response (SSE Events)">
    Streaming responses are returned in Server-Sent Events (SSE) format:

    ```text theme={null}
    event: response.created
    data: {"type":"response.created","response":{"id":"resp_xxx","status":"in_progress"}}

    event: response.output_item.added
    data: {"type":"response.output_item.added","output_index":0,"item":{"type":"message","role":"assistant"}}

    event: response.content_part.added
    data: {"type":"response.content_part.added","part":{"type":"output_text","text":""}}

    event: response.output_text.delta
    data: {"type":"response.output_text.delta","delta":"Artificial"}

    event: response.output_text.delta
    data: {"type":"response.output_text.delta","delta":" Intelligence"}

    event: response.output_text.delta
    data: {"type":"response.output_text.delta","delta":" is..."}

    event: response.output_text.done
    data: {"type":"response.output_text.done","text":"Artificial Intelligence is..."}

    event: response.completed
    data: {"type":"response.completed","response":{"id":"resp_xxx","status":"completed","usage":{"input_tokens":25,"output_tokens":150}}}
    ```

    **Common SSE Event Types:**

    | Event Type                   | Description          |
    | ---------------------------- | -------------------- |
    | `response.created`           | Response created     |
    | `response.output_text.delta` | Text delta output    |
    | `response.output_text.done`  | Text output complete |
    | `response.completed`         | Response completed   |
    | `response.failed`            | Response failed      |
  </Tab>
</Tabs>

## Comparison: Responses API vs Chat Completions API

| Feature                   | Responses API                        | Chat Completions API         |
| ------------------------- | ------------------------------------ | ---------------------------- |
| Reasoning Model Support   | ✅ Full support                       | ⚠️ Limited support           |
| Built-in Web Search       | ✅ Native support                     | ❌ Not supported              |
| Reasoning Control         | ✅ Fine-grained control               | ❌ Not supported              |
| Conversation Continuation | ✅ `previous_response_id`             | ❌ Manual management required |
| Multimodal Input          | ✅ Full support                       | ✅ Supported                  |
| Use Cases                 | Reasoning, search, advanced features | General conversation         |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.mixroute.ai/v1/responses \
    --header 'Authorization: Bearer sk-xxxxxxxxxx' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "gpt-5.5",
      "max_output_tokens": 2048,
      "input": [
        {"role": "user", "content": "Briefly introduce artificial intelligence"}
      ]
    }'
  ```

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

  client = OpenAI(
      api_key="sk-xxxxxxxxxx",
      base_url="https://api.mixroute.ai/v1"
  )

  response = client.responses.create(
      model="gpt-5.5",
      max_output_tokens=2048,
      input=[
          {"role": "user", "content": "Briefly introduce artificial intelligence"}
      ]
  )
  print(response.output[0].content[0].text)
  ```

  ```javascript JavaScript theme={null}
  const OpenAI = require('openai');

  const client = new OpenAI({
    apiKey: 'sk-xxxxxxxxxx',
    baseURL: 'https://api.mixroute.ai/v1'
  });

  const response = await client.responses.create({
    model: 'gpt-5.5',
    max_output_tokens: 2048,
    input: [
      { role: 'user', content: 'Briefly introduce artificial intelligence' }
    ]
  });
  console.log(response.output[0].content[0].text);
  ```

  ```php PHP theme={null}
  <?php
  $client = new GuzzleHttp\Client();
  $response = $client->post('https://api.mixroute.ai/v1/responses', [
      'headers' => [
          'Authorization' => 'Bearer sk-xxxxxxxxxx',
          'Content-Type' => 'application/json',
      ],
      'json' => [
          'model' => 'gpt-5.5',
          'max_output_tokens' => 2048,
          'input' => [
              ['role' => 'user', 'content' => 'Briefly introduce artificial intelligence']
          ]
      ]
  ]);
  echo $response->getBody();
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "net/http"
  )

  func main() {
      payload := map[string]interface{}{
          "model": "gpt-5.5",
          "max_output_tokens": 2048,
          "input": []map[string]string{
              {"role": "user", "content": "Briefly introduce artificial intelligence"},
          },
      }
      body, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", "https://api.mixroute.ai/v1/responses", bytes.NewBuffer(body))
      req.Header.Set("Authorization", "Bearer sk-xxxxxxxxxx")
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```

  ```java Java theme={null}
  import java.net.http.*;
  import java.net.URI;

  HttpClient client = HttpClient.newHttpClient();
  String json = """
      {
          "model": "gpt-5.5",
          "max_output_tokens": 2048,
          "input": [{"role": "user", "content": "Briefly introduce artificial intelligence"}]
      }
      """;
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.mixroute.ai/v1/responses"))
      .header("Authorization", "Bearer sk-xxxxxxxxxx")
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();
  HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
  System.out.println(response.body());
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'

  uri = URI('https://api.mixroute.ai/v1/responses')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = 'Bearer sk-xxxxxxxxxx'
  request['Content-Type'] = 'application/json'
  request.body = {
    model: 'gpt-5.5',
    max_output_tokens: 2048,
    input: [{ role: 'user', content: 'Briefly introduce artificial intelligence' }]
  }.to_json

  response = http.request(request)
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "resp_xxx",
    "object": "response",
    "created_at": 1768271369,
    "model": "gpt-5.5",
    "status": "completed",
    "output": [
      {
        "id": "msg_xxx",
        "type": "message",
        "status": "completed",
        "role": "assistant",
        "content": [
          {
            "type": "output_text",
            "text": "Artificial Intelligence (AI) is a branch of computer science...",
            "annotations": []
          }
        ]
      }
    ],
    "usage": {
      "input_tokens": 25,
      "output_tokens": 150,
      "total_tokens": 175
    }
  }
  ```
</ResponseExample>
