Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/aws-samples/bedrock-access-gateway
/ functions
Functions
48 in github.com/aws-samples/bedrock-access-gateway
⨍
Functions
48
◇
Types & classes
40
↳
Endpoints
5
↓ 7 callers
Method
_resolve_to_foundation_model
Resolve any model identifier to foundation model ID for feature detection. Handles: - Cross-region profiles (us.*, eu.*, apa
src/api/models/bedrock.py:253
↓ 4 callers
Method
_create_response
( self, model: str, message_id: str, content: list[dict] | None = None,
src/api/models/bedrock.py:912
↓ 4 callers
Method
stream_response_to_bytes
(response: ChatStreamResponse | Error | None = None)
src/api/models/base.py:50
↓ 3 callers
Method
_invoke_model
(self, args: dict, model_id: str)
src/api/models/bedrock.py:1288
↓ 2 callers
Method
_convert_finish_reason
Below is a list of finish reason according to OpenAI doc: - stop: if the model hit a natural stop point or a provided stop sequence,
src/api/models/bedrock.py:1259
↓ 2 callers
Method
_invoke_bedrock
Common logic for invoke bedrock models
src/api/models/bedrock.py:335
↓ 2 callers
Method
_parse_content_parts
( self, message: UserMessage | AssistantMessage, model_id: str, )
src/api/models/bedrock.py:1187
↓ 2 callers
Method
_supports_prompt_caching
Check if model supports prompt caching based on model ID pattern. Uses pattern matching instead of hardcoded whitelist for better ma
src/api/models/bedrock.py:275
↓ 2 callers
Method
generate_message_id
()
src/api/models/base.py:46
↓ 2 callers
Function
list_bedrock_models
Automatically getting a list of supported models. Returns a model list combines: - ON_DEMAND models. - Cross-Region Inference Pro
src/api/models/bedrock.py:111
↓ 2 callers
Method
list_models
Return a list of supported models
src/api/models/base.py:27
↓ 1 callers
Method
_async_iterate
Helper method to convert sync iterator to async iterator
src/api/models/bedrock.py:411
↓ 1 callers
Method
_calc_budget_tokens
( self, max_tokens: int, reasoning_effort: Literal["low", "medium", "high"] )
src/api/models/bedrock.py:1245
↓ 1 callers
Method
_convert_tool_spec
(self, func: Function)
src/api/models/bedrock.py:1234
↓ 1 callers
Method
_create_response_stream
Parsing the Bedrock stream response chunk. Ref: https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html#message-infe
src/api/models/bedrock.py:1005
↓ 1 callers
Method
_estimate_reasoning_tokens
Estimate reasoning tokens from reasoningContent blocks. Bedrock doesn't separately report reasoning tokens, so we estimate t
src/api/models/bedrock.py:895
↓ 1 callers
Method
_extract_tool_content
Extract text content from various OpenAI SDK tool message formats. Handles: - String content (legacy format) - List of conten
src/api/models/bedrock.py:618
↓ 1 callers
Method
_get_max_cache_tokens
Get maximum cacheable tokens limit for the model. Different models have different caching limits: - Claude: No explicit limi
src/api/models/bedrock.py:310
↓ 1 callers
Method
_parse_args
(self, embeddings_request: EmbeddingsRequest)
src/api/models/bedrock.py:1341
↓ 1 callers
Method
_parse_args
(self, embeddings_request: EmbeddingsRequest)
src/api/models/bedrock.py:1386
↓ 1 callers
Method
_parse_args
(self, text: str, dimensions: int | None = None)
src/api/models/bedrock.py:1430
↓ 1 callers
Method
_parse_image
Try to get the raw data from an image url. Ref: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ImageSource.html
src/api/models/bedrock.py:1158
↓ 1 callers
Method
_parse_messages
Converse API only support user and assistant messages. example output: [{ "role": "user", "content": [{"text
src/api/models/bedrock.py:530
↓ 1 callers
Method
_parse_request
Create default converse request body. Also perform validations to tool call etc. Ref: https://docs.aws.amazon.com/bedrock/latest/API
src/api/models/bedrock.py:767
↓ 1 callers
Method
_parse_system_prompts
Create system prompts with optional prompt caching support. Prompt caching can be enabled via: 1. ENABLE_PROMPT_CACHING environment v
src/api/models/bedrock.py:465
↓ 1 callers
Method
_reframe_multi_payloard
Receive messages and reformat them to comply with the Claude format With OpenAI format requests, it's not a problem to repeatedly receive mes
src/api/models/bedrock.py:669
↓ 1 callers
Method
chat
Default implementation for Chat API.
src/api/models/bedrock.py:373
↓ 1 callers
Method
chat_stream
Default implementation for Chat Stream API
src/api/models/bedrock.py:417
↓ 1 callers
Method
embed
Handle a basic embeddings request.
src/api/models/base.py:73
↓ 1 callers
Function
get_embeddings_model
(model_id: str)
src/api/models/bedrock.py:1509
↓ 1 callers
Method
is_supported_modality
(model_id: str, modality: str = "IMAGE")
src/api/models/bedrock.py:1227
↓ 1 callers
Method
validate
Perform basic validation on requests
src/api/models/bedrock.py:221
↓ 1 callers
Function
validate_model_id
(model_id: str)
src/api/routers/model.py:18
Method
_create_response
( self, embeddings: list[float], model: str, input_tokens: int = 0, ou
src/api/models/bedrock.py:1310
Function
api_key_auth
( credentials: Annotated[HTTPAuthorizationCredentials, Depends(security)], )
src/api/auth.py:39
Method
chat
Handle a basic chat completion requests.
src/api/models/base.py:36
Function
chat_completions
( chat_request: Annotated[ ChatRequest, Body( examples=[ {
src/api/routers/chat.py:21
Method
chat_stream
Handle a basic chat completion requests with stream response.
src/api/models/base.py:41
Method
embed
(self, embeddings_request: EmbeddingsRequest)
src/api/models/bedrock.py:1370
Method
embed
(self, embeddings_request: EmbeddingsRequest)
src/api/models/bedrock.py:1410
Method
embed
(self, embeddings_request: EmbeddingsRequest)
src/api/models/bedrock.py:1446
Function
embeddings
( embeddings_request: Annotated[ EmbeddingsRequest, Body( examples=[
src/api/routers/embeddings.py:17
Function
get_model
( model_id: Annotated[ str, Path(description="Model ID", example="anthropic.claude-3-sonne
src/api/routers/model.py:33
Function
health
For health check if needed
src/api/app.py:49
Function
list_models
()
src/api/routers/model.py:24
Method
list_models
Always refresh the latest model list
src/api/models/bedrock.py:215
Method
validate
Validate chat completion requests.
src/api/models/base.py:31
Function
validation_exception_handler
(request, exc)
src/api/app.py:55