컨텐츠로 건너뛰기
主站 新闻 控制台

Chat Completions

대화 완성은 가장 많이 사용되는 인터페이스로, OpenAI 프로토콜과 완전히 호환됩니다.

POST https://api.4allapi.com/v1/chat/completions

요청 파라미터

파라미터타입필수설명
modelstring모델 이름, 모델 개요 참조
messagesarray대화 메시지 배열, 요소에 rolecontent 포함
streamboolean아니오스트리밍 반환 여부, 스트리밍 출력 참조
temperaturenumber아니오샘플링 온도 0–2, 값이 클수록 더 다양한 출력
top_pnumber아니오핵 샘플링 임계값, temperature와 택일하여 조정
max_tokensnumber아니오응답의 최대 토큰 수
stopstring/array아니오정지 단어
presence_penaltynumber아니오주제 참신도 페널티 -2–2
frequency_penaltynumber아니오반복도 페널티 -2–2
toolsarray아니오도구/함수 호출 정의 (지원 모델)
response_formatobject아니오예: {"type":"json_object"} JSON 출력 강제

messagesrolesystem / user / assistant / tool을 지원합니다. content는 문자열이거나 멀티모달 배열(텍스트 + 이미지, 비전 이해 참조)일 수 있습니다.

요청 예시

Terminal window
curl https://api.4allapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AIPROXY_KEY" \
-d '{
"model": "fable-5",
"messages": [
{"role": "system", "content": "你是一个严谨的技术助手"},
{"role": "user", "content": "用一句话解释什么是 API 网关"}
],
"temperature": 0.7,
"max_tokens": 512
}'

응답 구조

{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1750000000,
"model": "fable-5",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "API 网关是……" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 32,
"completion_tokens": 41,
"total_tokens": 73
}
}

usage 필드는 과금 기준이며, 자세한 내용은 과금 및 한도를 참조하세요.