跳轉到主要內容
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 令牌。Format: 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
}