Send text or typed items to the Responses API, read the response object, stream it, and carry a conversation.
POST /v1/responses takes either a string or an array of typed items as input, and answers a response object whose output is an array of typed items.
curl https://opendunes.com/v1/responses \
-H "Authorization: Bearer $OPENDUNES_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.1",
"input": "What is the capital of Algeria?",
"max_output_tokens": 500
}'import os
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)
response = client.responses.create(
model="openai/gpt-5.1",
input="What is the capital of Algeria?",
max_output_tokens=500,
)
print(response.output_text)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://opendunes.com/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const response = await client.responses.create({
model: "openai/gpt-5.1",
input: "What is the capital of Algeria?",
max_output_tokens: 500,
});
console.log(response.output_text);For a conversation, send message items:
{
"model": "openai/gpt-5.1",
"input": [
{
"type": "message",
"role": "user",
"content": [
{ "type": "input_text", "text": "Tell me a joke about programming" }
]
}
],
"max_output_tokens": 500
}{
"id": "resp_1234567890",
"object": "response",
"created_at": 1758700000,
"model": "openai/gpt-5.1",
"status": "completed",
"output": [
{
"type": "message",
"id": "msg_abc123",
"status": "completed",
"role": "assistant",
"content": [
{ "type": "output_text", "text": "The capital of Algeria is Algiers (الجزائر).", "annotations": [] }
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 14,
"total_tokens": 26,
"cost": 0.0874
}
}usage.cost is the charge in DA. The answer carries X-Generation-Id, the handle of its receipt.
Add "stream": true to receive the answer as server-sent events, each a typed response.* event:
data: {"type":"response.created","response":{"id":"resp_1234567890","object":"response","status":"in_progress"}}
data: {"type":"response.output_text.delta","output_index":0,"content_index":0,"delta":"The capital"}
data: {"type":"response.output_text.delta","output_index":0,"content_index":0,"delta":" of Algeria is Algiers."}
data: {"type":"response.completed","response":{"id":"resp_1234567890","status":"completed","usage":{"input_tokens":12,"output_tokens":14,"total_tokens":26,"cost":0.0874}}}The usage, with cost in DA, rides the closing response.completed event. A failure after the stream began arrives as a response.failed event. See Streaming.
| Parameter | Type | Description |
|---|---|---|
model | string | Required. Any text model, lab/model |
input | string or array | Required. Text, or an array of typed items |
instructions | string | A system instruction |
stream | boolean | Stream the answer as events (default false) |
max_output_tokens | integer | The most tokens to generate |
temperature | number | Sampling temperature (0–2) |
top_p | number | Nucleus sampling (0–1) |
reasoning | object | See Reasoning |
tools · tool_choice | array · string or object | See Tool Calling |
Every other field of the Responses shape travels to the model as you sent it.
The Responses API is stateless: nothing is kept between requests. To continue a conversation, send it whole — the earlier user turns, the assistant's output items, then the new turn:
{
"model": "openai/gpt-5.1",
"input": [
{ "type": "message", "role": "user", "content": [{ "type": "input_text", "text": "What is the capital of Algeria?" }] },
{
"type": "message",
"role": "assistant",
"id": "msg_abc123",
"status": "completed",
"content": [{ "type": "output_text", "text": "The capital of Algeria is Algiers.", "annotations": [] }]
},
{ "type": "message", "role": "user", "content": [{ "type": "input_text", "text": "What language is spoken there?" }] }
]
}Every turn bills its whole input. store: true and previous_response_id are refused with a 400.
Any text model on sale answers here, not only OpenAI's — browse them at /models or read the list at GET /v1/models.