Add AWS Bedrock provider (Converse + ConverseStream)#461
Open
ricardosllm wants to merge 1 commit into
Open
Conversation
Bedrock's OpenAI-compatible endpoint only serves openai.* models; Claude and other inference profiles are reachable only through the native Converse API. This adds a dedicated `bedrock` API type implementing both Converse (non-streaming) and ConverseStream (binary event-stream framing), with bearer-token auth, tool calling and reasoning. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fcee451 to
b20b2be
Compare
Contributor
Author
|
I wrote this with Claude Opus 4.7 and reviewed as well with OpenAI GPT 5.5 It works for my usecase, here's what I tested: Configuration. Bedrock configured as a standard provider entry: {:providers {"bedrock" {:api "bedrock"
:url "https://bedrock-runtime.ap-southeast-1.amazonaws.com"
:key "<bearer token>"
:models {"global.anthropic.claude-sonnet-4-6" {}}}}}
Proven working — live against AWS Bedrock:
Not covered:
If you think this is in the right direction I can try to test what was not covered yet. |
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.
Closes #254.
Adds a
bedrockprovider/API type using AWS Bedrock's native Converse and ConverseStream APIs.Why
Bedrock's OpenAI-compatible endpoint only serves
openai.*models — Claude (and other) inference profiles return 404 there, so the existing OpenAI-compat custom-provider path can't reach them. This adds a dedicated handler. (Also supersedes the partial workaround discussed in #329.)Scope
vnd.amazon.eventstreamframe decoderAuthorization: Bearer <token>) — sidesteps SigV4; pairs withAWS_BEARER_TOKEN_BEDROCKtoolConfig/toolSpec/toolUse/toolResultblocksreasoningContentblocks;reasoning_configviaadditionalModelRequestFieldswhenreason?extraPayloadis filtered to Converse-valid top-level keys (verified against the botocore service model) so variant payloads aimed at other APIs don't 400SigV4 auth and a model-catalog endpoint are intentionally out of scope for this first cut.
Config
{ "providers": { "bedrock": { "api": "bedrock", "url": "https://bedrock-runtime.us-east-1.amazonaws.com", "key": "${env:AWS_BEARER_TOKEN_BEDROCK}", "models": { "us.anthropic.claude-sonnet-4-5-20250929-v1:0": {} } } } }Also reachable via the
/loginflow (providerbedrock).How to verify / test
Automated —
bb test(suite green,523 tests, 2881 assertions). Bedrock-specific:clojure -M:test --focus eca.llm-providers.bedrock-testcovers the binary event-stream decoder (crafted frames, truncated/malformed), message normalization,extraPayloadfiltering, request/response shapes, both tool-call loops, streaming callbacks, and error paths.Manual against live AWS:
export AWS_BEARER_TOKEN_BEDROCK=...bb debug-cli→./eca/login→bedrock../eca, select abedrock/...model, and run a chat. Verify:This branch was integrated and smoke-tested live (non-streaming text, ConverseStream streaming, multi-turn tool-call round-trip) by a downstream consumer that embeds ECA as a library.
🤖 Generated with Claude Code