ChatCompletions Format
Creates a model response based on conversation history. Supports streaming and non-streaming responses.
Compatible with OpenAI Chat Completions API.
Try It
POST
/v1/chat/completionshttps://api-platform.ope.aiAuthentication
Uses Bearer Token authentication.
- Header:
Authorization: Bearer <token> - Example:
Authorization: Bearer sk-xxxxxx
Request body (application/json)
The following fields are referenced for compatibility with OpenAI Chat Completions API; you can adjust based on OPEAI Platform's actual support scope.
| Field | Type | Required | Description | Default / Range |
|---|---|---|---|---|
model | string | Yes | Model ID | - |
messages | array<object> | Yes | Conversation message list | - |
temperature | number | No | Sampling temperature | Default 1; Range 0~2 |
top_p | number | No | Nucleus sampling parameter | Default 1; Range 0~1 |
n | integer | No | Number of completions to generate | Default 1; Range >=1 |
stream | boolean | No | Whether to stream responses | Default false |
stream_options | object | No | Streaming parameters | - |
stop | string | array<string> | No | Stop sequences | - |
max_tokens | integer | No | Maximum number of tokens to generate | - |
max_completion_tokens | integer | No | Maximum completion tokens | - |
presence_penalty | number | No | Presence penalty | Default 0; Range -2~2 |
frequency_penalty | number | No | Frequency penalty | Default 0; Range -2~2 |
logit_bias | object | No | Logit bias | - |
user | string | No | End-user identifier | - |
tools | array<object> | No | Tools list | - |
tool_choice | string | object | No | Tool choice strategy | - |
response_format | object | No | Response format | - |
seed | integer | No | Random seed | - |
reasoning_effort | "low" | "medium" | "high" | No | Reasoning effort (for models that support reasoning) | - |
modalities | array<string> | No | Output modalities | - |
audio | object | No | Audio output configuration | - |
Request examples
The domain below is an example:
https://api-platform.ope.ai.
- cURL
- JavaScript
- Go
- Python
- Java
- C#
curl -X POST "https://api-platform.ope.ai/v1/chat/completions" \
-H "Authorization: Bearer $OPEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "DeepSeek-V3.2",
"messages": [
{
"role": "user",
"content": "hello"
}
]
}'
const url = "https://api-platform.ope.ai/v1/chat/completions";
const apiKey = process.env.OPEAI_API_KEY;
const res = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "DeepSeek-V3.2",
messages: [{ role: "user", content: "hello" }],
}),
});
console.log(await res.json());
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"model":"DeepSeek-V3.2","messages":[{"role":"user","content":"hello"}]}`)
req, _ := http.NewRequest("POST", "https://api-platform.ope.ai/v1/chat/completions", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPEAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}
import os
import requests
resp = requests.post(
"https://api-platform.ope.ai/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.environ.get('OPEAI_API_KEY')}",
"Content-Type": "application/json",
},
json={
"model": "DeepSeek-V3.2",
"messages": [{"role": "user", "content": "hello"}],
},
timeout=60,
)
print(resp.json())
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("OPEAI_API_KEY");
String url = "https://api-platform.ope.ai/v1/chat/completions";
String json = """
{
"model": "DeepSeek-V3.2",
"messages": [
{ "role": "user", "content": "hello" }
]
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
public class Program
{
public static async Task Main()
{
var apiKey = Environment.GetEnvironmentVariable("OPEAI_API_KEY");
var url = "https://api-platform.ope.ai/v1/chat/completions";
var json = """
{
"model": "DeepSeek-V3.2",
"messages": [
{ "role": "user", "content": "hello" }
]
}
""";
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var resp = await http.PostAsync(url, content);
Console.WriteLine((int)resp.StatusCode);
Console.WriteLine(await resp.Content.ReadAsStringAsync());
}
}
Response examples
- 200
- 400
- 429
{
"id": "string",
"object": "chat.completion",
"created": 0,
"model": "string",
"choices": [
{
"index": 0,
"message": {
"role": "system",
"content": "string",
"name": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": { "name": "string", "arguments": "string" }
}
],
"tool_call_id": "string",
"reasoning_content": "string"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 0,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0
}
},
"system_fingerprint": "string"
}
{
"error": { "message": "string", "type": "string", "param": "string", "code": "string" }
}
{
"error": { "message": "string", "type": "string", "param": "string", "code": "string" }
}