채팅 완료 생성
Bearer API 키를 사용하여 ShareAI 채팅 완료 요청을 보내고 지원되는 모델, 메시지 및 스트림 필드를 이해하세요.
이 페이지에서
https://api.shareai.now/api/v1/chat/completions선택한 모델을 사용하여 채팅 요청 실행.
- 기본 URL
https://api.shareai.now- 인증
- Bearer API 키
이것은 API 키 작업 공간에서 승인 및 결제가 이루어진 요청의 기본 통합 경로입니다. 키의 모델 및 제공자 제한은 할당에 적용되며 허용된 대체 경로를 포함합니다.
요청 본문#
| 필드 | 유형 | 의미 |
|---|---|---|
model | 문자열, 필수 | 사용 가능한 정확한 모델 식별자. 모델에서 복사하세요. |
messages | 배열 | 역할과 내용을 포함하는 대화 메시지. |
stream | 불리언 | false는 하나의 JSON 결과를 반환합니다; true는 서버 전송 이벤트를 요청합니다. |
텍스트 메시지 내용을 사용하세요. 대화에 적합한 역할을 보내세요. system, user 그리고 assistant 모델이 사용할 대화 기록을 포함하세요; 요청이 저장된 대화를 공유한다고 가정하지 마세요.
cURL
curl --fail-with-body --request POST \
"https://api.shareai.now/api/v1/chat/completions" \
-H "Authorization: Bearer $SHAREAI_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "MODEL_IDENTIFIER",
"messages": [
{
"role": "system",
"content": "Be concise and helpful."
},
{
"role": "user",
"content": "Give me three ideas for a local community event."
}
],
"stream": false
}'
Python
import json
import os
import urllib.request
headers = {"Authorization": "Bearer " + os.environ["SHAREAI_API_KEY"]}
headers["Content-Type"] = "application/json"
payload = {'model': 'MODEL_IDENTIFIER', 'messages': [{'role': 'system', 'content': 'Be concise and helpful.'}, {'role': 'user', 'content': 'Give me three ideas for a local community event.'}], 'stream': False}
data = json.dumps(payload).encode()
request = urllib.request.Request('https://api.shareai.now/api/v1/chat/completions', data=data, headers=headers, method='POST')
with urllib.request.urlopen(request, timeout=60) as response:
print(json.load(response))
TypeScript
const url = "https://api.shareai.now/api/v1/chat/completions";
const headers: Record = {
Authorization: `Bearer ${process.env.SHAREAI_API_KEY}`,
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "MODEL_IDENTIFIER",
"messages": [
{
"role": "system",
"content": "Be concise and helpful."
},
{
"role": "user",
"content": "Give me three ideas for a local community event."
}
],
"stream": false
};
const response = await fetch(url, { method: "POST", headers, body: JSON.stringify(payload) });
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
console.log(await response.json());
응답#
완료된 비스트리밍 결과는 done true로 설정되고 생성된 텍스트를 반환합니다. message.content. 최상위 레벨도 done_reason 그리고 consumption_type. 를 포함합니다. 스트리밍은 다른 채팅 완료 청크 형식을 사용합니다. 비스트리밍 결과가 OpenAI 스타일의 선택 배열을 포함한다고 가정하지 마세요.
JSON
{
"done": true,
"done_reason": "stop",
"consumption_type": "credits",
"message": {
"role": "assistant",
"content": "Here are three ideas for your community event.",
"done": true,
"done_reason": "stop"
}
}
이것은 예시적인 완료된 결과입니다; consumption_type은 실제 할당 모드를 설명합니다. HTTP 상태가 200일 때도 최상위 오류를 확인하세요. 현재 no-device 결과는 error.code = no_device HTTP 200을 사용합니다.
모델 및 제공자 제한#
키는 특정 모델 및 실행 제공자로 제한될 수 있습니다. 액세스가 거부된 경우 키 정보를 확인하고 소유 작업 공간이 해당 액세스를 부여하려는 경우에만 콘솔에서 키를 업데이트하세요. 응답 스트리밍.
스트리밍 또는 고객 승인#
마지막 업데이트 9월 15, 2026