curl -X POST https://api-llm.sunra.ai/v1/messages \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/messages",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/messages", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4-20250514",
max_tokens: 1024,
messages: [
{ role: "user", content: "Hello, how are you?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking."
}
],
"model": "anthropic/claude-sonnet-4-20250514",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 15,
"total_tokens": 27,
"sunra_usage_semantics": "anthropic.exclusive.v1"
}
}
LLM
Create a message
POST
/
v1
/
messages
curl -X POST https://api-llm.sunra.ai/v1/messages \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/messages",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/messages", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4-20250514",
max_tokens: 1024,
messages: [
{ role: "user", content: "Hello, how are you?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking."
}
],
"model": "anthropic/claude-sonnet-4-20250514",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 15,
"total_tokens": 27,
"sunra_usage_semantics": "anthropic.exclusive.v1"
}
}
Crea un messaggio utilizzando il formato dell’API Anthropic Messages. Supporta testo, immagini, PDF, strumenti e pensiero esteso.
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 il messaggio. Sfoglia i modelli disponibili su sunra.ai/models.
object[]
obbligatorio
integer
obbligatorio
Il numero massimo di token da generare prima dell’arresto.
string
Prompt di sistema. Fornisce istruzioni che il modello dovrebbe seguire.
boolean
predefinito:false
Se trasmettere la risposta in streaming utilizzando Server-Sent Events (SSE).
number
Quantità di casualità iniettata nella risposta. Varia da 0.0 a 1.0.
number
Parametro di campionamento nucleus. Utilizza un valore tra 0 e 1.
integer
Campiona solo dalle prime K opzioni per ogni token successivo. Utilizzato per rimuovere le risposte a bassa probabilità dalla “coda lunga”.
string[]
Sequenze di testo personalizzate che faranno smettere il modello di generare.
object
Un oggetto che descrive i metadati sulla richiesta.
Mostra proprietà
Mostra proprietà
string
Un identificatore esterno per l’utente associato alla richiesta.
Risposta
Risposta messaggio riuscita.string
Identificatore univoco del messaggio.
string
Tipo di oggetto. Sempre
message.string
Il ruolo del messaggio generato. Sempre
assistant.object[]
string
Il modello che ha gestito la richiesta.
string
Il motivo per cui il modello ha smesso di generare. Può essere
end_turn, max_tokens, stop_sequence o tool_use.string | null
La sequenza di arresto che ha causato l’interruzione del modello, se applicabile.
object
Statistiche di utilizzo dei token. I tre bucket di input sono mutuamente esclusivi — vedi Utilizzo dei token.
Mostra proprietà
Mostra proprietà
integer
Numero di token di input nuovi elaborati. Esclude entrambi i bucket di cache.
integer
Numero di token di output generati.
integer
Tutti i bucket di input più
output_tokens. Omesso nelle risposte in streaming.string | null
Presente come
anthropic.exclusive.v1 quando Sunra ha normalizzato questa risposta. Verifica questo valore invece di dedurre la convenzione dai numeri. Vedi Utilizzo dei token.curl -X POST https://api-llm.sunra.ai/v1/messages \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/messages",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/messages", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4-20250514",
max_tokens: 1024,
messages: [
{ role: "user", content: "Hello, how are you?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking."
}
],
"model": "anthropic/claude-sonnet-4-20250514",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 15,
"total_tokens": 27,
"sunra_usage_semantics": "anthropic.exclusive.v1"
}
}
⌘I