Skip to content

Add Transparent HTTP Proxy Mode for Native Bedrock API Access #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LionsAd
Copy link
Contributor

@LionsAd LionsAd commented Aug 7, 2025

Summary

  • Add transparent HTTP proxy mode for direct AWS Bedrock API access
  • Single universal endpoint handles all Bedrock endpoints automatically
  • Pure passthrough with zero parsing - just auth swap and URL rewrite
  • Future-proof design works with any new AWS Bedrock features

Closes #170

Implementation Details

  • New bedrock_proxy.py router with universal /bedrock/model/{model_id}/{endpoint_path:path} endpoint
  • Environment variable AWS_BEARER_TOKEN_BEDROCK enables transparent proxy mode
  • Forwards all headers, methods, query params, and body content as-is
  • Automatic streaming detection and handling
  • Added httpx dependency for async HTTP client

Token Authentication Approach

Uses AWS_BEARER_TOKEN_BEDROCK environment variable for simplicity. While extracting tokens from boto3 client is theoretically possible, it's very complicated due to credential chain complexity, session management, and token refresh logic. The environment variable approach provides a clean, predictable solution.

Benefits

  • Perfect AWS compatibility - Always matches official AWS API exactly
  • Zero maintenance overhead - New AWS features work automatically
  • Better performance - No JSON parsing/reconstruction overhead
  • Broader compatibility - Handles all HTTP methods, headers, query params
  • Future-proof - Works with any future Bedrock API changes

Test Plan

  • Health check endpoint works
  • OpenAI-compatible endpoints still functional
  • Transparent proxy mode with AWS bearer token
  • All HTTP methods supported (GET, POST, PUT, DELETE, PATCH)
  • Streaming responses work correctly
  • Headers forwarded properly
  • Error handling for missing AWS token

🤖 Generated with Claude Code

@LionsAd LionsAd force-pushed the issue-170--add-transparent-proxy-support branch from 1109077 to 6375126 Compare August 7, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Transparent HTTP Proxy Mode for Native Bedrock API Access
1 participant