Chat Completions (OpenAI compatible)
Compatible with OpenAI POST /v1/chat/completions. The messages
content in the request body is masked for PII before the model is
called. SSE streaming is supported with stream: true.
POST
/v1/chat/completionsRequest body
requiredapplication/jsonmodelstringrequiredTarget model identifier (defined in the panel).
messagesChatMessage[]requiredmin items 1
Show propertiesHide properties
Array of
ChatMessagerolestringrequiredAllowed:
systemuserassistanttoolcontentstringrequiredMessage text. By default, personal data in the content of all roles
(`system`, `user`, `assistant`, `tool`) is masked inside the
gateway; only the masked form reaches the model.
streambooleanIf true, the response is returned as an SSE stream.
default: false
temperaturenumbermin 0 · max 2 · default: 1
max_tokensintegerMaximum number of tokens to generate.
min 1
top_pnumbermin 0 · max 1
Responses
200Successful response
idstringobjectstringcreatedintegermodelstringchoicesChatChoice[]Show propertiesHide properties
Array of
ChatChoiceindexintegerfinish_reasonstringmessageChatMessageShow propertiesHide properties
rolestringrequiredAllowed:
systemuserassistanttoolcontentstringrequiredMessage text. By default, personal data in the content of all roles
(`system`, `user`, `assistant`, `tool`) is masked inside the
gateway; only the masked form reaches the model.
usageUsageShow propertiesHide properties
prompt_tokensintegercompletion_tokensintegertotal_tokensinteger401Missing or invalid virtual key
errorobjectShow propertiesHide properties
messagestringtypestring429Quota or rate limit exceeded
errorobjectShow propertiesHide properties
messagestringtypestringRequest
from openai import OpenAI
client = OpenAI(
base_url="https://gw-tr.gurubase.io/v1",
api_key="SANAL_ANAHTAR",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "Ayşe Demir'in talebini özetle."},
],
)
print(resp.choices[0].message.content)import requests
response = requests.post(
"https://gw-tr.gurubase.io/v1/chat/completions",
headers={
"Content-Type": "application/json"
},
json={
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "string"
}
],
"stream": False,
"temperature": 1,
"max_tokens": 0,
"top_p": 0
},
)curl -X POST "https://gw-tr.gurubase.io/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "string"
}
],
"stream": false,
"temperature": 1,
"max_tokens": 0,
"top_p": 0
}'const response = await fetch("https://gw-tr.gurubase.io/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "string"
}
],
"stream": false,
"temperature": 1,
"max_tokens": 0,
"top_p": 0
})
});Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1718000000,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "system",
"content": "string"
}
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}{
"error": {
"message": "Sanal anahtar gerekli veya geçersiz.",
"type": "invalid_request_error"
}
}{
"error": {
"message": "string",
"type": "string"
}
}