1. Overview
This site provides compatibility with the OpenAI Chat Completions (/v1/chat/completions) format. For code already working with the official OpenAI SDK or OpenAI-compatible clients, simply point the request URL to our gateway's OpenAI endpoint and replace your api_key with a site-generated sk- key. All other invocation methods remain the same.
Currently available GPT-series models are listed in the Model Marketplace (e.g., gpt-5.5, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna, etc.). The full list and unit pricing can be queried via GET /v1/models.
2. API Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /v1/chat/completions | Chat completion (non-streaming / streaming), request body uses OpenAI payload |
| GET | /v1/models | List of models and unit prices (no authentication required) |
Gateway URL: https://www.relay-api.com. For OpenAI-compatible calls, send your requests to POST https://www.relay-api.com/v1, keeping the original paths.
3. Authentication
Authorization: Bearer sk-your-api-key
Create a key starting with sk- in "User Center → API Keys". Use the same authentication header as the official OpenAI standard; the SDK will automatically add the Authorization header.
4. Quick Start
4.1 curl (Non-streaming)
curl -X POST https://www.relay-api.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{
"model": "gpt-5.5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Introduce yourself in three sentences."}
],
"temperature": 0.7,
"max_tokens": 512
}'
4.2 OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(
base_url="https://www.relay-api.com/v1",
api_key="sk-your-api-key",
)
resp = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
After setting the base_url to the OpenAI endpoint listed above and replacing the api_key, all other calls are identical to the official SDK.
5. Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model slug, e.g., gpt-5.5 |
| messages | array | Yes | List of messages, elements are {role, content}; role values: system / user / assistant |
| temperature | number | No | Sampling temperature, default 1.0 |
| top_p | number | No | Nucleus sampling, default 1.0 |
| max_tokens | int | No | Maximum output tokens |
| stream | bool | No | Whether to stream the response, default false |
| stop | string / array | No | Stop sequences |
| presence_penalty / frequency_penalty | number | No | Repetition penalty, range -2 to 2 |
6. Response Structure
{
"id": "chatcmpl-123456",
"object": "chat.completion",
"created": 1710000000,
"model": "gpt-5.5",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello! Nice to meet you."},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 12,
"total_tokens": 30
}
}
| Field | Description |
|---|---|
| id | Unique ID for this completion |
| choices[].message | Assistant reply; content contains the text |
| choices[].finish_reason | Stop reason: stop / length / content_filter |
| usage.prompt_tokens | Input token count (basis for billing) |
| usage.completion_tokens | Output token count (basis for billing) |
| usage.total_tokens | Total token count |
7. Streaming Output
Add "stream": true to the request body to return an SSE stream. Each data: line is a chunk:
data: {"id": "chatcmpl-123456", "object": "chat.completion.chunk", "choices": [{"index": 0, "delta": {"role": "assistant"}, "finish_reason": null}]}
data: {"id": "chatcmpl-123456", "object": "chat.completion.chunk", "choices": [{"index": 0, "delta": {"content": "Hello"}, "finish_reason": null}]}
data: {"id": "chatcmpl-123456", "object": "chat.completion.chunk", "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}]}
data: [DONE]
Clients should concatenate the choices[0].delta.content of each chunk to obtain the full response. Receiving [DONE] indicates the end of the stream. When using the OpenAI SDK, setting stream=True handles these events automatically.
8. Common Error Codes
| HTTP Status | Meaning | Suggested Action |
|---|---|---|
| 400 | Invalid request parameters (model missing, empty messages, etc.) | Check request body fields |
| 401 | Invalid or missing API key | Verify Authorization header and key format |
| 403 | Key disabled, insufficient balance, or unauthorized model/route | Top up or check key permissions |
| 404 | Path or model not found | Confirm base_url and model name |
| 429 | Rate limit triggered | Retry with exponential backoff |
| 500 | Internal server error | Retry later; contact support if the issue persists |
Error response body format: {"code": status_code, "message": "error_description", "data": null}.
9. Compatibility Notes
- Supports OpenAI SDK (Python / Node.js, etc.) via custom
base_urlconfiguration. - Supports various OpenAI-compatible clients (LobeChat, ChatBox, NextChat, One API, etc.) by configuring a custom interface address.
- Model names must match the slug returned by
GET /v1/models.
Base URL Note: This site accepts /v1beta/models/... and /v1beta/v1beta/models/... (as well as /v1/... and /v1/v1/...), so whether your client appends /v1 or /v1beta does not affect calls: setting the Base URL to the domain root or an address containing /v1beta will both work. Please query and copy the model ID from the "Model ID" section in the top-right corner of the "Tokens" page in the console.
