LLM.Adapter.OpenAIResponse (LLM v0.1.2)

Copy Markdown View Source

OpenAI Responses API adapter.

Handles the wire format for the /v1/responses endpoint. This is OpenAI's newer API that supports multi-turn conversations via previous_response_id and structured output items.

Capabilities

  • Streaming via SSE with typed output items
  • Tool/function calling with function_call and function_call_output items
  • Reasoning/thinking via reasoning output items
  • Response chaining via previous_response_id
  • Model listing via /v1/models

Request format

Input uses the Responses API's item format:

  • Message: %{"type" => "message", "role" => ..., "content" => [...]}
  • Function call output: %{"type" => "function_call_output", "call_id" => ..., "output" => ...}

System instructions are sent as an "instructions" field.

SSE events

  • event: response.created — response started
  • event: response.output_text.delta — text chunk
  • event: response.reasoning.delta — thinking/reasoning chunk
  • event: response.function_call_arguments.delta — tool call arguments
  • event: response.output_item.done — tool call complete
  • event: response.completed — end of stream