cURL
curl --request POST \
--url https://aigw.portkey.ai/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<|endoftext|>",
"best_of": 1,
"echo": false,
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": 2,
"max_tokens": 16,
"n": 1,
"presence_penalty": 0,
"seed": 0,
"stop": "<|endoftext|>",
"stream": false,
"stream_options": {
"include_usage": true
},
"suffix": "<string>",
"temperature": 1,
"top_p": 1,
"user": "<string>"
}
'import requests
url = "https://aigw.portkey.ai/v1/completions"
payload = {
"model": "<string>",
"prompt": "<|endoftext|>",
"best_of": 1,
"echo": False,
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": 2,
"max_tokens": 16,
"n": 1,
"presence_penalty": 0,
"seed": 0,
"stop": "<|endoftext|>",
"stream": False,
"stream_options": { "include_usage": True },
"suffix": "<string>",
"temperature": 1,
"top_p": 1,
"user": "<string>"
}
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: '<string>',
prompt: '<|endoftext|>',
best_of: 1,
echo: false,
frequency_penalty: 0,
logit_bias: {},
logprobs: 2,
max_tokens: 16,
n: 1,
presence_penalty: 0,
seed: 0,
stop: '<|endoftext|>',
stream: false,
stream_options: {include_usage: true},
suffix: '<string>',
temperature: 1,
top_p: 1,
user: '<string>'
})
};
fetch('https://aigw.portkey.ai/v1/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/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>',
'prompt' => '<|endoftext|>',
'best_of' => 1,
'echo' => false,
'frequency_penalty' => 0,
'logit_bias' => [
],
'logprobs' => 2,
'max_tokens' => 16,
'n' => 1,
'presence_penalty' => 0,
'seed' => 0,
'stop' => '<|endoftext|>',
'stream' => false,
'stream_options' => [
'include_usage' => true
],
'suffix' => '<string>',
'temperature' => 1,
'top_p' => 1,
'user' => '<string>'
]),
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/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<|endoftext|>\",\n \"best_of\": 1,\n \"echo\": false,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": 2,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"seed\": 0,\n \"stop\": \"<|endoftext|>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"suffix\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 1,\n \"user\": \"<string>\"\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/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<|endoftext|>\",\n \"best_of\": 1,\n \"echo\": false,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": 2,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"seed\": 0,\n \"stop\": \"<|endoftext|>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"suffix\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 1,\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aigw.portkey.ai/v1/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\": \"<string>\",\n \"prompt\": \"<|endoftext|>\",\n \"best_of\": 1,\n \"echo\": false,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": 2,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"seed\": 0,\n \"stop\": \"<|endoftext|>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"suffix\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 1,\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"logprobs": {
"text_offset": [
123
],
"token_logprobs": [
123
],
"tokens": [
"<string>"
],
"top_logprobs": [
{}
]
},
"text": "<string>"
}
],
"created": 123,
"model": "<string>",
"object": "text_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
}
}
}Create completion
POST
/
completions
cURL
curl --request POST \
--url https://aigw.portkey.ai/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<|endoftext|>",
"best_of": 1,
"echo": false,
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": 2,
"max_tokens": 16,
"n": 1,
"presence_penalty": 0,
"seed": 0,
"stop": "<|endoftext|>",
"stream": false,
"stream_options": {
"include_usage": true
},
"suffix": "<string>",
"temperature": 1,
"top_p": 1,
"user": "<string>"
}
'import requests
url = "https://aigw.portkey.ai/v1/completions"
payload = {
"model": "<string>",
"prompt": "<|endoftext|>",
"best_of": 1,
"echo": False,
"frequency_penalty": 0,
"logit_bias": {},
"logprobs": 2,
"max_tokens": 16,
"n": 1,
"presence_penalty": 0,
"seed": 0,
"stop": "<|endoftext|>",
"stream": False,
"stream_options": { "include_usage": True },
"suffix": "<string>",
"temperature": 1,
"top_p": 1,
"user": "<string>"
}
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: '<string>',
prompt: '<|endoftext|>',
best_of: 1,
echo: false,
frequency_penalty: 0,
logit_bias: {},
logprobs: 2,
max_tokens: 16,
n: 1,
presence_penalty: 0,
seed: 0,
stop: '<|endoftext|>',
stream: false,
stream_options: {include_usage: true},
suffix: '<string>',
temperature: 1,
top_p: 1,
user: '<string>'
})
};
fetch('https://aigw.portkey.ai/v1/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/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>',
'prompt' => '<|endoftext|>',
'best_of' => 1,
'echo' => false,
'frequency_penalty' => 0,
'logit_bias' => [
],
'logprobs' => 2,
'max_tokens' => 16,
'n' => 1,
'presence_penalty' => 0,
'seed' => 0,
'stop' => '<|endoftext|>',
'stream' => false,
'stream_options' => [
'include_usage' => true
],
'suffix' => '<string>',
'temperature' => 1,
'top_p' => 1,
'user' => '<string>'
]),
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/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<|endoftext|>\",\n \"best_of\": 1,\n \"echo\": false,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": 2,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"seed\": 0,\n \"stop\": \"<|endoftext|>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"suffix\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 1,\n \"user\": \"<string>\"\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/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<|endoftext|>\",\n \"best_of\": 1,\n \"echo\": false,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": 2,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"seed\": 0,\n \"stop\": \"<|endoftext|>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"suffix\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 1,\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aigw.portkey.ai/v1/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\": \"<string>\",\n \"prompt\": \"<|endoftext|>\",\n \"best_of\": 1,\n \"echo\": false,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"logprobs\": 2,\n \"max_tokens\": 16,\n \"n\": 1,\n \"presence_penalty\": 0,\n \"seed\": 0,\n \"stop\": \"<|endoftext|>\",\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"suffix\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 1,\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"logprobs": {
"text_offset": [
123
],
"token_logprobs": [
123
],
"tokens": [
"<string>"
],
"top_logprobs": [
{}
]
},
"text": "<string>"
}
],
"created": 123,
"model": "<string>",
"object": "text_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.
Body
application/json
Required range:
0 <= x <= 20Required range:
-2 <= x <= 2Show child attributes
Show child attributes
Required range:
0 <= x <= 5Required range:
x >= 0Required range:
1 <= x <= 128Required range:
-2 <= x <= 2Required range:
-9223372036854776000 <= x <= 9223372036854776000Show child attributes
Show child attributes
Required range:
0 <= x <= 2Required range:
0 <= x <= 1Last modified on September 18, 2026
Was this page helpful?

