Repository navigation
feat(py/openai): explore AmazonBedrock backend for OpenAICompatible - #263
Closed
huangjeff5 wants to merge 3 commits into
Closed
huangjeff5 wants to merge 3 commits into
huangjeff5 wants to merge 3 commits into
Conversation
This was referenced Nov 30, 2026
Collaborator
Author
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.
Adds an
AmazonBedrock(region=..., profile=...)backend togenkit-openai(behind thegenkit-openai[amazon-bedrock]extra) so callers on AWS can call Bedrock's OpenAI-compatible models throughOpenAICompatible, authenticating with either the AWS credential chain (SigV4) or a Bedrock bearer token (AWS_BEARER_TOKEN_BEDROCK).What Fit Cleanly vs. Real Friction Found
_ServerProtocol from feat(py): serve Model Garden's OpenAI-compatible models via OpenAICompatible(backend=GoogleCloud()) #259 scaled cleanly with zero core changes: AddingAmazonBedrocktook one self-contained module (_amazon_bedrock.py), theamazon-bedrockextra (boto3>=1.37.24,botocore>=1.37.24), and oneelif isinstance(backend, AmazonBedrock)branch inOpenAICompatible.__init__.AsyncOpenAI._prepare_request: Unlikeanthropic, theopenaiPython SDK (2.21.0) has no built-in Bedrock/SigV4 client. SubclassingAsyncOpenAI(_SigV4OpenAI) to override the Stainless_prepare_requesthook signs every outgoing request withbotocore.auth.SigV4Authwithout interfering withhttp_client,timeout,max_retries, orhttpx.MockTransport— and fetchesget_frozen_credentials()off the event loop viaasyncio.to_thread, mapping mid-run expired STS/SSOBotoCoreErrors toFAILED_PRECONDITION.bedrock-runtimevs.bedrock-mantle): Defaults to AWS's recommendedhttps://bedrock-runtime.{region}.amazonaws.com/openai/v1(SigV4 servicebedrock, noGET /models). Overridingbase_url=to abedrock-mantle.{region}.api.awshost automatically switches SigV4 signing tobedrock-mantle.us-east-1fallback): Matches feat(py/anthropic): explore AmazonBedrock backend for Anthropic #261 andgenkit-amazon-bedrock— resolvesregion=,AWS_REGION,AWS_DEFAULT_REGION, then~/.aws/config, failing loudly withFAILED_PRECONDITIONwhen unset.genkit-amazon-bedrock: Defaults toname='bedrock'(matchinggenkit-amazon-bedrock's plugin name, just asGoogleClouddefaults to'modelgarden'). Apps running bothBedrock()(for Converse / Stability images / Titan embedders) andOpenAICompatible(backend=AmazonBedrock(...))pass a customname=(e.g.name='bedrock-openai').Open Questions to Decide Before Moving Past Exploration
'bedrock'vs. something non-colliding): Unlikegenkit-vertexai(which feat(py): deprecate genkit-vertexai; remove it in the next release #260 deprecates),genkit-amazon-bedrockstays alive for Converse, Stability images, and Titan/Cohere embedders. ShouldOpenAICompatible(backend=AmazonBedrock(...))default to'bedrock'(matchingGoogleCloud->'modelgarden') or require/pick a distinct name if people commonly register both side by side?bedrock-runtimevs.bedrock-mantledefault:bedrock-runtime.{region}.amazonaws.com/openai/v1is AWS's recommended default, whilebedrock-mantle.{region}.api.aws/v1addsGET /models, Responses API features, and Mantle-only models. ShouldAmazonBedrockstay onbedrock-runtimewithbase_url=override, or expose an explicit switch?AWS_BEARER_TOKEN_BEDROCK): Same question as feat(py/anthropic): explore AmazonBedrock backend for Anthropic #261 — right nowAWS_BEARER_TOKEN_BEDROCKworks automatically (skipping SigV4), while top-levelapi_key=andclient_options={'api_key': ...}are rejected. Shouldapi_key=stay rejected or accept a Bedrock bearer token?AsyncOpenAI._prepare_request:_prepare_requestis a documented Stainless base-client hook (with a leading underscore). Confirm we're comfortable relying on it (with a contract test) vs. wrapping anhttpx.Authflow.Verification
uv run --no-sync pytest packages/genkit-openai/ tests/version_bounds_guard_test.py(1,123 passed)uv run --no-sync ruff format --check --preview .uv run --no-sync ruff check --preview .uv run --no-sync ty check .uv run --no-sync pyrefly checkpython3 scripts/check_consistency.pyanduv lock --check