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",
"logprobs": null
}
],
"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",
"logprobs": null
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
지정된 채팅 대화에 대한 모델 응답 요청을 보냅니다. 스트리밍 및 비스트리밍 모드를 모두 지원합니다. OpenAI Chat Completions API 형식과 호환됩니다.
인증
string
필수
Bearer 토큰. API 키를 Authorization 헤더의 Bearer 토큰으로 사용하세요.Format:
Bearer <SUNRA_KEY>요청
이 엔드포인트는 JSON 객체를 받습니다.object[]
필수
string
필수
완성에 사용할 모델. 사용 가능한 모델은 sunra.ai/models에서 확인하세요.
boolean
기본값:false
true로 설정하면 부분 메시지 델타가 서버 전송 이벤트(SSE)로 전송됩니다.integer
완성에서 생성할 최대 토큰 수. 입력 토큰과 생성된 토큰의 총 길이는 모델의 컨텍스트 길이에 의해 제한됩니다.
number
기본값:1
0에서 2 사이의 샘플링 온도. 0.8과 같은 높은 값은 출력을 더 무작위로 만들고, 0.2와 같은 낮은 값은 더 집중적이고 결정론적으로 만듭니다.
number
기본값:1
핵 샘플링 매개변수(0-1). temperature 샘플링의 대안으로, 모델이 top_p 확률 질량을 가진 토큰을 고려합니다.
number
기본값:0
-2.0에서 2.0 사이의 숫자. 양수 값은 텍스트에서의 기존 빈도를 기반으로 새 토큰에 페널티를 부과하여, 모델이 같은 문장을 그대로 반복할 가능성을 줄입니다.
number
기본값:0
-2.0에서 2.0 사이의 숫자. 양수 값은 텍스트에 이미 나타났는지 여부를 기반으로 새 토큰에 페널티를 부과하여, 모델이 새로운 주제에 대해 이야기할 가능성을 높입니다.
string | string[]
API가 추가 토큰 생성을 중단하는 최대 4개의 시퀀스.
integer
기본값:1
각 입력 메시지에 대해 생성할 채팅 완성 선택지 수.
boolean
기본값:false
출력 토큰의 로그 확률을 반환할지 여부. true인 경우, 메시지 내용에 반환된 각 출력 토큰의 로그 확률을 반환합니다.
integer
각 토큰 위치에서 반환할 가장 가능성 높은 토큰 수를 지정하는 0에서 20 사이의 정수. 이 매개변수를 사용하려면
logprobs를 true로 설정해야 합니다.object
integer
지정된 경우, 시스템은 동일한 seed와 매개변수를 가진 반복 요청이 동일한 결과를 반환하도록 최선의 노력으로 결정론적 샘플링을 수행합니다.
object[]
string | object
모델이 어떤 도구를 호출할지(호출하는 경우) 제어합니다.
none은 모델이 도구를 호출하지 않음을 의미합니다. auto는 모델이 메시지 생성 또는 도구 호출 중에서 선택할 수 있음을 의미합니다. required는 모델이 하나 이상의 도구를 호출해야 함을 의미합니다. {"type": "function", "function": {"name": "my_function"}}을 통해 특정 함수를 지정할 수도 있습니다.boolean
기본값:true
도구 사용 시 병렬 함수 호출을 활성화할지 여부.
string
최종 사용자를 나타내는 고유 식별자로, 남용 모니터링 및 감지에 도움이 될 수 있습니다.
응답
채팅 완성 성공 응답.string
채팅 완성의 고유 식별자.
string
객체 유형. 항상
chat.completion.integer
채팅 완성이 생성된 시점의 Unix 타임스탬프(초 단위).
string
채팅 완성에 사용된 모델.
object[]
채팅 완성 선택지 목록.
n이 1보다 큰 경우 둘 이상일 수 있습니다.표시 속성
표시 속성
integer
선택지 목록에서의 인덱스.
object
string
모델이 토큰 생성을 중단한 이유.
stop, length, tool_calls, 또는 content_filter일 수 있습니다.object | null
선택지에 대한 로그 확률 정보.
object
string | null
모델이 실행되는 백엔드 구성을 나타내는 핑거프린트.
seed 매개변수와 함께 사용하여 백엔드 변경 사항을 파악할 수 있습니다.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",
"logprobs": null
}
],
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
⌘I