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",
"content": [
{
"type": "output_text",
"text": "Hello! I'm doing well, thank you for asking."
}
]
}
],
"frequency_penalty": 0,
"presence_penalty": 0,
"temperature": 1.0,
"top_p": 1.0,
"usage": {
"input_tokens": 15,
"output_tokens": 12,
"total_tokens": 27
}
}
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",
"content": [
{
"type": "output_text",
"text": "Hello! I'm doing well, thank you for asking."
}
]
}
],
"frequency_penalty": 0,
"presence_penalty": 0,
"temperature": 1.0,
"top_p": 1.0,
"usage": {
"input_tokens": 15,
"output_tokens": 12,
"total_tokens": 27
}
}
Crea una risposta in streaming o non-streaming utilizzando il formato dell’API OpenAI Responses.
Autenticazione
string
obbligatorio
Token Bearer. Utilizza la tua chiave API come token Bearer nell’header Authorization.Format:
Bearer <SUNRA_KEY>Richiesta
Questo endpoint si aspetta un oggetto JSON.string
obbligatorio
Il modello da utilizzare per generare la risposta. Sfoglia i modelli disponibili su sunra.ai/models.
string | object[]
Input per la richiesta di risposta. Può essere una stringa o un array di elementi di input.
string
Istruzioni a livello di sistema per il modello. Equivalente a un messaggio di sistema.
boolean
predefinito:false
Se impostato su
true, la risposta verrà trasmessa in streaming utilizzando Server-Sent Events (SSE).integer
Il numero massimo di token di output da generare.
number
Temperatura di campionamento tra 0 e 2. Valori più alti aumentano la casualità.
number
Parametro di campionamento nucleus (0-1).
number
Numero tra -2.0 e 2.0. Penalizza i token in base alla loro frequenza esistente.
number
Numero tra -2.0 e 2.0. Penalizza i token in base alla loro presenza precedente.
boolean
predefinito:true
Se salvare la risposta generata per un recupero successivo.
Risposta
Oggetto risposta riuscito.string
Identificatore univoco della risposta.
string
Tipo di oggetto. Sempre
response.number
Timestamp Unix della creazione.
string
Lo stato della risposta. Può essere
completed, failed, in_progress o cancelled.string
Il modello utilizzato per la risposta.
object[]
Lista degli elementi di output generati dal modello.
object
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",
"content": [
{
"type": "output_text",
"text": "Hello! I'm doing well, thank you for asking."
}
]
}
],
"frequency_penalty": 0,
"presence_penalty": 0,
"temperature": 1.0,
"top_p": 1.0,
"usage": {
"input_tokens": 15,
"output_tokens": 12,
"total_tokens": 27
}
}
⌘I