# 创建 Model Response

使用兼容 OpenAI 的 Responses API 格式创建模型响应。

- 原文: https://www.unifyllm.com/zh/docs/api-reference/responses/
- 语言: zh-CN

## 接口

```http
POST https://api.unifyllm.top/v1/responses
```

认证与请求头以本页调用示例为准。 Content-Type: application/json

## 参数

| 参数 | 位置 | 类型 | 必填 | 说明 | 可选值 | 示例 |
| --- | --- | --- | --- | --- | --- | --- |
| model | body | string | 是 | 本次请求使用的模型标识符。 | gpt-5.5, qwen3.5-ocr |  |
| input | body | string \| array | 是 | 提供给模型的文本、消息、图像或文件输入。 |  |  |
| instructions | body | string | 否 | 加入模型上下文的系统或开发者指令。 |  | You are a helpful assistant. |
| max_output_tokens | body | number | 否 | 响应允许生成的最大 Token 数。 |  | 1024 |
| reasoning | body | object | 否 | 受支持模型使用的推理配置。 |  |  |
| stream | body | boolean | 否 | 是否在结果生成时以流式方式返回。 |  |  |
| temperature | body | number | 否 | 用于控制响应随机性的采样温度。 |  |  |

## 文本输入

```json
{
  "model": "gpt-5.5",
  "input": "Tell me a three sentence bedtime story about a unicorn."
}
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unifyllm.top/v1/responses' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-5.5",
  "input": "Tell me a three sentence bedtime story about a unicorn."
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "gpt-5.5",
    "input": "Tell me a three sentence bedtime story about a unicorn."
  }),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

response = requests.post(
    "https://api.unifyllm.top/v1/responses",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=json.loads("{\n  \"model\": \"gpt-5.5\",\n  \"input\": \"Tell me a three sentence bedtime story about a unicorn.\"\n}")
)
response.raise_for_status()
print(response.json())
```

## 图像输入

```json
{
  "model": "gpt-5.5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "what is in this image?"
        },
        {
          "type": "input_image",
          "image_url": "https://example.com/reference-image.jpg"
        }
      ]
    }
  ]
}
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unifyllm.top/v1/responses' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-5.5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "what is in this image?"
        },
        {
          "type": "input_image",
          "image_url": "https://example.com/reference-image.jpg"
        }
      ]
    }
  ]
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "gpt-5.5",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "what is in this image?"
          },
          {
            "type": "input_image",
            "image_url": "https://example.com/reference-image.jpg"
          }
        ]
      }
    ]
  }),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

response = requests.post(
    "https://api.unifyllm.top/v1/responses",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=json.loads("{\n  \"model\": \"gpt-5.5\",\n  \"input\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"input_text\",\n          \"text\": \"what is in this image?\"\n        },\n        {\n          \"type\": \"input_image\",\n          \"image_url\": \"https://example.com/reference-image.jpg\"\n        }\n      ]\n    }\n  ]\n}")
)
response.raise_for_status()
print(response.json())
```

## 流式响应

```json
{
  "model": "gpt-5.5",
  "instructions": "You are a helpful assistant.",
  "input": "Hello!",
  "stream": true
}
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unifyllm.top/v1/responses' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-5.5",
  "instructions": "You are a helpful assistant.",
  "input": "Hello!",
  "stream": true
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "gpt-5.5",
    "instructions": "You are a helpful assistant.",
    "input": "Hello!",
    "stream": true
  }),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

response = requests.post(
    "https://api.unifyllm.top/v1/responses",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=json.loads("{\n  \"model\": \"gpt-5.5\",\n  \"instructions\": \"You are a helpful assistant.\",\n  \"input\": \"Hello!\",\n  \"stream\": true\n}")
)
response.raise_for_status()
print(response.json())
```

## 函数调用

```json
{
  "model": "gpt-5.5",
  "input": "What is the weather like in Boston today?",
  "tools": [
    {
      "type": "function",
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": [
              "celsius",
              "fahrenheit"
            ]
          }
        },
        "required": [
          "location",
          "unit"
        ]
      }
    }
  ],
  "tool_choice": "auto"
}
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unifyllm.top/v1/responses' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-5.5",
  "input": "What is the weather like in Boston today?",
  "tools": [
    {
      "type": "function",
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": [
              "celsius",
              "fahrenheit"
            ]
          }
        },
        "required": [
          "location",
          "unit"
        ]
      }
    }
  ],
  "tool_choice": "auto"
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "gpt-5.5",
    "input": "What is the weather like in Boston today?",
    "tools": [
      {
        "type": "function",
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. San Francisco, CA"
            },
            "unit": {
              "type": "string",
              "enum": [
                "celsius",
                "fahrenheit"
              ]
            }
          },
          "required": [
            "location",
            "unit"
          ]
        }
      }
    ],
    "tool_choice": "auto"
  }),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

response = requests.post(
    "https://api.unifyllm.top/v1/responses",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=json.loads("{\n  \"model\": \"gpt-5.5\",\n  \"input\": \"What is the weather like in Boston today?\",\n  \"tools\": [\n    {\n      \"type\": \"function\",\n      \"name\": \"get_current_weather\",\n      \"description\": \"Get the current weather in a given location\",\n      \"parameters\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"location\": {\n            \"type\": \"string\",\n            \"description\": \"The city and state, e.g. San Francisco, CA\"\n          },\n          \"unit\": {\n            \"type\": \"string\",\n            \"enum\": [\n              \"celsius\",\n              \"fahrenheit\"\n            ]\n          }\n        },\n        \"required\": [\n          \"location\",\n          \"unit\"\n        ]\n      }\n    }\n  ],\n  \"tool_choice\": \"auto\"\n}")
)
response.raise_for_status()
print(response.json())
```

