Chat Completions
curl --request POST \
--url https://openp.ai/v1/chat/completionsimport requests
url = "https://openp.ai/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://openp.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://openp.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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://openp.ai/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://openp.ai/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://openp.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyOpenAI-compatible
Chat Completions
POST /v1/chat/completions — a fully OpenAI-compatible chat endpoint
POST
/
v1
/
chat
/
completions
Chat Completions
curl --request POST \
--url https://openp.ai/v1/chat/completionsimport requests
url = "https://openp.ai/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://openp.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://openp.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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://openp.ai/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://openp.ai/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://openp.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyCreate a model response based on the conversation context (the messages array).
Every model with chat capability (OpenAI / Claude / Gemini / DeepSeek / Qwen, etc.) can be called through this endpoint.
Supported roles:
With
In the response:
After executing the tool, append the result to messages:
Call chat completions again to let the model continue answering based on the tool result.
You can also use a suffixed model ID (
Request
Authentication
Authorization: Bearer sk-XXXXXXXXXXXXXXXX
Main parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | ✅ | Model ID, e.g. gpt-5.5 |
messages | array | ✅ | Conversation history, each item { role, content } |
temperature | number | 0-2, default 1. Lower is more deterministic | |
top_p | number | 0-1, nucleus sampling; use this or temperature, not both | |
n | integer | How many candidates to generate (default 1) | |
stream | boolean | true enables SSE streaming | |
stream_options | object | { include_usage: true } appends usage at the end of the stream | |
max_tokens | integer | Maximum output tokens (legacy field, replaced by max_completion_tokens for some models) | |
max_completion_tokens | integer | New field, for o3 / GPT-5 | |
stop | string | array | Stop sequences | |
presence_penalty | number | -2 to 2 | |
frequency_penalty | number | -2 to 2 | |
logit_bias | map | Token bias | |
seed | integer | Reproducibility seed | |
response_format | object | { type: "json_object" } or a JSON Schema | |
tools | array | List of function-calling tools | |
tool_choice | string | object | auto / required / { type:"function", function:{name:"..."}} | |
parallel_tool_calls | boolean | Whether to allow parallel tool calls | |
reasoning_effort | string | Reasoning effort for o3 / GPT-5: low / medium / high | |
modalities | array | Multimodal output, e.g. ["text","audio"] | |
audio | object | Audio output options | |
user | string | End-user identifier (for auditing) |
messages structure
[
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Tell a joke"},
{"role": "assistant", "content": "Why do programmers like the dark? Because there are no bugs."},
{"role": "user", "content": [
{"type": "text", "text": "Describe this image"},
{"type": "image_url", "image_url": {"url": "https://..."}}
]}
]
system / user / assistant / tool (function return).
Response
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1715750400,
"model": "gpt-5.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "answer content..."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 27,
"completion_tokens": 19,
"total_tokens": 46,
"prompt_tokens_details": { "cached_tokens": 0 },
"completion_tokens_details": { "reasoning_tokens": 0 }
},
"system_fingerprint": "fp_..."
}
finish_reason possible values: stop / length / tool_calls / content_filter.
Streaming response
Withstream: true, the server pushes chunks in SSE format:
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"He"},"index":0}]}
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"llo"},"index":0}]}
data: {"id":"chatcmpl-...","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
data: [DONE]
stream_options.include_usage: true, an extra chunk with usage is sent at the end:
data: {"id":"chatcmpl-...","choices":[],"usage":{"prompt_tokens":...,"completion_tokens":...}}
Function calling
{
"model": "gpt-5.5",
"messages": [{"role": "user", "content": "Weather in Shanghai"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}
{
"choices": [{
"message": {
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_abc",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\":\"Shanghai\"}"}
}]
},
"finish_reason": "tool_calls"
}]
}
{"role": "tool", "tool_call_id": "call_abc", "content": "Shanghai is 26°C and clear today"}
Reasoning models
For the o3 / GPT-5 series, usereasoning_effort:
{
"model": "o3-mini-high",
"messages": [{"role": "user", "content": "Prove that √2 is irrational"}],
"reasoning_effort": "high",
"max_completion_tokens": 4096
}
o3-mini-low / -medium / -high) for the equivalent effect.