Chat Completions
curl --request POST \
--url https://api.savegate.ai/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"temperature": 123,
"max_tokens": 123,
"stream": true,
"top_p": 123,
"frequency_penalty": 123,
"presence_penalty": 123,
"stop": {},
"functions": [
{}
],
"function_call": {}
}
'import requests
url = "https://api.savegate.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"temperature": 123,
"max_tokens": 123,
"stream": True,
"top_p": 123,
"frequency_penalty": 123,
"presence_penalty": 123,
"stop": {},
"functions": [{}],
"function_call": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
temperature: 123,
max_tokens: 123,
stream: true,
top_p: 123,
frequency_penalty: 123,
presence_penalty: 123,
stop: {},
functions: [{}],
function_call: {}
})
};
fetch('https://api.savegate.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.savegate.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' => '<string>',
'messages' => [
[
]
],
'temperature' => 123,
'max_tokens' => 123,
'stream' => true,
'top_p' => 123,
'frequency_penalty' => 123,
'presence_penalty' => 123,
'stop' => [
],
'functions' => [
[
]
],
'function_call' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.savegate.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"stop\": {},\n \"functions\": [\n {}\n ],\n \"function_call\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.savegate.ai/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"stop\": {},\n \"functions\": [\n {}\n ],\n \"function_call\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.savegate.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"stop\": {},\n \"functions\": [\n {}\n ],\n \"function_call\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>",
"function_call": {}
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}Endpoints
Chat Completions
Create chat completions with any supported model
POST
/
v1
/
chat
/
completions
Chat Completions
curl --request POST \
--url https://api.savegate.ai/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"temperature": 123,
"max_tokens": 123,
"stream": true,
"top_p": 123,
"frequency_penalty": 123,
"presence_penalty": 123,
"stop": {},
"functions": [
{}
],
"function_call": {}
}
'import requests
url = "https://api.savegate.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"temperature": 123,
"max_tokens": 123,
"stream": True,
"top_p": 123,
"frequency_penalty": 123,
"presence_penalty": 123,
"stop": {},
"functions": [{}],
"function_call": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
temperature: 123,
max_tokens: 123,
stream: true,
top_p: 123,
frequency_penalty: 123,
presence_penalty: 123,
stop: {},
functions: [{}],
function_call: {}
})
};
fetch('https://api.savegate.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.savegate.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' => '<string>',
'messages' => [
[
]
],
'temperature' => 123,
'max_tokens' => 123,
'stream' => true,
'top_p' => 123,
'frequency_penalty' => 123,
'presence_penalty' => 123,
'stop' => [
],
'functions' => [
[
]
],
'function_call' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.savegate.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"stop\": {},\n \"functions\": [\n {}\n ],\n \"function_call\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.savegate.ai/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"stop\": {},\n \"functions\": [\n {}\n ],\n \"function_call\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.savegate.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"temperature\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"top_p\": 123,\n \"frequency_penalty\": 123,\n \"presence_penalty\": 123,\n \"stop\": {},\n \"functions\": [\n {}\n ],\n \"function_call\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>",
"function_call": {}
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}Request
Create a chat completion using any supported model.Headers
| Header | Value | Required |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | Yes |
Content-Type | application/json | Yes |
Body Parameters
string
required
The model to use (e.g.,
gpt-5.1, claude-sonnet-4.5, gpt-4.2, o3)array
required
Array of message objects with
role and contentnumber
default:"1"
Sampling temperature between 0 and 2
integer
Maximum number of tokens to generate
boolean
default:"false"
Whether to stream responses
number
default:"1"
Nucleus sampling parameter
number
default:"0"
Penalize frequent tokens (-2.0 to 2.0)
number
default:"0"
Penalize new tokens (-2.0 to 2.0)
string or array
Stop sequences
array
Function definitions for function calling
string or object
Controls function calling behavior
Response
Response Fields
string
Unique completion ID
string
Object type (always
chat.completion)integer
Unix timestamp
string
Model used for completion
array
object
Examples
curl https://api.savegate.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-savegate-xxxxxxxxxxxxx" \
-d '{
"model": "gpt-5.1",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
],
"temperature": 0.7
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-savegate-xxxxxxxxxxxxx",
base_url="https://api.savegate.ai/v1"
)
response = client.chat.completions.create(
model="gpt-5.1",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
temperature=0.7
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-savegate-xxxxxxxxxxxxx',
baseURL: 'https://api.savegate.ai/v1'
});
const response = await client.chat.completions.create({
model: 'gpt-5.1',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' }
],
temperature: 0.7
});
console.log(response.choices[0].message.content);
Response Example
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-5.1",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 8,
"total_tokens": 28
}
}
Streaming Example
response = client.chat.completions.create(
model="gpt-5.1",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
const stream = await client.chat.completions.create({
model: 'gpt-5.1',
messages: [{ role: 'user', content: 'Tell me a story' }],
stream: true
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
Function Calling Example
functions = [
{
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and state, e.g. San Francisco, CA"
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
]
response = client.chat.completions.create(
model="gpt-5.1",
messages=[{"role": "user", "content": "What's the weather in Boston?"}],
functions=functions,
function_call="auto"
)
print(response.choices[0].message.function_call)
const functions = [
{
name: 'get_weather',
description: 'Get current weather',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'City and state, e.g. San Francisco, CA'
},
unit: { type: 'string', enum: ['celsius', 'fahrenheit'] }
},
required: ['location']
}
}
];
const response = await client.chat.completions.create({
model: 'gpt-5.1',
messages: [{ role: 'user', content: "What's the weather in Boston?" }],
functions: functions,
function_call: 'auto'
});
console.log(response.choices[0].message.function_call);
⌘I