## 推理

```json
{
  "model": "gpt-5.5",
  "input": "How much wood would a woodchuck chuck?",
  "reasoning": {
    "effort": "high",
    "summary": "detailed"
  }
}
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unifyllm.top/v1/responses' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-5.5",
  "input": "How much wood would a woodchuck chuck?",
  "reasoning": {
    "effort": "high",
    "summary": "detailed"
  }
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "gpt-5.5",
    "input": "How much wood would a woodchuck chuck?",
    "reasoning": {
      "effort": "high",
      "summary": "detailed"
    }
  }),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

response = requests.post(
    "https://api.unifyllm.top/v1/responses",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=json.loads("{\n  \"model\": \"gpt-5.5\",\n  \"input\": \"How much wood would a woodchuck chuck?\",\n  \"reasoning\": {\n    \"effort\": \"high\",\n    \"summary\": \"detailed\"\n  }\n}")
)
response.raise_for_status()
print(response.json())
```

## Qwen OCR PDF

```json
{
  "model": "qwen3.5-ocr",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_file",
          "file_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260616/qmycjl/1506.02640v5.pdf"
        }
      ]
    }
  ],
  "max_output_tokens": 8192,
  "ocr_options": {
    "task": "document_parsing"
  }
}
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unifyllm.top/v1/responses' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "qwen3.5-ocr",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_file",
          "file_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260616/qmycjl/1506.02640v5.pdf"
        }
      ]
    }
  ],
  "max_output_tokens": 8192,
  "ocr_options": {
    "task": "document_parsing"
  }
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "qwen3.5-ocr",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_file",
            "file_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260616/qmycjl/1506.02640v5.pdf"
          }
        ]
      }
    ],
    "max_output_tokens": 8192,
    "ocr_options": {
      "task": "document_parsing"
    }
  }),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

response = requests.post(
    "https://api.unifyllm.top/v1/responses",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json=json.loads("{\n  \"model\": \"qwen3.5-ocr\",\n  \"input\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"input_file\",\n          \"file_url\": \"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260616/qmycjl/1506.02640v5.pdf\"\n        }\n      ]\n    }\n  ],\n  \"max_output_tokens\": 8192,\n  \"ocr_options\": {\n    \"task\": \"document_parsing\"\n  }\n}")
)
response.raise_for_status()
print(response.json())
```

## 响应示例

### 默认 — HTTP 200

```json
{
  "id": "resp_08eee34deb147259016a55e17d834c819a9aff22e251c367b0",
  "object": "response",
  "created_at": 1784013181,
  "status": "completed",
  "background": false,
  "completed_at": 1784013184,
  "error": null,
  "frequency_penalty": 0,
  "incomplete_details": null,
  "instructions": "You are a helpful assistant.",
  "max_output_tokens": null,
  "max_tool_calls": null,
  "model": "gpt-5.5",
  "moderation": null,
  "output": [
    {
      "id": "msg_08eee34deb147259016a55e17e12a8819a8efec3711f7575f4",
      "type": "message",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "logprobs": [],
          "text": "A gentle unicorn named Luma lived in a moonlit meadow where the flowers glowed softly at night.  \nEach evening, she sprinkled stardust from her silver horn to help lost fireflies find their way home.  \nWhen the sky filled with twinkling lights, Luma curled beneath a velvet tree and dreamed of rainbow clouds."
        }
      ],
      "phase": "final_answer",
      "role": "assistant"
    }
  ],
  "parallel_tool_calls": true,
  "presence_penalty": 0,
  "previous_response_id": null,
  "prompt_cache_key": "034b1177-b68a-4e30-b3cc-0d4e7f3eec74",
  "prompt_cache_retention": "24h",
  "reasoning": {
    "context": "current_turn",
    "effort": "medium",
    "mode": "standard",
    "summary": null
  },
  "safety_identifier": "user-9f6nlV797bodUQhVEfE26DER",
  "service_tier": "default",
  "store": false,
  "temperature": 1,
  "text": {
    "format": {
      "type": "text"
    },
    "verbosity": "medium"
  },
  "tool_choice": "auto",
  "tool_usage": {
    "image_gen": {
      "input_tokens": 0,
      "input_tokens_details": {
        "image_tokens": 0,
        "text_tokens": 0
      },
      "output_tokens": 0,
      "output_tokens_details": {
        "image_tokens": 0,
        "text_tokens": 0
      },
      "total_tokens": 0
    },
    "web_search": {
      "num_requests": 0
    }
  },
  "tools": [],
  "top_logprobs": 0,
  "top_p": 0.98,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 27,
    "input_tokens_details": {
      "cache_write_tokens": 0,
      "cached_tokens": 0
    },
    "output_tokens": 72,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 99
  },
  "user": null,
  "metadata": {}
}
```
