OpenAI chat completions
curl --request POST \
--url https://api-vip.apigo.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"content": "<string>"
}
],
"temperature": 0.7,
"stream": true
}
'import requests
url = "https://api-vip.apigo.ai/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [{ "content": "<string>" }],
"temperature": 0.7,
"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: 0.7,
stream: true
})
};
fetch('https://api-vip.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://api-vip.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' => 0.7,
'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://api-vip.apigo.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 0.7,\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://api-vip.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\": 0.7,\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-vip.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\": 0.7,\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-compatible chat completion endpoint for multi-turn conversations, tool calling, and streaming responses.
POST
/
v1
/
chat
/
completions
OpenAI chat completions
curl --request POST \
--url https://api-vip.apigo.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"content": "<string>"
}
],
"temperature": 0.7,
"stream": true
}
'import requests
url = "https://api-vip.apigo.ai/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [{ "content": "<string>" }],
"temperature": 0.7,
"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: 0.7,
stream: true
})
};
fetch('https://api-vip.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://api-vip.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' => 0.7,
'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://api-vip.apigo.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"temperature\": 0.7,\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://api-vip.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\": 0.7,\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-vip.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\": 0.7,\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>"
}Creates a model response for a chat conversation.
This endpoint is still the safest default when you need compatibility with existing OpenAI SDKs, chat clients, or legacy chat-completion workflows. Supported fields vary by model, especially for reasoning, tool use, and multimodal inputs.
Integration guidance
- Authenticate with
Authorization: Bearer {API_KEY} - Use this as the default entry point for existing OpenAI-style chat integrations
- If you want a more unified interface for structured output, multimodal input, and tools, prefer
/v1/responses - Streaming clients should handle SSE chunks incrementally instead of waiting for one final JSON response
Request highlights
messagesis required and carries the conversation historymodelis required and selects the target modeltemperatureandtop_pboth affect sampling, but most integrations should tune only one of them- If you need token-level probabilities, combine
logprobswithtop_logprobs - For caching and safety attribution, prefer
prompt_cache_keyandsafety_identifier
Response highlights
- Plain text is usually read from
choices[0].message.content - Tool calls can be read from
message.tool_calls - Streaming responses arrive as SSE chunks and must be merged incrementally
- Usage accounting is exposed through
usage, including more detailed token breakdowns
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
