OpenAI chat completions
curl --request POST \
--url https://maas.apigo.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"content": "<string>"
}
],
"temperature": 1,
"stream": true
}
'import requests
url = "https://maas.apigo.ai/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [{ "content": "<string>" }],
"temperature": 1,
"stream": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-4o',
messages: [{content: '<string>'}],
temperature: 1,
stream: true
})
};
fetch('https://maas.apigo.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://maas.apigo.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4o',
'messages' => [
[
'content' => '<string>'
]
],
'temperature' => 1,
'stream' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://maas.apigo.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"stream\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://maas.apigo.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://maas.apigo.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>"
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": 123,
"message": "<string>"
}Text
/v1/chat/completions
다중 대화, 도구 호출 및 스트리밍 응답을 위한 OpenAI 호환 채팅 완료 엔드포인트입니다.
POST
/
v1
/
chat
/
completions
OpenAI chat completions
curl --request POST \
--url https://maas.apigo.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"content": "<string>"
}
],
"temperature": 1,
"stream": true
}
'import requests
url = "https://maas.apigo.ai/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [{ "content": "<string>" }],
"temperature": 1,
"stream": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-4o',
messages: [{content: '<string>'}],
temperature: 1,
stream: true
})
};
fetch('https://maas.apigo.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://maas.apigo.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4o',
'messages' => [
[
'content' => '<string>'
]
],
'temperature' => 1,
'stream' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://maas.apigo.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"stream\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://maas.apigo.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://maas.apigo.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>"
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": 123,
"message": "<string>"
}채팅 대화에 대한 모델 응답을 만듭니다.
이 엔드포인트는 기존 OpenAI SDK, 채팅 클라이언트 또는 레거시 채팅 완료 워크플로와의 호환성이 필요할 때 여전히 가장 안전한 기본값입니다. 지원되는 필드는 특히 추론, 도구 사용 및 다중 모드 입력의 경우 모델에 따라 다릅니다.
통합 지침
Authorization: Bearer {API_KEY}로 인증- 이를 기존 OpenAI 스타일 채팅 통합의 기본 진입점으로 사용합니다.
- 구조화된 출력, 다중 모드 입력 및 도구에 대한 보다 통합된 인터페이스를 원한다면
/v1/responses를 선호하세요. - 스트리밍 클라이언트는 하나의 최종 JSON 응답을 기다리는 대신 SSE 청크를 점진적으로 처리해야 합니다.
요청 하이라이트
messages가 필요하며 대화 기록을 전달합니다.model가 필요하며 대상 모델을 선택합니다.temperature및top_p는 모두 샘플링에 영향을 미치지만 대부분의 통합에서는 둘 중 하나만 조정해야 합니다.- 토큰 수준의 확률이 필요한 경우
logprobs와top_logprobs를 결합하세요. - 캐싱 및 안전 속성을 위해서는
prompt_cache_key및safety_identifier를 선호합니다.
응답 하이라이트
- 일반 텍스트는 일반적으로
choices[0].message.content에서 읽습니다. message.tool_calls에서 도구 호출을 읽을 수 있습니다.- 스트리밍 응답은 SSE 청크로 도착하며 점진적으로 병합되어야 합니다.
- 보다 자세한 토큰 분석을 포함하여 사용량 계산은
usage를 통해 노출됩니다.
인증
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
본문
application/json
