API reference
Create a response
POST /v1/responses request, response, and error contract.
POST /v1/responses
Stateless, zero-data-retention Responses API compatibility for text generation. Supports message input, streaming SSE, local function tools, structured text formats, and model-dependent reasoning controls. store=true and non-null previous_response_id are rejected; clients must resend conversation context in input.
Authentication¶
Send Authorization: Bearer $KOSCOMPUTE_API_KEY.
Request¶
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Public model ID returned by GET /models |
input |
string · array | Yes | See the endpoint guide for behavior and model support. |
stream |
boolean | No | See the endpoint guide for behavior and model support. |
temperature |
number | No | See the endpoint guide for behavior and model support. |
top_p |
number | No | See the endpoint guide for behavior and model support. |
max_output_tokens |
integer | No | See the endpoint guide for behavior and model support. |
tools |
array | No | See the endpoint guide for behavior and model support. |
tool_choice |
string · object | No | See the endpoint guide for behavior and model support. |
parallel_tool_calls |
boolean | No | See the endpoint guide for behavior and model support. |
text |
object | No | See the endpoint guide for behavior and model support. |
reasoning |
object | No | Model-dependent reasoning controls; public reasoning text is not exposed. |
metadata |
object | No | See the endpoint guide for behavior and model support. |
store |
boolean | No | Values: False. |
previous_response_id |
null | No | See the endpoint guide for behavior and model support. |
prompt_cache_key |
null | No | See the endpoint guide for behavior and model support. |
Examples¶
cURL¶
curl https://api.koscompute.com/v1/responses \
-H "Authorization: Bearer $KOSCOMPUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen/qwen3.8-27b","input":"Reply with one sentence.","max_output_tokens":120}'
Python¶
import os
import requests
response = requests.post(
"https://api.koscompute.com/v1/responses",
headers={"Authorization": f"Bearer {os.environ['KOSCOMPUTE_API_KEY']}"},
json={
"model": "qwen/qwen3.8-27b",
"input": "Reply with one sentence.",
"max_output_tokens": 120
},
)
print(response.json())
JavaScript¶
const response = await fetch("https://api.koscompute.com/v1/responses", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.KOSCOMPUTE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"model":"qwen/qwen3.8-27b","input":"Reply with one sentence.","max_output_tokens":120}),
});
console.log(await response.json());
Responses¶
| Status | Meaning |
|---|---|
200 |
Completed JSON response or a canonical Responses SSE stream when stream=true |
400 |
Bad request — invalid parameters or payload |
401 |
Invalid or missing API key |
403 |
Model not allowed for this API key |
404 |
Public model not found |
413 |
Request body exceeds the limit |
429 |
Rate limit or admission capacity is full. The message states when to retry; vision saturation also reports active/total vision concurrency. |
500 |
Internal server error |
502 |
Invalid or failed upstream response |
503 |
No healthy route |
504 |
Backend generation timeout |
Next steps¶
Use the endpoint guide for complete workflows, model capability notes, streaming behavior, and retry advice.