feat(bedrock_mantle): Add support for native Responses API route#29476
feat(bedrock_mantle): Add support for native Responses API route#29476Sameerlite wants to merge 2 commits into
Conversation
Register BedrockMantleResponsesAPIConfig so /v1/responses hits
bedrock-mantle.{region}.api.aws/openai/v1/responses instead of the
chat-completions fallback. Fix default api_base to use /openai/v1.
Co-authored-by: Cursor <cursoragent@cursor.com>
Greptile SummaryThis PR adds native Responses API support for the Bedrock Mantle provider by introducing
Confidence Score: 4/5Safe to merge once the The bare-host and standard-path cases are correctly handled and tested. However, when litellm/llms/bedrock_mantle/responses/transformation.py — specifically the
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock_mantle/responses/transformation.py | New Responses API config; URL-routing logic for the /v1 suffix case produces an incorrect endpoint for Bedrock Mantle. |
| litellm/llms/bedrock_mantle/chat/transformation.py | Corrects default API base from /v1 to /openai/v1; straightforward and safe. |
| litellm/utils.py | Registers BedrockMantleResponsesAPIConfig with ProviderConfigManager; minimal and correct. |
| tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_transformation.py | Adds mock-only tests for responses config; covers default and bare-host cases, but misses the /v1-suffixed API base scenario. |
Reviews (2): Last reviewed commit: "fix(bedrock_mantle): correct responses U..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Ensure Bedrock Mantle Responses URLs always include the OpenAI-compatible /openai/v1 prefix for bare API bases and remove unreachable api_base guard logic. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@greptileai addressed both review points: fixed bare-host Bedrock Mantle Responses URL fallback to include /openai/v1 and removed the unreachable api_base guard. Added a regression test for bare BEDROCK_MANTLE_API_BASE. |
| if api_base.endswith("/v1"): | ||
| return f"{api_base}/responses" |
There was a problem hiding this comment.
/v1 fallback produces wrong Bedrock Mantle URL
When BEDROCK_MANTLE_API_BASE is set to a URL ending in /v1 (e.g. https://bedrock-mantle.us-east-1.api.aws/v1 — the old default format before this PR's fix), get_complete_url returns {base}/responses instead of the correct /openai/v1/responses path. The Bedrock Mantle Responses endpoint lives at /openai/v1/responses, so any user whose BEDROCK_MANTLE_API_BASE still carries the old /v1 suffix will receive a 404 when calling responses. A dedicated test for this case (api_base ending in /v1) is also missing.
| resolved_api_base, | ||
| _, | ||
| ) = BedrockMantleChatConfig()._get_openai_compatible_provider_info( | ||
| api_base=api_base or litellm_params.get("api_base"), |
There was a problem hiding this comment.
High: Bedrock Mantle key can be sent to caller-controlled api_base
An authenticated proxy caller can POST to /v1/responses with a Bedrock Mantle model and an api_base pointing at their server while omitting api_key. validate_environment() still attaches BEDROCK_MANTLE_API_KEY, and this URL builder sends the request to the caller's host, exposing the provider bearer token. Only use operator-configured base URLs when using the environment credential, or require/allowlist per-request api_base before attaching the proxy's Bedrock Mantle key.
PR overviewThis PR adds native Bedrock Mantle support for the Responses API route, including transformation logic for handling There is one open security issue with a clear credential-exposure impact: an authenticated proxy caller can influence the request base URL while the proxy attaches the operator-configured Bedrock Mantle API key. That could send the provider bearer token to a caller-controlled host if not constrained. No issues have been fixed yet, so the PR still carries a significant open security risk. Open issues (1)
Fixed/addressed: 0 · PR risk: 8/10 |
Summary
BedrockMantleResponsesAPIConfigsolitellm.responses()and proxy/v1/responsescall Bedrock Mantle's native/openai/v1/responsesinstead of falling back to chat completions.bedrock_mantleapi_base from.../v1to.../openai/v1(chat and responses).Test plan
poetry run pytest tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_transformation.py -q/v1/responseswithbedrock_mantle/<model>logshttps://bedrock-mantle.{region}.api.aws/openai/v1/responsesFixes #29463