Skip to content

Add OpenAI Responses API route (/v1/responses) to gateway - #57

Merged
FMXExpress merged 1 commit into
mainfrom
codex/implement-post-/v1/responses-route
May 28, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
codex/implement-post-/v1/responses-route

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Motivation

  • Expose a Responses-compatible endpoint that modern OpenAI clients and KAI expect (/v1/responses) so callers can send model + input (string or message-array) and receive Responses-shaped output.
  • Reuse the existing tool-loop flow (TToolLoopConfig / RunToolLoop) so Responses requests get the same provider/tool execution semantics as /v1/chat/completions.

Description

  • Added routing and handler declaration for POST /v1/responses and included the route in the /v1 index and README examples (files touched: src/pkg/gateway/PasClaw.Gateway.Server.pas, README.md).
  • Implemented TGatewayServer.HandleResponses to parse model, input (accepting either a string or an array of message/content items), stream, temperature, and max_output_tokens/max_tokens, convert to TMessage array, and run the existing tool-loop.
  • Added GenResponseId and BuildResponsesObject helpers to emit a minimal Responses-compatible non-streaming JSON object with id, object: "response", created_at, model, status, output (assistant message content) and usage fields.
  • Streaming behavior for Responses is intentionally not implemented and yields a clear OpenAI-shaped invalid-request error when stream:true is requested.

Testing

  • Ran git diff --check and repository grep checks for the new route and handler (rg -n "POST /v1/responses|HandleResponses|unsupported_streaming|/v1/responses") which reported the expected symbols in src/pkg/gateway/PasClaw.Gateway.Server.pas and README.md.
  • Performed smoke/manual verification edits to README.md showing curl examples for string input, message-array input, missing/empty input, and unsupported streaming behavior (examples added to README).
  • Attempted make test-hashline but the build step is blocked in this environment because fpcres is not available, so FPC-focused tests could not run here.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant