curl -X POST https://aireiter.com/api/v1/responses \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": true
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.responses.create(
model="claude-sonnet-4-5-20250929",
input="Write a one-sentence bedtime story about a unicorn."
)
print(response.output_text)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://aireiter.com/api/v1",
});
const response = await client.responses.create({
model: "claude-sonnet-4-5-20250929",
input: "Write a one-sentence bedtime story about a unicorn.",
});
console.log(response.output_text);
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": false,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://aireiter.com/api/v1/responses", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.*;
import java.util.Map;
public class ResponsesExample {
public static void main(String[] args) throws Exception {
var payload = Map.of(
"model", "claude-sonnet-4-5-20250929",
"input", "Write a one-sentence bedtime story about a unicorn.",
"stream", false
);
var body = new ObjectMapper().writeValueAsString(payload);
var request = HttpRequest.newBuilder()
.uri(URI.create("https://aireiter.com/api/v1/responses"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$client = new GuzzleHttp\Client();
$response = $client->post('https://aireiter.com/api/v1/responses', [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY',
'Content-Type' => 'application/json',
],
'json' => [
'model' => 'claude-sonnet-4-5-20250929',
'input' => 'Write a one-sentence bedtime story about a unicorn.',
'stream' => false,
],
]);
echo $response->getBody();
require 'net/http'
require 'json'
uri = URI('https://aireiter.com/api/v1/responses')
req = Net::HTTP::Post.new(uri, {
'Authorization' => 'Bearer YOUR_API_KEY',
'Content-Type' => 'application/json'
})
req.body = {
model: 'claude-sonnet-4-5-20250929',
input: 'Write a one-sentence bedtime story about a unicorn.',
stream: false
}.to_json
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
puts res.body
import Foundation
let payload: [String: Any] = [
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": false
]
var request = URLRequest(url: URL(string: "https://aireiter.com/api/v1/responses")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_API_KEY", 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.Net.Http;
using System.Net.Http.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
var response = await client.PostAsJsonAsync("https://aireiter.com/api/v1/responses", new {
model = "claude-sonnet-4-5-20250929",
input = "Write a one-sentence bedtime story about a unicorn.",
stream = false
});
Console.WriteLine(await response.Content.ReadAsStringAsync());
#include <stdio.h>
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
headers = curl_slist_append(headers, "Content-Type: application/json");
const char *data = "{\"model\":\"claude-sonnet-4-5-20250929\","
"\"input\":\"Write a one-sentence bedtime story about a unicorn.\","
"\"stream\":false}";
curl_easy_setopt(curl, CURLOPT_URL, "https://aireiter.com/api/v1/responses");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
return 0;
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final response = await http.post(
Uri.parse('https://aireiter.com/api/v1/responses'),
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'claude-sonnet-4-5-20250929',
'input': 'Write a one-sentence bedtime story about a unicorn.',
'stream': false,
}),
);
print(response.body);
}
library(httr)
library(jsonlite)
response <- POST(
"https://aireiter.com/api/v1/responses",
add_headers(
Authorization = "Bearer YOUR_API_KEY",
`Content-Type` = "application/json"
),
body = toJSON(list(
model = "claude-sonnet-4-5-20250929",
input = "Write a one-sentence bedtime story about a unicorn.",
stream = FALSE
), auto_unbox = TRUE)
)
content(response, "text")
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0123",
"object": "response",
"created_at": 1742000000.123,
"status": "completed",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_xyz123",
"output": [
{
"id": "msg_AbCdEfGhIjKl0123",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "The little unicorn tiptoed through the moonlit meadow, leaving a trail of shimmering stardust as she galloped home to her cozy cloud.",
"annotations": []
}
]
}
],
"output_text": "The little unicorn tiptoed through the moonlit meadow, leaving a trail of shimmering stardust as she galloped home to her cozy cloud.",
"usage": {
"input_tokens": 20,
"output_tokens": 35,
"total_tokens": 55,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0456",
"object": "response",
"created_at": 1742000100.456,
"status": "completed",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc456",
"output": [
{
"id": "fc_AbCdEfGhIjKl0456",
"type": "function_call",
"call_id": "call_AbCdEfGh",
"name": "get_weather",
"arguments": "{\"location\":\"San Francisco\",\"unit\":\"celsius\"}"
}
],
"output_text": "",
"usage": {
"input_tokens": 80,
"output_tokens": 25,
"total_tokens": 105,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0789",
"object": "response",
"created_at": 1742000200.789,
"status": "incomplete",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_def789",
"output": [
{
"id": "msg_AbCdEfGhIjKl0789",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "Here is a very long story that was cut off due to max_output_tokens...",
"annotations": []
}
]
}
],
"output_text": "Here is a very long story that was cut off due to max_output_tokens...",
"incomplete_details": {
"reason": "max_output_tokens"
},
"usage": {
"input_tokens": 15,
"output_tokens": 256,
"total_tokens": 271,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "model is required"
}
}
{
"type": "error",
"error": {
"type": "authentication_error",
"message": "Invalid API key"
}
}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Insufficient credits"
}
}
{
"type": "error",
"error": {
"type": "not_found_error",
"message": "Model 'unknown-model' not found"
}
}
{
"type": "error",
"error": {
"type": "api_error",
"message": "All providers failed"
}
}
OpenAI Responses API
OpenAI Responses API
- Compatible with OpenAI Responses API protocol, supporting text conversation, image understanding, tool invocation, structured output, and reasoning mode
- Mainly used by tools such as Codex CLI and AI SDK
POST
/
api
/
v1
/
responses
curl -X POST https://aireiter.com/api/v1/responses \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": true
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.responses.create(
model="claude-sonnet-4-5-20250929",
input="Write a one-sentence bedtime story about a unicorn."
)
print(response.output_text)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://aireiter.com/api/v1",
});
const response = await client.responses.create({
model: "claude-sonnet-4-5-20250929",
input: "Write a one-sentence bedtime story about a unicorn.",
});
console.log(response.output_text);
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": false,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://aireiter.com/api/v1/responses", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.*;
import java.util.Map;
public class ResponsesExample {
public static void main(String[] args) throws Exception {
var payload = Map.of(
"model", "claude-sonnet-4-5-20250929",
"input", "Write a one-sentence bedtime story about a unicorn.",
"stream", false
);
var body = new ObjectMapper().writeValueAsString(payload);
var request = HttpRequest.newBuilder()
.uri(URI.create("https://aireiter.com/api/v1/responses"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$client = new GuzzleHttp\Client();
$response = $client->post('https://aireiter.com/api/v1/responses', [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY',
'Content-Type' => 'application/json',
],
'json' => [
'model' => 'claude-sonnet-4-5-20250929',
'input' => 'Write a one-sentence bedtime story about a unicorn.',
'stream' => false,
],
]);
echo $response->getBody();
require 'net/http'
require 'json'
uri = URI('https://aireiter.com/api/v1/responses')
req = Net::HTTP::Post.new(uri, {
'Authorization' => 'Bearer YOUR_API_KEY',
'Content-Type' => 'application/json'
})
req.body = {
model: 'claude-sonnet-4-5-20250929',
input: 'Write a one-sentence bedtime story about a unicorn.',
stream: false
}.to_json
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
puts res.body
import Foundation
let payload: [String: Any] = [
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": false
]
var request = URLRequest(url: URL(string: "https://aireiter.com/api/v1/responses")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_API_KEY", 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.Net.Http;
using System.Net.Http.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
var response = await client.PostAsJsonAsync("https://aireiter.com/api/v1/responses", new {
model = "claude-sonnet-4-5-20250929",
input = "Write a one-sentence bedtime story about a unicorn.",
stream = false
});
Console.WriteLine(await response.Content.ReadAsStringAsync());
#include <stdio.h>
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
headers = curl_slist_append(headers, "Content-Type: application/json");
const char *data = "{\"model\":\"claude-sonnet-4-5-20250929\","
"\"input\":\"Write a one-sentence bedtime story about a unicorn.\","
"\"stream\":false}";
curl_easy_setopt(curl, CURLOPT_URL, "https://aireiter.com/api/v1/responses");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
return 0;
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final response = await http.post(
Uri.parse('https://aireiter.com/api/v1/responses'),
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'claude-sonnet-4-5-20250929',
'input': 'Write a one-sentence bedtime story about a unicorn.',
'stream': false,
}),
);
print(response.body);
}
library(httr)
library(jsonlite)
response <- POST(
"https://aireiter.com/api/v1/responses",
add_headers(
Authorization = "Bearer YOUR_API_KEY",
`Content-Type` = "application/json"
),
body = toJSON(list(
model = "claude-sonnet-4-5-20250929",
input = "Write a one-sentence bedtime story about a unicorn.",
stream = FALSE
), auto_unbox = TRUE)
)
content(response, "text")
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0123",
"object": "response",
"created_at": 1742000000.123,
"status": "completed",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_xyz123",
"output": [
{
"id": "msg_AbCdEfGhIjKl0123",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "The little unicorn tiptoed through the moonlit meadow, leaving a trail of shimmering stardust as she galloped home to her cozy cloud.",
"annotations": []
}
]
}
],
"output_text": "The little unicorn tiptoed through the moonlit meadow, leaving a trail of shimmering stardust as she galloped home to her cozy cloud.",
"usage": {
"input_tokens": 20,
"output_tokens": 35,
"total_tokens": 55,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0456",
"object": "response",
"created_at": 1742000100.456,
"status": "completed",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc456",
"output": [
{
"id": "fc_AbCdEfGhIjKl0456",
"type": "function_call",
"call_id": "call_AbCdEfGh",
"name": "get_weather",
"arguments": "{\"location\":\"San Francisco\",\"unit\":\"celsius\"}"
}
],
"output_text": "",
"usage": {
"input_tokens": 80,
"output_tokens": 25,
"total_tokens": 105,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0789",
"object": "response",
"created_at": 1742000200.789,
"status": "incomplete",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_def789",
"output": [
{
"id": "msg_AbCdEfGhIjKl0789",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "Here is a very long story that was cut off due to max_output_tokens...",
"annotations": []
}
]
}
],
"output_text": "Here is a very long story that was cut off due to max_output_tokens...",
"incomplete_details": {
"reason": "max_output_tokens"
},
"usage": {
"input_tokens": 15,
"output_tokens": 256,
"total_tokens": 271,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "model is required"
}
}
{
"type": "error",
"error": {
"type": "authentication_error",
"message": "Invalid API key"
}
}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Insufficient credits"
}
}
{
"type": "error",
"error": {
"type": "not_found_error",
"message": "Model 'unknown-model' not found"
}
}
{
"type": "error",
"error": {
"type": "api_error",
"message": "All providers failed"
}
}
Authorization
string
required
Bearer Token authentication. Format:
Authorization: Bearer <api-key>Get API Key:Visit the API Key management page to get your API Keystring
Alternative authentication method, choose either this or
Authorization. Format: x-api-key: <api-key>Request Body Parameters
string
required
The name of the model to use. Examples:
gpt-4o, gpt-5.4, gpt-5.5, etc.The full list of models can be obtained via GET /api/v1/models.array
required
List of input contentsAn array of inputs, each containing the fields
role and content. Supports multi-turn conversations and multi-modal content (text + images).Show Detailed Field Description
Show Detailed Field Description
string
default:"user"
required
Message roleOptions:
user (user message), assistant (AI reply for multi-turn dialogue), system (system prompt)array
required
Content arraySupports various types of content blocks, including text and images.
Show Content Block Types
Show Content Block Types
string
required
Content typeOptions:
input_text: text inputinput_image: image input
string
Text contentUsed when
type is input_text; fill in the text contentstring
Image URLUsed when
type is input_imageSupports two formats:1. Full image URL address- Publicly accessible image URLs (http:// or https://)
- Example:
https://example.com/image.jpg
- Must use the full Data URI format
- Format:
data:image/{format};base64,{base64_data} - Supported image formats: jpeg, png, gif, webp
- Example:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABg... - Note: Must include the prefix
data:image/jpeg;base64,
string
System Prompt. Used to set the model’s behavior guidelines, role identity, or context.Equivalent to a message in the array with
role: "system".boolean
default:"true"
Whether to enable streaming output.
true(default): returns tokens incrementally as SSE event stream, suitable for real-time displayfalse: returns the full response at once after completion, suitable for batch processing
integer
Maximum number of tokens to generate in the reply. If exceeded, the response
status will be "incomplete", and incomplete_details.reason will be "max_output_tokens".number
Sampling temperature, range
0 to 2. Higher values result in more random output, lower values more deterministic. Not recommended to adjust temperature and top_p simultaneously.number
Nucleus sampling probability, range
0 to 1. The model samples only from tokens whose cumulative probability reaches top_p.array
List of tools available for the model to call. Currently, only
type: "function" is supported; built-in tools like web_search, file_search, computer_use are not supported.string | object
default:"auto"
Tool calling policy:
"auto": model decides automatically whether to call tools"none": prohibit calling tools"required": force calling at least one tool{ "type": "function", "name": "function_name" }: force call the specified tool
boolean
default:"true"
Whether the model is allowed to call multiple tools in parallel. Only effective if
tools are provided.object
Output format control.
Show Text Object
Show Text Object
object
Show Format Object
Show Format Object
string
required
Output format type:
"text": plain text (default)"json_object": JSON format"json_schema": JSON complying with specified Schema
string
Schema name (effective only for
json_schema)string
Schema description (effective only for
json_schema)boolean
default:"true"
Whether to strictly follow the Schema (effective only for
json_schema)object
JSON Schema definition (required only for
json_schema)object
Reasoning mode configuration (applicable to models supporting reasoning, such as
gpt-5.2 and above).Show Reasoning Object
Show Reasoning Object
string
Reasoning intensity:
"low" | "medium" | "high"Response Fields
string
Unique response identifier, format:
resp_ + 24-character random stringstring
Fixed as
"response"number
Response creation time, Unix timestamp (seconds, with millisecond precision)
string
Response status:
"completed": Completed successfully"incomplete": Cut off early due tomax_output_tokens"in_progress": Streaming output in progress (only in streaming events)"failed": Generation failed
string
Actual model name used
string
Platform extension field. Billing task ID for this call, used for reconciliation and consumption queries.Note:
- Non-streaming:
task_idis located directly at the top level of the response JSON - Streaming:
task_idis nested inside theresponseobject ofresponse.created(first event) andresponse.completed(last event). It needs to be parsed from the raw SSE event. The OpenAI SDK streaming interface does not automatically expose this field
array
Array of output items, which may contain two types: text messages and tool calls.
Show message type
Show message type
string
Message ID, format:
msg_ + 16-character random stringstring
Fixed as
"message"string
Fixed as
"assistant"string
"completed" | "in_progress"string
Shortcut field, equivalent to
output[0].content[0].text (in plain text scenarios). Empty string in tool call scenarios.object
object | null
Not null when
status is "incomplete".Show incomplete_details object
Show incomplete_details object
string
Cutoff reason. Currently only
"max_output_tokens"curl -X POST https://aireiter.com/api/v1/responses \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": true
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.responses.create(
model="claude-sonnet-4-5-20250929",
input="Write a one-sentence bedtime story about a unicorn."
)
print(response.output_text)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://aireiter.com/api/v1",
});
const response = await client.responses.create({
model: "claude-sonnet-4-5-20250929",
input: "Write a one-sentence bedtime story about a unicorn.",
});
console.log(response.output_text);
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": false,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://aireiter.com/api/v1/responses", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.*;
import java.util.Map;
public class ResponsesExample {
public static void main(String[] args) throws Exception {
var payload = Map.of(
"model", "claude-sonnet-4-5-20250929",
"input", "Write a one-sentence bedtime story about a unicorn.",
"stream", false
);
var body = new ObjectMapper().writeValueAsString(payload);
var request = HttpRequest.newBuilder()
.uri(URI.create("https://aireiter.com/api/v1/responses"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$client = new GuzzleHttp\Client();
$response = $client->post('https://aireiter.com/api/v1/responses', [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY',
'Content-Type' => 'application/json',
],
'json' => [
'model' => 'claude-sonnet-4-5-20250929',
'input' => 'Write a one-sentence bedtime story about a unicorn.',
'stream' => false,
],
]);
echo $response->getBody();
require 'net/http'
require 'json'
uri = URI('https://aireiter.com/api/v1/responses')
req = Net::HTTP::Post.new(uri, {
'Authorization' => 'Bearer YOUR_API_KEY',
'Content-Type' => 'application/json'
})
req.body = {
model: 'claude-sonnet-4-5-20250929',
input: 'Write a one-sentence bedtime story about a unicorn.',
stream: false
}.to_json
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
puts res.body
import Foundation
let payload: [String: Any] = [
"model": "claude-sonnet-4-5-20250929",
"input": "Write a one-sentence bedtime story about a unicorn.",
"stream": false
]
var request = URLRequest(url: URL(string: "https://aireiter.com/api/v1/responses")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_API_KEY", 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.Net.Http;
using System.Net.Http.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
var response = await client.PostAsJsonAsync("https://aireiter.com/api/v1/responses", new {
model = "claude-sonnet-4-5-20250929",
input = "Write a one-sentence bedtime story about a unicorn.",
stream = false
});
Console.WriteLine(await response.Content.ReadAsStringAsync());
#include <stdio.h>
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
headers = curl_slist_append(headers, "Content-Type: application/json");
const char *data = "{\"model\":\"claude-sonnet-4-5-20250929\","
"\"input\":\"Write a one-sentence bedtime story about a unicorn.\","
"\"stream\":false}";
curl_easy_setopt(curl, CURLOPT_URL, "https://aireiter.com/api/v1/responses");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
return 0;
}
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
final response = await http.post(
Uri.parse('https://aireiter.com/api/v1/responses'),
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'claude-sonnet-4-5-20250929',
'input': 'Write a one-sentence bedtime story about a unicorn.',
'stream': false,
}),
);
print(response.body);
}
library(httr)
library(jsonlite)
response <- POST(
"https://aireiter.com/api/v1/responses",
add_headers(
Authorization = "Bearer YOUR_API_KEY",
`Content-Type` = "application/json"
),
body = toJSON(list(
model = "claude-sonnet-4-5-20250929",
input = "Write a one-sentence bedtime story about a unicorn.",
stream = FALSE
), auto_unbox = TRUE)
)
content(response, "text")
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0123",
"object": "response",
"created_at": 1742000000.123,
"status": "completed",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_xyz123",
"output": [
{
"id": "msg_AbCdEfGhIjKl0123",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "The little unicorn tiptoed through the moonlit meadow, leaving a trail of shimmering stardust as she galloped home to her cozy cloud.",
"annotations": []
}
]
}
],
"output_text": "The little unicorn tiptoed through the moonlit meadow, leaving a trail of shimmering stardust as she galloped home to her cozy cloud.",
"usage": {
"input_tokens": 20,
"output_tokens": 35,
"total_tokens": 55,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0456",
"object": "response",
"created_at": 1742000100.456,
"status": "completed",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_abc456",
"output": [
{
"id": "fc_AbCdEfGhIjKl0456",
"type": "function_call",
"call_id": "call_AbCdEfGh",
"name": "get_weather",
"arguments": "{\"location\":\"San Francisco\",\"unit\":\"celsius\"}"
}
],
"output_text": "",
"usage": {
"input_tokens": 80,
"output_tokens": 25,
"total_tokens": 105,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"id": "resp_AbCdEfGhIjKlMnOpQrSt0789",
"object": "response",
"created_at": 1742000200.789,
"status": "incomplete",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_def789",
"output": [
{
"id": "msg_AbCdEfGhIjKl0789",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "Here is a very long story that was cut off due to max_output_tokens...",
"annotations": []
}
]
}
],
"output_text": "Here is a very long story that was cut off due to max_output_tokens...",
"incomplete_details": {
"reason": "max_output_tokens"
},
"usage": {
"input_tokens": 15,
"output_tokens": 256,
"total_tokens": 271,
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "model is required"
}
}
{
"type": "error",
"error": {
"type": "authentication_error",
"message": "Invalid API key"
}
}
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Insufficient credits"
}
}
{
"type": "error",
"error": {
"type": "not_found_error",
"message": "Model 'unknown-model' not found"
}
}
{
"type": "error",
"error": {
"type": "api_error",
"message": "All providers failed"
}
}
Streaming Response Events
Whenstream: true, the API returns an SSE event stream in text/event-stream format. Each event has the following format:
event: <event_type>
data: <JSON_payload>
sequence_number field (incrementing from 0) to ensure clients process events in order.
Obtainingtask_id: To get the billing task ID in streaming mode, listen for the firstresponse.createdevent and readevent.response.task_id.
Event Sequence (Text Response)
| No. | Event Type | Description |
|---|---|---|
| 1 | response.created | Response object created, status: "in_progress" |
| 2 | response.in_progress | Response generation started |
| 3 | response.output_item.added | Output message item added |
| 4 | response.content_part.added | Text content chunk added, text: "" |
| 5 | response.output_text.delta | (Repeated) Incremental text per token |
| 6 | response.output_text.done | Text content completed with full text |
| 7 | response.content_part.done | Content chunk completed |
| 8 | response.output_item.done | Message item completed |
| 9 | response.completed | Response completed with full response object and usage |
Event Sequence (Tool Invocation)
| No. | Event Type | Description |
|---|---|---|
| … | response.output_item.added | Function call item added |
| … | response.function_call_arguments.delta | (Repeated) Function arguments incremental |
| … | response.function_call_arguments.done | Function arguments completed |
| … | response.output_item.done | Function call item completed |
| Last | response.completed | Response completed |
Event Examples
{
"type": "response.created",
"sequence_number": 0,
"response": {
"id": "resp_AbCdEfGhIjKlMnOpQrSt0123",
"object": "response",
"created_at": 1742000000.123,
"status": "in_progress",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_xyz123",
"output": [],
"output_text": ""
}
}
{
"type": "response.output_text.delta",
"sequence_number": 5,
"item_id": "msg_AbCdEfGhIjKl0123",
"output_index": 0,
"content_index": 0,
"delta": "The little"
}
{
"type": "response.completed",
"sequence_number": 9,
"response": {
"id": "resp_AbCdEfGhIjKlMnOpQrSt0123",
"object": "response",
"created_at": 1742000000.123,
"status": "completed",
"model": "claude-sonnet-4-5-20250929",
"task_id": "task_xyz123",
"output": [
{
"id": "msg_AbCdEfGhIjKl0123",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "The little unicorn tiptoed through the moonlit meadow.",
"annotations": []
}
]
}
],
"output_text": "The little unicorn tiptoed through the moonlit meadow.",
"usage": {
"input_tokens": 20,
"output_tokens": 12,
"total_tokens": 32,
"output_tokens_details": { "reasoning_tokens": 0 }
}
}
}
{
"type": "response.function_call_arguments.delta",
"sequence_number": 7,
"output_index": 0,
"delta": "{\"location\":"
}
Usage Examples
Basic Text Conversation
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://aireiter.com/api/v1"
)
response = client.responses.create(
model="claude-sonnet-4-5-20250929",
instructions="You are a helpful coding assistant.",
input="How do I reverse a string in Python?",
)
print(response.output_text)
Image Understanding
response = client.responses.create(
model="claude-sonnet-4-5-20250929",
input=[
{
"role": "user",
"content": [
{"type": "input_text", "text": "What's in this image?"},
{"type": "input_image", "image_url": {"url": "https://example.com/photo.jpg"}},
],
}
],
)
print(response.output_text)
Tool Invocation
tools = [
{
"type": "function",
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
]
response = client.responses.create(
model="gpt-5.2",
input="What's the weather like in Tokyo?",
tools=tools,
tool_choice="auto",
)
# Check for tool calls
for item in response.output:
if item.type == "function_call":
print(f"Tool: {item.name}, Args: {item.arguments}")
Structured Output (JSON Schema)
import json
schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
"hobbies": {"type": "array", "items": {"type": "string"}},
},
"required": ["name", "age", "hobbies"],
"additionalProperties": False,
}
response = client.responses.create(
model="claude-sonnet-4-5-20250929",
input="Extract info: Alice is 30 years old and loves hiking and cooking.",
text={
"format": {
"type": "json_schema",
"name": "person_info",
"strict": True,
"schema": schema,
}
},
)
data = json.loads(response.output_text)
print(data) # {"name": "Alice", "age": 30, "hobbies": ["hiking", "cooking"]}
Reasoning Mode
response = client.responses.create(
model="claude-3-7-sonnet-20250219", # Model supporting reasoning
input="Solve: If x + y = 10 and x * y = 21, what are x and y?",
reasoning={"effort": "high"},
)
print(response.output_text)
Multi-turn Conversation
previous_response_id is currently ineffective; you need to manually concatenate historical messages in input:
# First turn
response1 = client.responses.create(
model="claude-sonnet-4-5-20250929",
input="My name is Bob.",
)
# Second turn: manually concatenate history
response2 = client.responses.create(
model="claude-sonnet-4-5-20250929",
input=[
{"role": "user", "content": "My name is Bob."},
{"role": "assistant", "content": response1.output_text},
{"role": "user", "content": "What's my name?"},
],
)
print(response2.output_text) # "Your name is Bob."
Notes
-
Streaming by Default: The
streamparameter defaults totrue. To receive a non-streaming response, explicitly pass"stream": false. -
Insufficient Credits: An HTTP
402is returned when the balance is insufficient. Please recharge and try again. -
Limited Support for text.format: The underlying provider currently has limited support for structured output—models may still output Markdown code blocks instead of pure JSON in
json_objectmode; Schema constraints may not be enforced injson_schemamode. For structured output, it is recommended to clearly describe the required format ininstructionsorinput. -
Tool Parameters: The
parametersfield must be a valid JSON Schema, and therequiredarray specifies which parameters are mandatory.
Error Code Description
| HTTP Status Code | error.type | Description |
|---|---|---|
| 400 | invalid_request_error | Invalid request parameters (missing required fields, JSON parsing failure, etc.) |
| 401 | authentication_error | API Key is invalid or expired |
| 402 | invalid_request_error | Insufficient account balance |
| 404 | not_found_error | Specified model does not exist |
| 502 | api_error | All upstream AI providers are unavailable |
| 503 | api_error | No available provider configuration |
⌘I