curl https://aireiter.com/api/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{"role": "user", "content": "Hello, world"}
]
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[
{"role": "user", "content": "Hello, world"}
]
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.API_KEY,
baseURL: 'https://aireiter.com/api/v1'
});
const response = await client.chat.completions.create({
model: 'claude-sonnet-4-5-20250929',
messages: [
{ role: 'user', content: 'Hello, world' }
]
});
console.log(response.choices[0].message.content);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
url := "https://aireiter.com/api/v1/chat/completions"
payload := map[string]interface{}{
"model": "claude-sonnet-4-5-20250929",
"messages": []map[string]string{
{"role": "user", "content": "Hello, world"},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+os.Getenv("API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://aireiter.com/api/v1/chat/completions";
String apiKey = System.getenv("API_KEY");
String payload = """
{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{"role": "user", "content": "Hello, world"}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://aireiter.com/api/v1/chat/completions";
$apiKey = getenv('API_KEY');
$payload = [
"model" => "claude-sonnet-4-5-20250929",
"messages" => [
["role" => "user", "content" => "Hello, world"]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://aireiter.com/api/v1/chat/completions")
api_key = ENV['API_KEY']
payload = {
model: "claude-sonnet-4-5-20250929",
messages: [{ role: "user", content: "Hello, world" }]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = payload.to_json
puts http.request(request).body
import Foundation
let url = URL(string: "https://aireiter.com/api/v1/chat/completions")!
let apiKey = ProcessInfo.processInfo.environment["API_KEY"] ?? ""
let payload: [String: Any] = [
"model": "claude-sonnet-4-5-20250929",
"messages": [["role": "user", "content": "Hello, world"]]
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
URLSession.shared.dataTask(with: request) { data, _, _ in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://aireiter.com/api/v1/chat/completions";
var apiKey = Environment.GetEnvironmentVariable("API_KEY");
var payload = @"{
""model"": ""claude-sonnet-4-5-20250929"",
""messages"": [
{""role"": ""user"", ""content"": ""Hello, world""}
]
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
CURL *curl;
const char *api_key = getenv("API_KEY");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
const char *payload =
"{\"model\":\"claude-sonnet-4-5-20250929\","
"\"messages\":[{\"role\":\"user\",\"content\":\"Hello, world\"}]}";
char auth_header[256];
snprintf(auth_header, sizeof(auth_header), "Authorization: Bearer %s", api_key);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, auth_header);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://aireiter.com/api/v1/chat/completions");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://aireiter.com/api/v1/chat/completions');
final apiKey = Platform.environment['API_KEY']!;
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'claude-sonnet-4-5-20250929',
'messages': [{'role': 'user', 'content': 'Hello, world'}],
}),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://aireiter.com/api/v1/chat/completions"
api_key <- Sys.getenv("API_KEY")
response <- POST(
url,
add_headers(
`Authorization` = paste("Bearer", api_key),
`Content-Type` = "application/json"
),
body = toJSON(list(
model = "claude-sonnet-4-5-20250929",
messages = list(list(role = "user", content = "Hello, world"))
), auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"id": "chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b",
"object": "chat.completion",
"created": 1741680000,
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 15,
"total_tokens": 27
}
}
{
"id": "chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b",
"object": "chat.completion",
"created": 1741680000,
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_01A09q90qw90lq917835lq9",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\": \"Beijing\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 85,
"completion_tokens": 22,
"total_tokens": 107
}
}
{
"error": {
"message": "messages is required and must not be empty",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Insufficient credits",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Model 'xxx' not found",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "All providers failed",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
OpenAI Chat Completions API
OpenAI Chat Completions API
- Fully compatible with OpenAI Chat Completions API format
- Supports multi-turn conversations, tool calls, structured output, and streaming responses
- Can directly replace the
baseURLof the OpenAI SDK without modifying other code
POST
/
api
/
v1
/
chat
/
completions
curl https://aireiter.com/api/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{"role": "user", "content": "Hello, world"}
]
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[
{"role": "user", "content": "Hello, world"}
]
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.API_KEY,
baseURL: 'https://aireiter.com/api/v1'
});
const response = await client.chat.completions.create({
model: 'claude-sonnet-4-5-20250929',
messages: [
{ role: 'user', content: 'Hello, world' }
]
});
console.log(response.choices[0].message.content);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
url := "https://aireiter.com/api/v1/chat/completions"
payload := map[string]interface{}{
"model": "claude-sonnet-4-5-20250929",
"messages": []map[string]string{
{"role": "user", "content": "Hello, world"},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+os.Getenv("API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://aireiter.com/api/v1/chat/completions";
String apiKey = System.getenv("API_KEY");
String payload = """
{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{"role": "user", "content": "Hello, world"}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://aireiter.com/api/v1/chat/completions";
$apiKey = getenv('API_KEY');
$payload = [
"model" => "claude-sonnet-4-5-20250929",
"messages" => [
["role" => "user", "content" => "Hello, world"]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://aireiter.com/api/v1/chat/completions")
api_key = ENV['API_KEY']
payload = {
model: "claude-sonnet-4-5-20250929",
messages: [{ role: "user", content: "Hello, world" }]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = payload.to_json
puts http.request(request).body
import Foundation
let url = URL(string: "https://aireiter.com/api/v1/chat/completions")!
let apiKey = ProcessInfo.processInfo.environment["API_KEY"] ?? ""
let payload: [String: Any] = [
"model": "claude-sonnet-4-5-20250929",
"messages": [["role": "user", "content": "Hello, world"]]
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
URLSession.shared.dataTask(with: request) { data, _, _ in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://aireiter.com/api/v1/chat/completions";
var apiKey = Environment.GetEnvironmentVariable("API_KEY");
var payload = @"{
""model"": ""claude-sonnet-4-5-20250929"",
""messages"": [
{""role"": ""user"", ""content"": ""Hello, world""}
]
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
CURL *curl;
const char *api_key = getenv("API_KEY");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
const char *payload =
"{\"model\":\"claude-sonnet-4-5-20250929\","
"\"messages\":[{\"role\":\"user\",\"content\":\"Hello, world\"}]}";
char auth_header[256];
snprintf(auth_header, sizeof(auth_header), "Authorization: Bearer %s", api_key);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, auth_header);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://aireiter.com/api/v1/chat/completions");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://aireiter.com/api/v1/chat/completions');
final apiKey = Platform.environment['API_KEY']!;
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'claude-sonnet-4-5-20250929',
'messages': [{'role': 'user', 'content': 'Hello, world'}],
}),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://aireiter.com/api/v1/chat/completions"
api_key <- Sys.getenv("API_KEY")
response <- POST(
url,
add_headers(
`Authorization` = paste("Bearer", api_key),
`Content-Type` = "application/json"
),
body = toJSON(list(
model = "claude-sonnet-4-5-20250929",
messages = list(list(role = "user", content = "Hello, world"))
), auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"id": "chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b",
"object": "chat.completion",
"created": 1741680000,
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 15,
"total_tokens": 27
}
}
{
"id": "chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b",
"object": "chat.completion",
"created": 1741680000,
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_01A09q90qw90lq917835lq9",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\": \"Beijing\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 85,
"completion_tokens": 22,
"total_tokens": 107
}
}
{
"error": {
"message": "messages is required and must not be empty",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Insufficient credits",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Model 'xxx' not found",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "All providers failed",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
Authorizations
string
required
API key in Bearer Token formatGet the API key:Visit the API Key management page to get your API key
Authorization: Bearer YOUR_API_KEY
Body
string
required
Model nameOpenAI compatible models (recommended for tool calls):
gpt-4o-mini— lightweight and fast, suitable for high-frequency simple tasksgpt-4o— general recommendation, balanced performance and costgpt-5.2— high-performance version, full support for tool calls- For more models, please refer to
GET /api/v1/models
claude-haiku-4-5-20251001— lightweight and fastclaude-sonnet-4-5-20250929— general recommendationclaude-sonnet-4-6— new Sonnet versionclaude-opus-4-5-20251101— flagship inference modelclaude-opus-4-6— new Opus version, most powerful
GET /api/v1/modelsarray
required
Message listThe model generates the next reply based on the message history. Each message includes
Plain text message:Multi-turn conversation:Multi-turn tool calls:
role and content.Show Field Description
Show Field Description
[{"role": "user", "content": "Hello"}]
[
{"role": "system", "content": "You are a professional code reviewer."},
{"role": "user", "content": "Please review this code snippet."},
{"role": "assistant", "content": "Let me analyze it..."},
{"role": "user", "content": "Are there any performance issues?"}
]
[
{"role": "user", "content": "What is the weather in Beijing today?"},
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_001",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\": \"Beijing\"}"}
}
]
},
{
"role": "tool",
"tool_call_id": "call_001",
"content": "Beijing: 25°C, sunny"
}
]
integer
Maximum output token countControls the maximum number of tokens the model can generate; the model may naturally stop before reaching the limit. Minimum value:
1.
No limit by default (subject to model context window constraints).integer
Maximum output token count (new name for
max_tokens)Equivalent to max_tokens; provide either one, with max_tokens having higher priority.boolean
Whether to enable streaming outputWhen set to
true, responses are streamed in real-time via SSE (Server-Sent Events). Default is true. To disable streaming, explicitly pass "stream": false.When set to false, the full response is returned after generation completes.number
Temperature, range
0–2- Low values (e.g.,
0.2): more deterministic, conservative output - High values (e.g.,
0.8): more random, creative output
1.0. Not recommended to use with top_p simultaneously.number
Nucleus sampling parameter, range
0–1Samples from tokens with cumulative probability up to top_p. Default is 1.0.
Not recommended to use with temperature simultaneously.number
Frequency penalty, range
-2.0–2.0Positive values penalize tokens appearing frequently in generated text, reducing repetition. Default is 0.number
Presence penalty, range
-2.0–2.0Positive values penalize tokens that have appeared before, encouraging the model to explore new topics. Default is 0.integer
Random seedWhen set, the same seed plus identical request parameters will attempt to produce deterministic output for reproducibility.
string | array
Stop sequencesThe model will immediately stop generation upon encountering this string (or any string in the array). Up to 4 allowed.
{"stop": ["\n\nUser:", "###END###"]}
array
Tool definitions listDefines function tools callable by the model, each with a name, description, and parameter JSON Schema.
{
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather of a specified city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name, e.g., Beijing"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["city"]
}
}
}
]
}
string | object
Tool selection policy
"auto"— the model decides whether to call tools (default)"required"— force the model to call a tool"none"— prohibit calling any tools{"type": "function", "function": {"name": "get_weather"}}— force call a specified tool
{"tool_choice": "required"}
boolean
Whether to allow parallel tool callsWhen set to
false, only one tool is called at a time. Default is true (allow parallel calls).object
Response formatControls the model’s output format.
JSON object mode:JSON Schema mode:
Show Field Description
Show Field Description
string
required
Format type
"text"— plain text (default)"json_object"— JSON object, the model returns valid JSON"json_schema"— output strictly according to a specified JSON Schema
{"response_format": {"type": "json_object"}}
{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "analysis_result",
"strict": true,
"schema": {
"type": "object",
"properties": {
"summary": {"type": "string"},
"score": {"type": "number"},
"tags": {"type": "array", "items": {"type": "string"}}
},
"required": ["summary", "score", "tags"]
}
}
}
}
string
Reasoning effortApplicable to models that support reasoning (such as
gpt-5.2 and above), controls the depth of model reasoning."low"— fast reasoning, saves tokens"medium"— balanced reasoning"high"— deep reasoning, more accurate but consumes more tokens
Response
string
Completion unique identifierExample:
"chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b"string
Object type, fixed to
"chat.completion" (non-streaming) or "chat.completion.chunk" (streaming)integer
Creation time, Unix timestamp (seconds)
string
Model name passed in the request
string
Billing task ID (project extension field), used to track the credit consumption record for this call
array
Array of generated results (always only 1 item)
Show Field Description
Show Field Description
integer
Result index, always
0object
Complete message object in non-streaming response
role— fixed to"assistant"content— text content (nullwhen tool calls are made)tool_calls— list of tool calls (present if there are tool calls)
object
Incremental content in streaming response
- First frame:
{"role": "assistant"} - Text frame:
{"content": "..."} - Tool call frame:
{"tool_calls": [{"index": 0, "id": "...", "type": "function", "function": {"name": "...", "arguments": ""}}]} - Final frame:
{}
string
Reason for stopping
"stop"— natural end"length"— reachedmax_tokenslimit"tool_calls"— model requested a tool call"content_filter"— content filtering
object
curl https://aireiter.com/api/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{"role": "user", "content": "Hello, world"}
]
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[
{"role": "user", "content": "Hello, world"}
]
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.API_KEY,
baseURL: 'https://aireiter.com/api/v1'
});
const response = await client.chat.completions.create({
model: 'claude-sonnet-4-5-20250929',
messages: [
{ role: 'user', content: 'Hello, world' }
]
});
console.log(response.choices[0].message.content);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
url := "https://aireiter.com/api/v1/chat/completions"
payload := map[string]interface{}{
"model": "claude-sonnet-4-5-20250929",
"messages": []map[string]string{
{"role": "user", "content": "Hello, world"},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+os.Getenv("API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://aireiter.com/api/v1/chat/completions";
String apiKey = System.getenv("API_KEY");
String payload = """
{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{"role": "user", "content": "Hello, world"}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://aireiter.com/api/v1/chat/completions";
$apiKey = getenv('API_KEY');
$payload = [
"model" => "claude-sonnet-4-5-20250929",
"messages" => [
["role" => "user", "content" => "Hello, world"]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://aireiter.com/api/v1/chat/completions")
api_key = ENV['API_KEY']
payload = {
model: "claude-sonnet-4-5-20250929",
messages: [{ role: "user", content: "Hello, world" }]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = payload.to_json
puts http.request(request).body
import Foundation
let url = URL(string: "https://aireiter.com/api/v1/chat/completions")!
let apiKey = ProcessInfo.processInfo.environment["API_KEY"] ?? ""
let payload: [String: Any] = [
"model": "claude-sonnet-4-5-20250929",
"messages": [["role": "user", "content": "Hello, world"]]
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
URLSession.shared.dataTask(with: request) { data, _, _ in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://aireiter.com/api/v1/chat/completions";
var apiKey = Environment.GetEnvironmentVariable("API_KEY");
var payload = @"{
""model"": ""claude-sonnet-4-5-20250929"",
""messages"": [
{""role"": ""user"", ""content"": ""Hello, world""}
]
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
CURL *curl;
const char *api_key = getenv("API_KEY");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
const char *payload =
"{\"model\":\"claude-sonnet-4-5-20250929\","
"\"messages\":[{\"role\":\"user\",\"content\":\"Hello, world\"}]}";
char auth_header[256];
snprintf(auth_header, sizeof(auth_header), "Authorization: Bearer %s", api_key);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, auth_header);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://aireiter.com/api/v1/chat/completions");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://aireiter.com/api/v1/chat/completions');
final apiKey = Platform.environment['API_KEY']!;
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'claude-sonnet-4-5-20250929',
'messages': [{'role': 'user', 'content': 'Hello, world'}],
}),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://aireiter.com/api/v1/chat/completions"
api_key <- Sys.getenv("API_KEY")
response <- POST(
url,
add_headers(
`Authorization` = paste("Bearer", api_key),
`Content-Type` = "application/json"
),
body = toJSON(list(
model = "claude-sonnet-4-5-20250929",
messages = list(list(role = "user", content = "Hello, world"))
), auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"id": "chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b",
"object": "chat.completion",
"created": 1741680000,
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 15,
"total_tokens": 27
}
}
{
"id": "chatcmpl-9vKqnMf3Ax8ZpRdTw2LsYe7b",
"object": "chat.completion",
"created": 1741680000,
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_01A09q90qw90lq917835lq9",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\": \"Beijing\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 85,
"completion_tokens": 22,
"total_tokens": 107
}
}
{
"error": {
"message": "messages is required and must not be empty",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Insufficient credits",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "Model 'xxx' not found",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
{
"error": {
"message": "All providers failed",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
Usage Examples
Basic Conversation
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[
{"role": "user", "content": "Implement quicksort in Python"}
]
)
print(response.choices[0].message.content)
System Prompt + Multi-turn Conversation
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[
{"role": "system", "content": "You are a senior Python developer expert specializing in code review and performance optimization."},
{"role": "user", "content": "What is the GIL?"},
{"role": "assistant", "content": "GIL (Global Interpreter Lock) is..."},
{"role": "user", "content": "How to bypass the GIL for true parallelism?"}
],
temperature=0.3
)
Streaming Response
stream = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[{"role": "user", "content": "Write a technical blog about quantum computing"}],
stream=True
)
for chunk in stream:
delta = chunk.choices[0].delta
if delta.content:
print(delta.content, end="", flush=True)
Tool Invocation (Complete Multi-turn Flow)
import json
tools = [
{
"type": "function",
"function": {
"name": "get_stock_price",
"description": "Get real-time stock price",
"parameters": {
"type": "object",
"properties": {
"ticker": {"type": "string", "description": "Stock symbol, e.g., AAPL"}
},
"required": ["ticker"]
}
}
}
]
messages = [{"role": "user", "content": "What is Tesla's stock price?"}]
# First round: model decides to call a tool
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=messages,
tools=tools
)
# Handle tool invocation
if response.choices[0].finish_reason == "tool_calls":
tool_call = response.choices[0].message.tool_calls[0]
# Execute the tool (business logic)
tool_result = {"price": 245.80, "currency": "USD"}
# Second round: return the result to the model
messages += [
response.choices[0].message,
{
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps(tool_result)
}
]
final = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=messages,
tools=tools
)
print(final.choices[0].message.content)
Structured Output (JSON Schema)
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[
{"role": "user", "content": "Analyze the sentiment of the following product review: 'These headphones have great sound quality but average battery life'"}
],
response_format={
"type": "json_schema",
"json_schema": {
"name": "sentiment_analysis",
"strict": True,
"schema": {
"type": "object",
"properties": {
"sentiment": {"type": "string", "enum": ["positive", "negative", "mixed"]},
"score": {"type": "number", "description": "Sentiment score from -1.0 to 1.0"},
"highlights": {"type": "array", "items": {"type": "string"}}
},
"required": ["sentiment", "score", "highlights"]
}
}
}
)
result = json.loads(response.choices[0].message.content)
print(result)
# {"sentiment": "mixed", "score": 0.2, "highlights": ["great sound quality", "average battery life"]}
Sampling Parameter Control
# Creative writing: high temperature + frequency penalty
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[{"role": "user", "content": "Write a modern poem about autumn"}],
temperature=0.9,
frequency_penalty=0.5,
presence_penalty=0.3
)
# Precise output: low temperature + fixed seed
response = client.chat.completions.create(
model="claude-sonnet-4-5-20250929",
messages=[{"role": "user", "content": "Calculate the result of 1234 × 5678"}],
temperature=0.0,
seed=42
)
Streaming Response Event Format
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","task_id":"task_abc123","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":5,"total_tokens":17}}
data: [DONE]
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_abc","type":"function","function":{"name":"get_weather","arguments":""}}]},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"city\""}}]},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":": \"Beijing\"}"}}]},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1741680000,"model":"claude-sonnet-4-5-20250929","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":85,"completion_tokens":22,"total_tokens":107}}
data: [DONE]
Notes
-
Authorization method: Only supports the format
Authorization: Bearer <api_key>. When using the OpenAI SDK, simply set theapi_key. -
Streaming by default: The
streamparameter defaults totrue. For non-streaming responses, explicitly pass"stream": false. -
Insufficient balance: Returns HTTP
402when the balance is insufficient. Please recharge and try again. -
stop and stop sequences: The
stopparameter is currently ineffective. The underlying providers do not support this feature yet; passing the parameter will not cause errors but will not stop generation at specified sequences. -
Note on response_format: Current underlying providers have limited support for
response_format—injson_objectmode, the model may still output Markdown code blocks instead of pure JSON; injson_schemamode, the schema constraints may not be enforced. For structured output, it is recommended to clearly specify the required format in the prompt. -
Tool parameters: The
parametersfield must be a valid JSON Schema, and therequiredarray determines which parameters are mandatory. -
Model selection recommendations:
- Haiku — high-frequency simple Q&A, lowest cost
- Sonnet — code generation, document processing, generally recommended
- Opus — complex reasoning, long text analysis, strongest capabilities
-thinkingseries — for scenarios requiring deep thinking such as mathematical proofs and logical deductions
⌘I