Chat completions
curl --request POST \
--url https://api.gately.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, how are you today?"
}
],
"temperature": 0.7,
"max_tokens": 150
}
'import requests
url = "https://api.gately.ai/v1/chat/completions"
payload = {
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, how are you today?"
}
],
"temperature": 0.7,
"max_tokens": 150
}
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-4',
messages: [
{role: 'system', content: 'You are a helpful assistant.'},
{role: 'user', content: 'Hello, how are you today?'}
],
temperature: 0.7,
max_tokens: 150
})
};
fetch('https://api.gately.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.gately.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-4',
'messages' => [
[
'role' => 'system',
'content' => 'You are a helpful assistant.'
],
[
'role' => 'user',
'content' => 'Hello, how are you today?'
]
],
'temperature' => 0.7,
'max_tokens' => 150
]),
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.gately.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you today?\"\n }\n ],\n \"temperature\": 0.7,\n \"max_tokens\": 150\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.gately.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you today?\"\n }\n ],\n \"temperature\": 0.7,\n \"max_tokens\": 150\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gately.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-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you today?\"\n }\n ],\n \"temperature\": 0.7,\n \"max_tokens\": 150\n}"
response = http.request(request)
puts response.read_bodyAI Models API
Chat Completions
Generate responses from AI models based on conversation history
POST
/
v1
/
chat
/
completions
Chat completions
curl --request POST \
--url https://api.gately.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, how are you today?"
}
],
"temperature": 0.7,
"max_tokens": 150
}
'import requests
url = "https://api.gately.ai/v1/chat/completions"
payload = {
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, how are you today?"
}
],
"temperature": 0.7,
"max_tokens": 150
}
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-4',
messages: [
{role: 'system', content: 'You are a helpful assistant.'},
{role: 'user', content: 'Hello, how are you today?'}
],
temperature: 0.7,
max_tokens: 150
})
};
fetch('https://api.gately.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.gately.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-4',
'messages' => [
[
'role' => 'system',
'content' => 'You are a helpful assistant.'
],
[
'role' => 'user',
'content' => 'Hello, how are you today?'
]
],
'temperature' => 0.7,
'max_tokens' => 150
]),
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.gately.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you today?\"\n }\n ],\n \"temperature\": 0.7,\n \"max_tokens\": 150\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.gately.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you today?\"\n }\n ],\n \"temperature\": 0.7,\n \"max_tokens\": 150\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gately.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-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, how are you today?\"\n }\n ],\n \"temperature\": 0.7,\n \"max_tokens\": 150\n}"
response = http.request(request)
puts response.read_bodyChat Completions API
The Chat Completions API allows you to have dynamic conversations with AI models. This endpoint enables you to send a series of messages and receive AI-generated responses that maintain context throughout the conversation.Features
- Support for multiple advanced AI models
- Streaming responses for real-time applications
- Temperature and other control parameters
- Function calling capabilities
Example Usage
Models
Available models for chat completions:wizardlm-2-7bclaude-3-5-sonnetgpt-4o-mini
Example Request
{
"stream": false,
"model": "wizardlm-2-7b",
"messages": [
{
"role": "user",
"content": "What is artificial intelligence?"
}
],
"temperature": 0.7,
"max_tokens": 1500
}
Example With Function Calling
{
"stream": false,
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "What's the weather like in New York?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
}
]
}
Example With Image Recognition
{
"stream": false,
"model": "claude-3-5-sonnet",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What's in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg",
"detail": "auto"
}
}
]
}
]
}
Was this page helpful?
⌘I

