OpenAI Chat API
This platform provides a chat endpoint compatible with the OpenAI Chat Completions API.
This document is intended for client-side integrators and focuses on the public request path, authentication method, request parameters, and example payloads. Field names and JSON structure are kept as close as possible to the native OpenAI Chat Completions API.
Overview:
- Endpoint:
POST /v1/chat/completions - Capability type: chat / text generation
- Response modes:
- When
stream = falseor omitted: standard JSON response - When
stream = true:text/event-streamSSE response
- When
- Protocol style: the request body follows the native OpenAI Chat Completions structure and does not wrap content in an extra
inputfield
Current scope:
- Covers only
POST /v1/chat/completions POST /v1/responsesis also supported, but is documented separately at/docs/api-reference/text/openai-response-api- Does not cover other OpenAI endpoints such as embeddings, images, or audio
1. API Overview
- HTTP method:
POST - Request path:
/v1/chat/completions - Content-Type:
application/json - Response type:
- Non-streaming:
application/json - Streaming:
text/event-stream
- Non-streaming:
2. Authentication and Headers
Example headers:
Authorization: Bearer YOUR_REACH_API_KEY
Content-Type: application/jsonAt least one of Authorization or x-api-key must be provided.
Header details:
| Header | Required | Description |
|---|---|---|
Authorization | No | Platform API key in the format Bearer sk-xxxxxx |
x-api-key | No | You can also pass the platform API key directly in this header |
Content-Type | Yes | Must be application/json |
3. Request Body
The request body follows the native OpenAI Chat Completions object structure:
{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Please introduce yourself in one sentence."
}
],
"temperature": 0.2,
"stream": false
}3.1 Top-Level Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID |
messages | array<object> | Yes | Chat message list, at least one item |
temperature | number | No | Sampling temperature |
top_p | number | No | Nucleus sampling parameter |
n | integer | No | Number of candidate results |
max_tokens | integer | No | Maximum number of output tokens |
max_completion_tokens | integer | No | New output token limit supported by some models |
stop | string or array<string> | No | Stop sequences |
stream | boolean | No | Whether to return SSE streaming output |
stream_options | object | No | Additional streaming configuration such as include_usage |
tools | array<object> | No | Tool definitions |
tool_choice | string or object | No | Tool calling strategy |
parallel_tool_calls | boolean | No | Whether parallel tool calls are allowed |
response_format | object | No | Structured output configuration |
presence_penalty | number | No | Penalty for topic novelty |
frequency_penalty | number | No | Repetition penalty |
logit_bias | object | No | Token bias configuration |
user | string | No | End-user identifier |
3.2 messages Parameter
Each message uses the following structure:
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | Role. Common values: system, user, assistant, tool |
content | string or array<object> | Yes | Message content. Can be plain text or an array of content blocks |
name | string | No | Optional role name |
tool_call_id | string | No | Used to associate tool calls when role = tool |
Text example:
{
"role": "user",
"content": "Write a product introduction in no more than 50 words."
}Content block example:
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please describe this image."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.example.com/demo.png"
}
}
]
}4. Request Examples
4.1 Standard Non-Streaming Request
curl -X POST "https://direct.reachapi.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Introduce ReachAPI in one sentence."
}
],
"temperature": 0.2
}'4.2 Streaming Request
curl -X POST "https://direct.reachapi.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Summarize today'\''s priorities in three lines."
}
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'4.3 Request with Tool Definitions
curl -X POST "https://direct.reachapi.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Help me check the weather in Shanghai."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather information for a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}'5. Successful Response
Example non-streaming response:
{
"id": "chatcmpl_123",
"object": "chat.completion",
"created": 1710000000,
"model": "YOUR_MODEL_ID",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello, I am a model-powered assistant."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 18,
"total_tokens": 30
}
}6. Streaming Response
When stream = true, the endpoint returns OpenAI-style SSE events:
data: {"id":"chatcmpl_123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":""}}]}
data: {"id":"chatcmpl_123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"}}]}
data: [DONE]7. Error Response
OpenAI-style error example:
{
"error": {
"message": "Field `messages` is required",
"type": "invalid_request_error",
"param": null,
"code": "MISSING_REQUIRED_FIELD"
}
}Common scenarios:
- Missing
modelin the request body - Missing
messagesin the request body - Invalid JSON payload
- Authentication failure
8. Compatibility Notes
- This document lists commonly used fields and example payloads. Actual field names and structures follow the OpenAI Chat Completions API.
- This endpoint only covers the Chat Completions path and does not represent the full OpenAI API surface.
- If you use newer or experimental official fields, validate them against the actual capabilities available on your gateway.
9. Supported Models and Reference Pricing
The following prices are summarized from the unified pricing document and apply to the GPT text models currently listed. Pricing was checked on 2026-04-17. For detailed pricing rules, refer to gpt.md.
| Model | Input | Cached input | Output |
|---|---|---|---|
gpt-5.4 | $2.50 / 1M tokens | $0.25 / 1M tokens | $15.00 / 1M tokens |
gpt-5.3-codex | $1.75 / 1M tokens | $0.175 / 1M tokens | $14.00 / 1M tokens |
gpt-5.2 | $1.75 / 1M tokens | $0.175 / 1M tokens | $14.00 / 1M tokens |
gpt-5.1-codex | $1.25 / 1M tokens | $0.125 / 1M tokens | $10.00 / 1M tokens |
gpt-5.1 | $1.25 / 1M tokens | $0.125 / 1M tokens | $10.00 / 1M tokens |
gpt-5 | $1.25 / 1M tokens | $0.125 / 1M tokens | $10.00 / 1M tokens |
gpt-5.4-mini | $0.75 / 1M tokens | $0.075 / 1M tokens | $4.50 / 1M tokens |
gpt-5-mini | $0.25 / 1M tokens | $0.025 / 1M tokens | $2.00 / 1M tokens |
Notes:
Cached inputrefers to the unit price for cache-hit input tokens- If the model list changes over time, use the dashboard or product configuration as the source of truth for currently enabled models
10. References
- OpenAI Chat Completions API: https://platform.openai.com/docs/api-reference/chat/create
- OpenAI text generation guide: https://platform.openai.com/docs/guides/text?api-mode=chat
- OpenAI API errors: https://platform.openai.com/docs/guides/error-codes/api-errors
- Unified platform pricing document:
gpt.md