Chat Completions
OpenAI-compatible chat completion endpoint. Hand a list of messages to the model and get back one or more assistant replies, optionally streamed.
Protocol boundary
This is the OpenAI request/response format. Some Anthropic-backed groups can still use it through gateway translation, but if you depend on Anthropic-native semantics, prefer /v1/messages.
Endpoint
POST https://api.sakrylle.com/v1/chat/completionsHeaders
| Name | Required | Description |
|---|---|---|
Authorization | Yes | Bearer sk-xxxxxxxxxxxxxxxx |
Content-Type | Yes | application/json |
Accept | No | Set text/event-stream for streaming |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, e.g. gpt-5.6-sol |
messages | array | Yes | Full conversation history; each item has a role (system / user / assistant / tool) and content |
stream | boolean | No | Defaults to false; true returns SSE |
temperature | number | No | 0–2, defaults follow upstream |
top_p | number | No | Nucleus sampling probability |
max_tokens | integer | No | Upper bound on output tokens (some newer models use max_completion_tokens) |
n | integer | No | Number of candidates to generate, defaults to 1 |
stop | string | array | No | Stop sequences |
presence_penalty | number | No | -2.0 to 2.0 |
frequency_penalty | number | No | -2.0 to 2.0 |
tools | array | No | Tool definitions |
tool_choice | string | object | No | auto / none / a specific tool |
response_format | object | No | e.g. {"type":"json_object"} |
user | string | No | End-user identifier |
The gateway only validates that
modelis present; all other fields pass through to the OpenAI-compatible upstream.
Example request
json
{
"model": "gpt-5.6-sol",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Introduce yourself." }
],
"temperature": 0.7
}Example response
json
{
"id": "chatcmpl-xxxxxxxxxxxxxxxx",
"object": "chat.completion",
"created": 1716350400,
"model": "gpt-5.6-sol",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I'm gpt-5.6-sol. How can I help you?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 14,
"total_tokens": 42
}
}Streaming response
With stream: true, the response is Content-Type: text/event-stream. Each frame is a data: <json> line, ending with data: [DONE].
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1716350400,"model":"gpt-5.6-sol","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1716350400,"model":"gpt-5.6-sol","choices":[{"index":0,"delta":{"content":"Sakrylle"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1716350400,"model":"gpt-5.6-sol","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]Errors
400 invalid_request_error— missingmodelor invalid JSON401 authentication_error— invalid API key403 billing_error— balance or plan quota exhausted429 rate_limit_error— concurrency or rate limit hit502 upstream_error— upstream repeatedly failed, please retry later
For the full table, see Errors.
Code samples
bash
curl https://api.sakrylle.com/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'python
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxxxxxxxxxx",
base_url="https://api.sakrylle.com/v1",
)
resp = client.chat.completions.create(
model="gpt-5.6-sol",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)javascript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-xxxxxxxxxxxxxxxx",
baseURL: "https://api.sakrylle.com/v1",
});
const resp = await client.chat.completions.create({
model: "gpt-5.6-sol",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);go
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("sk-xxxxxxxxxxxxxxxx"),
option.WithBaseURL("https://api.sakrylle.com/v1/"),
)
resp, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: openai.F("gpt-5.6-sol"),
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
openai.UserMessage("Hello!"),
}),
})
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}rust
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = Client::new();
let resp: serde_json::Value = client
.post("https://api.sakrylle.com/v1/chat/completions")
.bearer_auth("sk-xxxxxxxxxxxxxxxx")
.json(&json!({
"model": "gpt-5.6-sol",
"messages": [{"role": "user", "content": "Hello!"}]
}))
.send()
.await?
.json()
.await?;
println!("{resp:#}");
Ok(())
}java
import java.net.URI;
import java.net.http.*;
public class ChatCompletions {
public static void main(String[] args) throws Exception {
String body = """
{"model":"gpt-5.6-sol","messages":[{"role":"user","content":"Hello!"}]}
""";
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.sakrylle.com/v1/chat/completions"))
.header("Authorization", "Bearer sk-xxxxxxxxxxxxxxxx")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());
}
}csharp
using System.Net.Http.Headers;
using System.Text;
var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "sk-xxxxxxxxxxxxxxxx");
var payload = """
{"model":"gpt-5.6-sol","messages":[{"role":"user","content":"Hello!"}]}
""";
var resp = await http.PostAsync(
"https://api.sakrylle.com/v1/chat/completions",
new StringContent(payload, Encoding.UTF8, "application/json"));
Console.WriteLine(await resp.Content.ReadAsStringAsync());