feat: Support OpenAI Responses API (/v1/responses)#34
Open
shohei81 wants to merge 7 commits into
Open
Conversation
Why: CI lint step (`black --check src tests`) was failing on src/main.py, which blocked the rest of the matrix (test/type-check/security/pytest all got skipped on Python 3.10/3.11/3.12). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…es API Minimum spec-compliance fixes for /v1/responses: - Streaming: emit the full SSE event sequence per spec (response.created → in_progress → output_item.added → content_part.added → output_text.delta×N → output_text.done → content_part.done → output_item.done → completed). Each event now carries `type` + monotonic `sequence_number`, and the response object is nested under the `response` key as required by OpenAI SDK clients. - Add `output_text` to the final streaming response object so clients see the same flattened text field they get from non-streaming. - Map `previous_response_id` → internal session_id so real Responses API clients can chain conversations without using our custom `session_id` field. - `_build_responses_output` now includes `status` and `annotations` on the message/output_text items (used by both streaming and non-streaming responses). Why minimum: refactoring the duplicated chat/responses pipeline is out of scope here; these changes only shift the surface to match what OpenAI clients actually expect, without touching the core Claude execution path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Non-streaming response was returning `created` (Chat Completions field name), causing the OpenAI SDK Responses model to fail validation since it expects `created_at`. Streaming already uses `created_at`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…schema" This reverts commit b82f722.
… Responses API" This reverts commit 827bbfa.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds basic support for the OpenAI
/v1/responsesAPI, includingoptional streaming support, to improve compatibility with newer OpenAI-based
tooling.
The implementation is intentionally minimal and scoped to:
/v1/responsesrequests into the existing Claude execution flowThis work addresses the feature request discussed in #21.
What’s included
/v1/responsesendpoint supportTesting
No new tests were added in this PR; the change is covered by existing tests.
Notes
If this direction aligns with the project’s design goals, I’m happy to:
Fixes #21