curl -X POST https://api-llm.sunra.ai/v1/chat/completions \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/chat/completions",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "openai/gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-4o",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "openai/gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
LLM
Create a chat completion
POST
/
v1
/
chat
/
completions
curl -X POST https://api-llm.sunra.ai/v1/chat/completions \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/chat/completions",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "openai/gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-4o",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "openai/gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
Sendet eine Anfrage für eine Modellantwort für die gegebene Chat-Konversation. Unterstützt sowohl Streaming- als auch Nicht-Streaming-Modi. Kompatibel mit dem OpenAI Chat Completions API-Format.
Authentifizierung
string
erforderlich
Bearer-Token. Verwenden Sie Ihren API-Schlüssel als Bearer-Token im Authorization-Header.Format:
Bearer <SUNRA_KEY>Anfrage
Dieser Endpunkt erwartet ein JSON-Objekt.string
erforderlich
Das Modell, das für die Vervollständigung verwendet werden soll. Verfügbare Modelle finden Sie unter sunra.ai/models.
object[]
erforderlich
boolean
Standard:false
Wenn auf
true gesetzt, werden partielle Nachrichtendeltas als Server-Sent Events (SSE) gesendet.integer
Die maximale Anzahl der zu generierenden Tokens in der Vervollständigung.
number
Sampling-Temperatur zwischen 0 und 2. Höhere Werte wie 0.8 machen die Ausgabe zufälliger, niedrigere Werte wie 0.2 machen sie fokussierter und deterministischer.
number
Nucleus-Sampling-Parameter (0-1). Eine Alternative zum Temperatur-Sampling, bei der das Modell die Tokens mit der top_p-Wahrscheinlichkeitsmasse berücksichtigt.
number
Zahl zwischen -2.0 und 2.0. Positive Werte bestrafen neue Tokens basierend auf ihrer bestehenden Häufigkeit im bisherigen Text und verringern die Wahrscheinlichkeit, dass das Modell dieselbe Zeile wörtlich wiederholt.
number
Zahl zwischen -2.0 und 2.0. Positive Werte bestrafen neue Tokens basierend darauf, ob sie im bisherigen Text vorkommen, und erhöhen die Wahrscheinlichkeit, dass das Modell über neue Themen spricht.
string | string[]
Bis zu 4 Sequenzen, bei denen die API die weitere Token-Generierung stoppt.
Antwort
Erfolgreiche Chat-Vervollständigungs-Antwort.string
Eindeutiger Vervollständigungs-Bezeichner.
string
Objekttyp. Immer
chat.completion.integer
Unix-Zeitstempel der Erstellung.
string
Das für die Vervollständigung verwendete Modell.
object[]
Liste der Vervollständigungsoptionen.
Anzeigen Eigenschaften
Anzeigen Eigenschaften
object
curl -X POST https://api-llm.sunra.ai/v1/chat/completions \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/chat/completions",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "openai/gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-4o",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" }
]
})
});
const data = await response.json();
console.log(data);
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "openai/gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
⌘I