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?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/responses",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "openai/gpt-4o",
"input": [
{
"type": "message",
"role": "user",
"content": "Hello, how are you?"
}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/responses", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-4o",
input: [
{
type: "message",
role: "user",
content: "Hello, how are you?"
}
]
})
});
const data = await response.json();
console.log(data);
{
"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
}
LLM
Create a response
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?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/responses",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "openai/gpt-4o",
"input": [
{
"type": "message",
"role": "user",
"content": "Hello, how are you?"
}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/responses", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-4o",
input: [
{
type: "message",
role: "user",
content: "Hello, how are you?"
}
]
})
});
const data = await response.json();
console.log(data);
{
"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 格式建立串流或非串流回應。
認證
string
必填
Bearer 令牌。在 Authorization 請求標頭中使用您的 API 金鑰作為 Bearer 令牌。Format:
Bearer <SUNRA_KEY>請求
此端點接受一個 JSON 物件。string
必填
用於生成回應的模型 ID。在 sunra.ai/models 瀏覽可用模型。
string | object[]
string | null
在模型上下文的第一個項目中插入系統(或開發者)訊息。與
input 一起使用時,指令會插入到輸入的開頭。boolean
預設值:false
如果設為
true,將使用伺服器傳送事件(SSE)串流傳輸回應。integer
輸出令牌數的上限,包括可見輸出令牌和推理令牌。
number
預設值:1
取樣溫度,介於 0 到 2 之間。較高的值增加隨機性。
number
預設值:1
核取樣參數。作為溫度取樣的替代方案。
number
預設值:0
介於 -2.0 和 2.0 之間的數字。正值會根據新令牌在文本中的現有頻率進行懲罰。
number
預設值:0
介於 -2.0 和 2.0 之間的數字。正值會根據新令牌是否已出現在文本中進行懲罰。
object[]
string | object
控制工具選擇行為。支援的字串值:
none、auto、required。也可以指定特定函式。boolean
預設值:true
是否允許模型並行執行工具呼叫。
object
boolean
預設值:true
是否儲存生成的回應以供後續檢索。
object
可附加到回應的 16 組鍵值對。鍵為最多 64 個字元的字串。值為最多 512 個字元的字串。
string
代表您終端使用者的唯一識別碼。最多 128 個字元。
回應
成功的回應物件。string
唯一回應識別碼。
string
物件類型。始終為
response。number
回應建立時的 Unix 時間戳(以秒為單位)。
string
回應的狀態。可能的值:
completed、failed、in_progress、cancelled。string
用於生成回應的模型。
object[]
object
number
使用的取樣溫度。
number
使用的核取樣值。
integer | null
使用的最大輸出令牌數設定。
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?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/responses",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "openai/gpt-4o",
"input": [
{
"type": "message",
"role": "user",
"content": "Hello, how are you?"
}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/responses", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-4o",
input: [
{
type: "message",
role: "user",
content: "Hello, how are you?"
}
]
})
});
const data = await response.json();
console.log(data);
{
"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
}
⌘I