Chat Completions
curl --request POST \
--url https://api.example.com/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": true,
"user": "<string>",
"getprofile": {
"traits": [
{}
],
"skipInjection": true,
"skipExtraction": true
}
}
'import requests
url = "https://api.example.com/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": True,
"user": "<string>",
"getprofile": {
"traits": [{}],
"skipInjection": True,
"skipExtraction": True
}
}
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: [{}],
stream: true,
user: '<string>',
getprofile: {traits: [{}], skipInjection: true, skipExtraction: true}
})
};
fetch('https://api.example.com/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.example.com/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' => [
[
]
],
'stream' => true,
'user' => '<string>',
'getprofile' => [
'traits' => [
[
]
],
'skipInjection' => true,
'skipExtraction' => true
]
]),
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.example.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"user\": \"<string>\",\n \"getprofile\": {\n \"traits\": [\n {}\n ],\n \"skipInjection\": true,\n \"skipExtraction\": true\n }\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.example.com/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"user\": \"<string>\",\n \"getprofile\": {\n \"traits\": [\n {}\n ],\n \"skipInjection\": true,\n \"skipExtraction\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/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 \"stream\": true,\n \"user\": \"<string>\",\n \"getprofile\": {\n \"traits\": [\n {}\n ],\n \"skipInjection\": true,\n \"skipExtraction\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1704067200,
"model": "gpt-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello Alex! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 50,
"completion_tokens": 12,
"total_tokens": 62
}
}
Proxy API
Chat Completions
OpenAI-compatible chat completion endpoint
POST
/
v1
/
chat
/
completions
Chat Completions
curl --request POST \
--url https://api.example.com/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": true,
"user": "<string>",
"getprofile": {
"traits": [
{}
],
"skipInjection": true,
"skipExtraction": true
}
}
'import requests
url = "https://api.example.com/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": True,
"user": "<string>",
"getprofile": {
"traits": [{}],
"skipInjection": True,
"skipExtraction": True
}
}
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: [{}],
stream: true,
user: '<string>',
getprofile: {traits: [{}], skipInjection: true, skipExtraction: true}
})
};
fetch('https://api.example.com/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.example.com/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' => [
[
]
],
'stream' => true,
'user' => '<string>',
'getprofile' => [
'traits' => [
[
]
],
'skipInjection' => true,
'skipExtraction' => true
]
]),
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.example.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"user\": \"<string>\",\n \"getprofile\": {\n \"traits\": [\n {}\n ],\n \"skipInjection\": true,\n \"skipExtraction\": true\n }\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.example.com/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": true,\n \"user\": \"<string>\",\n \"getprofile\": {\n \"traits\": [\n {}\n ],\n \"skipInjection\": true,\n \"skipExtraction\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/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 \"stream\": true,\n \"user\": \"<string>\",\n \"getprofile\": {\n \"traits\": [\n {}\n ],\n \"skipInjection\": true,\n \"skipExtraction\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1704067200,
"model": "gpt-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello Alex! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 50,
"completion_tokens": 12,
"total_tokens": 62
}
}
Overview
The chat completions endpoint is fully compatible with OpenAI’s API. GetProfile automatically:- Loads the user’s profile
- Injects relevant context into the system message
- Forwards the request to the upstream provider
- Extracts traits and memories in the background
Request
string
required
Model to use (e.g.,
gpt-5, gpt-5-mini)array
required
Array of message objects
boolean
default:"false"
Enable streaming responses
string
User identifier (alternative to
X-GetProfile-Id header)object
Response
Standard OpenAI chat completion response.{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1704067200,
"model": "gpt-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello Alex! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 50,
"completion_tokens": 12,
"total_tokens": 62
}
}
Examples
Basic Request
curl https://api.yourserver.com/v1/chat/completions \
-H "Authorization: Bearer gp_your_key" \
-H "X-GetProfile-Id: user-123" \
-H "X-Upstream-Key: sk-openai-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello!" }],
});
Streaming
curl https://api.yourserver.com/v1/chat/completions \
-H "Authorization: Bearer gp_your_key" \
-H "X-GetProfile-Id: user-123" \
-H "X-Upstream-Key: sk-openai-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
const stream = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello!" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
Per-Request Traits
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Help me plan my trip" }],
// @ts-ignore - GetProfile extension
getprofile: {
traits: [
{
key: "travel_preferences",
valueType: "object",
extraction: { enabled: true },
injection: { enabled: true, template: "Travel prefs: {{value}}" },
},
],
},
});
Skip Processing
// Skip context injection (raw request)
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello!" }],
// @ts-ignore
getprofile: { skipInjection: true },
});
// Skip background extraction
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello!" }],
// @ts-ignore
getprofile: { skipExtraction: true },
});
⌘I