OpenAI Responses API

An OpenAI-compatible /v1/responses endpoint, so the OpenAI SDKs and the Codex CLI work with Pendra models.

POST /v1/responses

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.

Body application/json
model string Required
A model your workers serve, such as qwen3.6:27b. Leave off the quant to use whichever one you installed. See Naming a model.
input string | array Required
The prompt, or the whole conversation. Nothing is stored between requests, so send everything each time. See Sending a conversation.
instructions string
The system prompt.
max_output_tokens integer default: 32768
The most tokens the reply may contain, thinking included unless you set a thinking budget in reasoning.
stream boolean default: false
Set true to stream the reply. See Streaming.
tools array
The tools the model can call. See Tools.
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
How random the output is, from 0 to 2. Use 0 for the most focused, repeatable answers.
top_p number default: the model's recommended value
Only the most likely tokens, adding up to this probability, are considered.
store, parallel_tool_calls boolean
Accepted and ignored. Nothing is stored.

previous_response_id isn't supported and returns a 400.

Sending a conversation

  • Message content can hold input_text, input_image and input_file parts, and so can a function_call_output, so a tool can return a screenshot.
  • An input_image needs its image in image_url, as a data URL or a web address. A file_id alone gets a 400.
  • An input_file can 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_output after its call. Include the reasoning items too, so the model can see its earlier thinking.

Tools

  • function tools take JSON arguments, and calls come back as function_call items. See Tool calling.
  • custom tools take free text, like Codex's apply_patch. Calls come back as custom_tool_call items. The model sees a tool's grammar but isn't held to it, so check the text before you use it. A call cut off by max_output_tokens has status: "incomplete", so don't run it.
  • namespace groups, like Codex's sub-agent tools. Calls carry the group's name in namespace.
  • Built-in tools such as file_search or code_interpreter are left out, and listed in the reply under pendra.ignored_tools. web_search works 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}
}
  • worker and request_id say which worker ran it. See Which worker served the request.
  • timing gives the speed. See Timing.
  • notice explains an unusual reply, such as thinking that hit its budget. See Notices.
  • images_omitted appears when the oldest images in a long conversation were left out.
  • ignored_tools lists 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_tokens is how many input tokens came from the cache. Divide it by input_tokens for 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 error event.
  • A custom tool's text arrives in response.custom_tool_call_input.delta events.
  • While a long prompt is being read, Pendra sends a : keep-alive line 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.