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

# 创建响应

Response API 是 OpenAI 最先进的模型响应生成接口，支持文本和图像输入，输出文本内容。通过内置工具还可以扩展模型能力，包括文件搜索、网络搜索、计算机使用等功能，借助函数调用功能，还允许模型访问外部系统和数据。

### 文本消息

以下是最简单最基础的 Response API 请求示例：

<CodeGroup>
  ```bash curl theme={null}
  curl --location --request POST 'https://geekai.co/api/v1/responses' \
  --header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "model": "gpt-5-mini",
      "input": "你好"
  }'
  ```

  ```bash python theme={null}
  # 先安装 OpenAI SDK: `pip3 install openai`
  from openai import OpenAI
  client = OpenAI(api_key="$GEEKAI_API_KEY", base_url="https://geekai.co/api/v1")
  response = client.responses.create(
      model="gpt-5-mini",
      input="你好"
  )
  print(response)
  ```

  ```bash javascript theme={null}
  // 先安装 OpenAI SDK: `npm install openai`
  import OpenAI from "openai";
  const openai = new OpenAI({
      baseURL: 'https://geekai.co/api/v1',
      apiKey: '$GEEKAI_API_KEY'
  });
  async function main() {
      const response = await openai.responses.create({
          model: "gpt-5-mini",
          input: "你好"
      });
      console.log(response);
  }
  main();
  ```

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

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

  func main() {
  	requestBody := map[string]any{
  		"model": "gpt-5-mini",
  		"input": "你好", 
  	}
  	
  	jsonData, err := json.Marshal(requestBody)
  	if err != nil {
  		panic(err)
  	}

  	client := &http.Client{}
  	req, err := http.NewRequest("POST", "https://geekai.co/api/v1/responses", bytes.NewBuffer(jsonData))
  	if err != nil {
  		panic(err)
  	}

  	req.Header.Set("Authorization", "Bearer $GEEKAI_API_KEY")
  	req.Header.Set("Content-Type", "application/json")

  	resp, err := client.Do(req)
  	if err != nil {
  		panic(err)
  	}
  	defer resp.Body.Close()

  	body, err := io.ReadAll(resp.Body)
  	if err != nil {
  		panic(err)
  	}

  	fmt.Println(string(body))
  }
  ```
</CodeGroup>

如果以数组形式传入多条消息，对应示例如下：

<CodeGroup>
  ```bash single_text theme={null}
  curl --location --request POST 'https://geekai.co/api/v1/responses' \
  --header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "model": "gpt-5-mini",
      "input": [
  		{
  			"type": "message",
  			"role": "user",
  			"content": "你好"
  		}
  	]
  }'
  ```

  ```bash content_list theme={null}
  curl --location --request POST 'https://geekai.co/api/v1/responses' \
  --header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "model": "gpt-5-mini",
      "input": [
  		{
  			"type": "message",
  			"role": "user",
  			"content": [
  				{
  					"type": "input_text",
  					"text": "你好"
  				}
  			]
  		}
  	]
  }'
  ```
</CodeGroup>

和 Chat Completion API 不同的是，需要在 Response API 的 `role` 同一级中显式指定消息的 `type` 字段，一般为 `message`。

### 支持的模型

适用于所支持 Response API 的模型，目前支持 Response API 的模型是:

* `gpt-3.5-turbo`
* `gpt-4`
* `gpt-4-turbo`
* `gpt-4o-mini`
* `gpt-4o`
* `gpt-4.1`
* `gpt-4.1-mini`
* `gpt-4.1-nano`
* `gpt-5`
* `gpt-5-mini`
* `gpt-5-nano`
* `gpt-5-pro`
* `gpt-5-codex`
* `o1`
* `o1-pro`
* `o3-mini`
* `o3`
* `o3-pro`
* `o4-mini`
* `codex-mini-latest`
* `computer-use-preview`
* `o3-deep-research`
* `o4-mini-deep-research`

其中 `o3-pro`、`o3-deep-research`、`o4-mini-deep-research`、`gpt-5-pro` 目前仅支持通过 Response API 调用，其他模型既支持 Response API 也支持 Chat Completion API。
