Skip to main content
POST
/
v1
/
chat
/
completions
Chat Completions
curl --request POST \
  --url https://openp.ai/v1/chat/completions
import 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_body
Create 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.

Request

Authentication

Authorization: Bearer sk-XXXXXXXXXXXXXXXX

Main parameters

FieldTypeRequiredDescription
modelstringModel ID, e.g. gpt-5.5
messagesarrayConversation history, each item { role, content }
temperaturenumber0-2, default 1. Lower is more deterministic
top_pnumber0-1, nucleus sampling; use this or temperature, not both
nintegerHow many candidates to generate (default 1)
streambooleantrue enables SSE streaming
stream_optionsobject{ include_usage: true } appends usage at the end of the stream
max_tokensintegerMaximum output tokens (legacy field, replaced by max_completion_tokens for some models)
max_completion_tokensintegerNew field, for o3 / GPT-5
stopstring | arrayStop sequences
presence_penaltynumber-2 to 2
frequency_penaltynumber-2 to 2
logit_biasmapToken bias
seedintegerReproducibility seed
response_formatobject{ type: "json_object" } or a JSON Schema
toolsarrayList of function-calling tools
tool_choicestring | objectauto / required / { type:"function", function:{name:"..."}}
parallel_tool_callsbooleanWhether to allow parallel tool calls
reasoning_effortstringReasoning effort for o3 / GPT-5: low / medium / high
modalitiesarrayMultimodal output, e.g. ["text","audio"]
audioobjectAudio output options
userstringEnd-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://..."}}
  ]}
]
Supported roles: 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

With stream: 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]
With 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"]
      }
    }
  }]
}
In the response:
{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": null,
      "tool_calls": [{
        "id": "call_abc",
        "type": "function",
        "function": {"name": "get_weather", "arguments": "{\"city\":\"Shanghai\"}"}
      }]
    },
    "finish_reason": "tool_calls"
  }]
}
After executing the tool, append the result to messages:
{"role": "tool", "tool_call_id": "call_abc", "content": "Shanghai is 26°C and clear today"}
Call chat completions again to let the model continue answering based on the tool result.

Reasoning models

For the o3 / GPT-5 series, use reasoning_effort:
{
  "model": "o3-mini-high",
  "messages": [{"role": "user", "content": "Prove that √2 is irrational"}],
  "reasoning_effort": "high",
  "max_completion_tokens": 4096
}
You can also use a suffixed model ID (o3-mini-low / -medium / -high) for the equivalent effect.

Errors

See Error codes for common errors.