OpenAI Responses API
An OpenAI-compatible /v1/responses endpoint, so the OpenAI SDKs and the Codex CLI work with Pendra models.
Pendra speaks OpenAI's Responses format, so the OpenAI SDKs and the
Codex CLI work with Pendra
models. Set the base URL to https://api.pendra.ai/v1 and use a
Pendra API key. The endpoint also answers at /api/v1/responses.
Authentication
Send your key as Authorization: Bearer. The
x-api-key header works too.
model
string
Required
qwen3.6:27b. Leave off the quant to use whichever one you installed. See Naming a model.
input
string | array
Required
instructions
string
max_output_tokens
integer
default: 32768
reasoning.
stream
boolean
default: false
true to stream the reply. See Streaming.
tools
array
tool_choice
string | object
default: auto
auto, none, required, or {"type":"function","name":"..."} to force one tool. Use "type":"custom" for a custom tool, and add namespace for a tool in a group.
reasoning
object
{"effort":"low"}, "medium" or "high" sets how much a reasoning model thinks, and "none" or "minimal" skips thinking. Pendra also takes {"max_tokens":4096} as a thinking budget, which then comes on top of max_output_tokens. The default budget is 8,192. See Thinking.
temperature
number
default: the model's recommended value
0 to 2. Use 0 for the most focused, repeatable answers.
top_p
number
default: the model's recommended value
store, parallel_tool_calls
boolean
previous_response_id isn't supported and returns a
400.
Sending a conversation
-
Message content can hold
input_text,input_imageandinput_fileparts, and so can afunction_call_output, so a tool can return a screenshot. -
An
input_imageneeds its image inimage_url, as a data URL or a web address. Afile_idalone gets a400. - An
input_filecan be a text or CSV file of up to 1 MB. -
Send earlier output items back in the order you got them, with each
function_call_outputafter its call. Include thereasoningitems too, so the model can see its earlier thinking.
Tools
-
functiontools take JSON arguments, and calls come back asfunction_callitems. See Tool calling. -
customtools take free text, like Codex'sapply_patch. Calls come back ascustom_tool_callitems. The model sees a tool'sgrammarbut isn't held to it, so check the text before you use it. A call cut off bymax_output_tokenshasstatus: "incomplete", so don't run it. -
namespacegroups, like Codex's sub-agent tools. Calls carry the group's name innamespace. -
Built-in tools such as
file_searchorcode_interpreterare left out, and listed in the reply underpendra.ignored_tools.web_searchworks on a worker with web tools on.
custom and namespace tools need an up-to-date worker.
Response
You get OpenAI's Responses object, as in the example. output
is a list of items, such as message, reasoning
and function_call. status is
completed, or incomplete if the reply was cut off.
The reply also has a pendra field, which OpenAI clients
ignore:
"pendra": {
"worker": {"id": "wrk-1a2b3c4d", "name": "london-gpu-01", "version": "3.115.1"},
"request_id": "3f1c8a2e-5b7d-4e19-9c0a-6d2f8b1e4a73",
"timing": {"ttft_ms": 115, "tokens_per_second": 58.34, "queue_wait_ms": 16600}
}
workerandrequest_idsay which worker ran it. See Which worker served the request.timinggives the speed. See Timing.noticeexplains an unusual reply, such as thinking that hit its budget. See Notices.images_omittedappears when the oldest images in a long conversation were left out.ignored_toolslists built-in tools the model couldn't call.
A stream carries notice on its response.completed
event, and names the worker in the X-Worker-Id and
X-Worker-Name headers instead.
Prompt caching
Pendra reuses the part of a conversation it has already read, so follow-up turns start replying sooner. It's automatic and free.
usage.input_tokens_details.cached_tokensis how many input tokens came from the cache. Divide it byinput_tokensfor the hit rate.- When streaming, it arrives on
response.completed.
Streaming
With "stream": true you get the Responses events:
event: response.created
data: {"type":"response.created","response":{"id":"resp_01HZ8b","object":"response","status":"in_progress","model":"qwen3.6:27b-q4_k_m"}}
event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_01","output_index":0,"content_index":0,"delta":"Hello"}
event: response.completed
data: {"type":"response.completed","response":{"id":"resp_01HZ8b","status":"completed","usage":{"input_tokens":8,"output_tokens":2,"total_tokens":10,"input_tokens_details":{"cached_tokens":0}}}}
- If the request can't start, for example because no worker is online or every worker is busy, you get a normal HTTP error before any events, so check the status first. See Errors & rate limits.
- A failure after the stream has started arrives as an
errorevent. - A custom tool's text arrives in
response.custom_tool_call_input.deltaevents. -
While a long prompt is being read, Pendra sends a
: keep-aliveline every 15 seconds. SDKs ignore it. If you read the stream yourself, skip lines that start with:. - When your workers are busy, Pendra can hold a request for a while before it starts, so give your HTTP client a timeout of at least 90 seconds.
Use with Codex
Codex asks for OpenAI's own models by default, such as
gpt-5-codex. Pendra won't swap in a model for a name it
doesn't know, so set a Pendra model id or you'll get a 404.
See Codex for the full setup.