cURL
curl --request POST \
--url https://aigw.portkey.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "<string>",
"role": "system",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": false,
"top_logprobs": 10,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": {
"type": "text"
},
"seed": 0,
"stop": "<string>",
"stream": false,
"stream_options": {
"include_usage": true
},
"thinking": {
"type": "disabled",
"budget_tokens": 2
},
"temperature": 1,
"top_p": 1,
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": false
}
}
],
"parallel_tool_calls": true,
"user": "<string>",
"functions": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
]
}
'import requests
url = "https://aigw.portkey.ai/v1/chat/completions"
payload = {
"messages": [
{
"content": "<string>",
"role": "system",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": False,
"top_logprobs": 10,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": { "type": "text" },
"seed": 0,
"stop": "<string>",
"stream": False,
"stream_options": { "include_usage": True },
"thinking": {
"type": "disabled",
"budget_tokens": 2
},
"temperature": 1,
"top_p": 1,
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": False
}
}
],
"parallel_tool_calls": True,
"user": "<string>",
"functions": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
]
}
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({
messages: [{content: '<string>', role: 'system', name: '<string>'}],
model: '<string>',
frequency_penalty: 0,
logit_bias: {},
logprobs: false,
top_logprobs: 10,
max_tokens: 123,
max_completion_tokens: 123,
n: 1,
presence_penalty: 0,
response_format: {type: 'text'},
seed: 0,
stop: '<string>',
stream: false,
stream_options: {include_usage: true},
thinking: {type: 'disabled', budget_tokens: 2},
temperature: 1,
top_p: 1,
tools: [
{
type: 'function',
function: {name: '<string>', description: '<string>', parameters: {}, strict: false}
}
],
parallel_tool_calls: true,
user: '<string>',
functions: [{name: '<string>', description: '<string>', parameters: {}}]
})
};
fetch('https://aigw.portkey.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://aigw.portkey.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([
'messages' => [
[
'content' => '<string>',
'role' => 'system',
'name' => '<string>'
]
],
'model' => '<string>',
'frequency_penalty' => 0,
'logit_bias' => [
],
'logprobs' => false,
'top_logprobs' => 10,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'n' => 1,
'presence_penalty' => 0,
'response_format' => [
'type' => 'text'
],
'seed' => 0,
'stop' => '<string>',
'stream' => false,
'stream_options' => [
'include_usage' => true
],
'thinking' => [
'type' => 'disabled',
'budget_tokens' => 2
],
'temperature' => 1,
'top_p' => 1,
'tools' => [
[
'type' => 'function',
'function' => [
'name' => '<string>',
'description' => '<string>',
'parameters' => [
],
'strict' => false
]
]
],
'parallel_tool_calls' => true,
'user' => '<string>',
'functions' => [
[
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
]
]),
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://aigw.portkey.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"system\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 10,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"seed\": 0,\n \"stop\": \"<string>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"thinking\": {\n \"type\": \"disabled\",\n \"budget_tokens\": 2\n },\n \"temperature\": 1,\n \"top_p\": 1,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": false\n }\n }\n ],\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"functions\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\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://aigw.portkey.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"system\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 10,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"seed\": 0,\n \"stop\": \"<string>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"thinking\": {\n \"type\": \"disabled\",\n \"budget_tokens\": 2\n },\n \"temperature\": 1,\n \"top_p\": 1,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": false\n }\n }\n ],\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"functions\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aigw.portkey.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 \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"system\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 10,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"seed\": 0,\n \"stop\": \"<string>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"thinking\": {\n \"type\": \"disabled\",\n \"budget_tokens\": 2\n },\n \"temperature\": 1,\n \"top_p\": 1,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": false\n }\n }\n ],\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"functions\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"message": {
"content": "<string>",
"role": "assistant",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"content_blocks": [
{
"type": "text",
"text": "<string>"
}
]
},
"logprobs": {
"content": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
]
}
}
],
"created": 123,
"model": "<string>",
"object": "chat.completion",
"system_fingerprint": "<string>",
"usage": {
"completion_tokens": 123,
"prompt_tokens": 123,
"total_tokens": 123,
"completion_tokens_details": {
"reasoning_tokens": 123,
"accepted_prediction_tokens": 123,
"rejected_prediction_tokens": 123
},
"prompt_tokens_details": {
"cached_tokens": 123
}
}
}POST
/
chat
/
completions
cURL
curl --request POST \
--url https://aigw.portkey.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "<string>",
"role": "system",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": false,
"top_logprobs": 10,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": {
"type": "text"
},
"seed": 0,
"stop": "<string>",
"stream": false,
"stream_options": {
"include_usage": true
},
"thinking": {
"type": "disabled",
"budget_tokens": 2
},
"temperature": 1,
"top_p": 1,
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": false
}
}
],
"parallel_tool_calls": true,
"user": "<string>",
"functions": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
]
}
'import requests
url = "https://aigw.portkey.ai/v1/chat/completions"
payload = {
"messages": [
{
"content": "<string>",
"role": "system",
"name": "<string>"
}
],
"model": "<string>",
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": False,
"top_logprobs": 10,
"max_tokens": 123,
"max_completion_tokens": 123,
"n": 1,
"presence_penalty": 0,
"response_format": { "type": "text" },
"seed": 0,
"stop": "<string>",
"stream": False,
"stream_options": { "include_usage": True },
"thinking": {
"type": "disabled",
"budget_tokens": 2
},
"temperature": 1,
"top_p": 1,
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": False
}
}
],
"parallel_tool_calls": True,
"user": "<string>",
"functions": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
]
}
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({
messages: [{content: '<string>', role: 'system', name: '<string>'}],
model: '<string>',
frequency_penalty: 0,
logit_bias: {},
logprobs: false,
top_logprobs: 10,
max_tokens: 123,
max_completion_tokens: 123,
n: 1,
presence_penalty: 0,
response_format: {type: 'text'},
seed: 0,
stop: '<string>',
stream: false,
stream_options: {include_usage: true},
thinking: {type: 'disabled', budget_tokens: 2},
temperature: 1,
top_p: 1,
tools: [
{
type: 'function',
function: {name: '<string>', description: '<string>', parameters: {}, strict: false}
}
],
parallel_tool_calls: true,
user: '<string>',
functions: [{name: '<string>', description: '<string>', parameters: {}}]
})
};
fetch('https://aigw.portkey.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://aigw.portkey.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([
'messages' => [
[
'content' => '<string>',
'role' => 'system',
'name' => '<string>'
]
],
'model' => '<string>',
'frequency_penalty' => 0,
'logit_bias' => [
],
'logprobs' => false,
'top_logprobs' => 10,
'max_tokens' => 123,
'max_completion_tokens' => 123,
'n' => 1,
'presence_penalty' => 0,
'response_format' => [
'type' => 'text'
],
'seed' => 0,
'stop' => '<string>',
'stream' => false,
'stream_options' => [
'include_usage' => true
],
'thinking' => [
'type' => 'disabled',
'budget_tokens' => 2
],
'temperature' => 1,
'top_p' => 1,
'tools' => [
[
'type' => 'function',
'function' => [
'name' => '<string>',
'description' => '<string>',
'parameters' => [
],
'strict' => false
]
]
],
'parallel_tool_calls' => true,
'user' => '<string>',
'functions' => [
[
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
]
]),
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://aigw.portkey.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"system\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 10,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"seed\": 0,\n \"stop\": \"<string>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"thinking\": {\n \"type\": \"disabled\",\n \"budget_tokens\": 2\n },\n \"temperature\": 1,\n \"top_p\": 1,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": false\n }\n }\n ],\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"functions\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\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://aigw.portkey.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"system\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 10,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"seed\": 0,\n \"stop\": \"<string>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"thinking\": {\n \"type\": \"disabled\",\n \"budget_tokens\": 2\n },\n \"temperature\": 1,\n \"top_p\": 1,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": false\n }\n }\n ],\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"functions\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aigw.portkey.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 \"messages\": [\n {\n \"content\": \"<string>\",\n \"role\": \"system\",\n \"name\": \"<string>\"\n }\n ],\n \"model\": \"<string>\",\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": false,\n \"top_logprobs\": 10,\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"seed\": 0,\n \"stop\": \"<string>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"thinking\": {\n \"type\": \"disabled\",\n \"budget_tokens\": 2\n },\n \"temperature\": 1,\n \"top_p\": 1,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": false\n }\n }\n ],\n \"parallel_tool_calls\": true,\n \"user\": \"<string>\",\n \"functions\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"message": {
"content": "<string>",
"role": "assistant",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"content_blocks": [
{
"type": "text",
"text": "<string>"
}
]
},
"logprobs": {
"content": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
]
}
}
],
"created": 123,
"model": "<string>",
"object": "chat.completion",
"system_fingerprint": "<string>",
"usage": {
"completion_tokens": 123,
"prompt_tokens": 123,
"total_tokens": 123,
"completion_tokens_details": {
"reasoning_tokens": 123,
"accepted_prediction_tokens": 123,
"rejected_prediction_tokens": 123
},
"prompt_tokens_details": {
"cached_tokens": 123
}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Body
application/json
messages
(System message · object | Developer message · object | User message · object | Assistant message · object | Tool message · object | Function message · object)[]
required
Minimum array length:
1- System message
- Developer message
- User message
- Assistant message
- Tool message
- Function message
Show child attributes
Show child attributes
Required range:
-2 <= x <= 2Show child attributes
Show child attributes
Required range:
0 <= x <= 20Required range:
1 <= x <= 128Required range:
-2 <= x <= 2- Text
- JSON schema
- JSON object
Show child attributes
Show child attributes
Required range:
-9223372036854776000 <= x <= 9223372036854776000Show child attributes
Show child attributes
Show child attributes
Show child attributes
Required range:
0 <= x <= 2Required range:
0 <= x <= 1Show child attributes
Show child attributes
Available options:
none, auto, required Available options:
none, auto Required array length:
1 - 128 elementsShow child attributes
Show child attributes
Last modified on September 18, 2026
Was this page helpful?

