feat: OpenAI-compatible gateway endpoints + Bedrock streaming#9
Closed
shadmoney wants to merge 3 commits intoopenagen:mainfrom
Closed
feat: OpenAI-compatible gateway endpoints + Bedrock streaming#9shadmoney wants to merge 3 commits intoopenagen:mainfrom
shadmoney wants to merge 3 commits intoopenagen:mainfrom
Conversation
The test was not updated when the function signature changed to include the skills_prompt_mode parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ints Add an OpenAI-compatible API surface to the gateway so that standard OpenAI client libraries can interact with ZeroClaw directly. Endpoints: - POST /v1/chat/completions — supports both streaming (SSE) and non-streaming responses, bearer token auth, rate limiting - GET /v1/models — returns the gateway's configured model The chat completions endpoint accepts the standard OpenAI request format (model, messages, temperature, stream) and returns responses in the OpenAI envelope format. Streaming uses SSE with delta chunks and a [DONE] sentinel. A 512KB body limit is applied (vs 64KB default) since chat histories can be large. When the underlying provider doesn't support native streaming, the handler falls back to wrapping the non-streaming response in a single SSE chunk for transparent compatibility. Includes 8 unit tests for request/response serialization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement the streaming provider trait methods for Bedrock, enabling
real-time token-by-token responses via the ConverseStream endpoint.
Key implementation details:
- Uses /model/{id}/converse-stream endpoint with SigV4 signing
- Parses AWS binary event-stream format (application/vnd.amazon.eventstream)
with a minimal parser (~60 lines) — no new crate dependencies needed
- Handles contentBlockDelta events for text extraction, plus error and
exception events
- Uses mpsc channel + stream::unfold pattern (matching compatible.rs)
- Clones credentials for async task ownership
The binary event-stream parser extracts frame lengths, header sections
(looking for :event-type), and payload bytes. CRC validation is skipped
since TLS already provides integrity guarantees.
Includes 10 new tests for URL formatting, binary parsing, and
deserialization.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for contributing to ZeroClaw. For faster review, please ensure:
See |
PR intake checks found warnings (non-blocking)Fast safe checks found advisory issues. CI lint/test/build gates still enforce merge quality.
Action items:
Run logs: https://github.com/openagen/zeroclaw/actions/runs/22288816257 Detected blocking line issues (sample):
Detected advisory line issues (sample):
|
Author
|
Opened against wrong upstream — closing. |
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
/v1/chat/completions— supports streaming (SSE) and non-streaming responses, bearer token auth, rate limiting, and a 512KB body limit for large chat histories. Falls back to single-chunk SSE when the provider doesn't natively support streaming./v1/models— returns the gateway's configured model in standard OpenAI format.stream_chat_with_system()for the Bedrock provider using the/converse-streamendpoint with SigV4 signing and a minimal AWS binary event-stream parser (no new crate dependencies).skills_prompt_modeargument inbuild_system_prompttest that was broken after a recent signature change.Motivation
These changes enable standard OpenAI client libraries (Python
openai, TypeScriptopenai, LangChain, etc.) to interact with ZeroClaw's gateway directly, which is the main integration path for applications migrating from OpenAI-compatible gateways. Bedrock streaming enables real-time token-by-token responses for AWS Bedrock users.Test plan
cargo buildsucceedscurlagainst/v1/chat/completionsand/v1/models🤖 Generated with Claude Code