跳转到主要内容
POST
/
v1
/
responses
curl -X POST https://api-llm.sunra.ai/v1/responses \
  -H "Authorization: Bearer <SUNRA_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "input": [
      {
        "type": "message",
        "role": "user",
        "content": "Hello, how are you?"
      }
    ]
  }'
{
  "id": "resp-abc123",
  "object": "response",
  "created_at": 1704067200,
  "status": "completed",
  "model": "openai/gpt-4o",
  "output": [
    {
      "type": "message",
      "id": "msg_abc123",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Hello! I'm doing well, thank you for asking. How can I help you today?",
          "annotations": []
        }
      ]
    }
  ],
  "temperature": 1.0,
  "top_p": 1.0,
  "max_output_tokens": null,
  "usage": {
    "input_tokens": 15,
    "output_tokens": 18,
    "total_tokens": 33,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens_details": {
      "reasoning_tokens": 0
    }
  },
  "error": null
}
使用 OpenAI Responses API 格式创建流式或非流式响应。

认证

Authorization
string
必填
Bearer 令牌。在 Authorization 请求头中使用您的 API 密钥作为 Bearer 令牌。格式:Bearer <SUNRA_KEY>

请求

此端点接受一个 JSON 对象。
model
string
必填
用于生成响应的模型 ID。在 sunra.ai/models 浏览可用模型。
input
string | object[]
响应请求的输入。可以是字符串或输入项数组。
instructions
string | null
在模型上下文的第一个项目中插入系统(或开发者)消息。与 input 一起使用时,指令会插入到输入的开头。
stream
boolean
默认值:false
如果设置为 true,将使用服务器发送事件(SSE)流式传输响应。
max_output_tokens
integer
输出令牌数的上限,包括可见输出令牌和推理令牌。
temperature
number
默认值:1
采样温度,介于 0 到 2 之间。较高的值增加随机性。
top_p
number
默认值:1
核采样参数。温度采样的替代方案。
frequency_penalty
number
默认值:0
介于 -2.0 和 2.0 之间的数字。正值会根据新令牌在文本中的现有频率进行惩罚。
presence_penalty
number
默认值:0
介于 -2.0 和 2.0 之间的数字。正值会根据新令牌是否已出现在文本中进行惩罚。
tools
object[]
模型可以调用的工具数组。
tool_choice
string | object
控制工具选择行为。支持的字符串值:noneautorequired。也可以指定特定函数。
parallel_tool_calls
boolean
默认值:true
是否允许模型并行运行工具调用。
text
object
文本响应格式的配置。
reasoning
object
推理输出的配置。
store
boolean
默认值:true
是否存储生成的响应以供后续检索。
metadata
object
可附加到响应的 16 个键值对集合。键为最长 64 个字符的字符串。值为最长 512 个字符的字符串。
user
string
代表您的最终用户的唯一标识符。最长 128 个字符。

响应

成功的响应对象。
id
string
唯一响应标识符。
object
string
对象类型。始终为 response
created_at
number
响应创建时的 Unix 时间戳(秒)。
status
string
响应的状态。可能的值:completedfailedin_progresscancelled
model
string
用于生成响应的模型。
output
object[]
模型生成的内容项数组。
usage
object
响应的令牌使用统计。
temperature
number
使用的采样温度。
top_p
number
使用的核采样值。
max_output_tokens
integer | null
使用的最大输出令牌数设置。
error
object | null
如果生成失败,则为错误对象。
curl -X POST https://api-llm.sunra.ai/v1/responses \
  -H "Authorization: Bearer <SUNRA_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "input": [
      {
        "type": "message",
        "role": "user",
        "content": "Hello, how are you?"
      }
    ]
  }'
{
  "id": "resp-abc123",
  "object": "response",
  "created_at": 1704067200,
  "status": "completed",
  "model": "openai/gpt-4o",
  "output": [
    {
      "type": "message",
      "id": "msg_abc123",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Hello! I'm doing well, thank you for asking. How can I help you today?",
          "annotations": []
        }
      ]
    }
  ],
  "temperature": 1.0,
  "top_p": 1.0,
  "max_output_tokens": null,
  "usage": {
    "input_tokens": 15,
    "output_tokens": 18,
    "total_tokens": 33,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens_details": {
      "reasoning_tokens": 0
    }
  },
  "error": null
}