- Newest
- Most votes
- Most comments
There are two main approaches to standardize Amazon Bedrock model invocation parameters across different providers and models:
-
Use the Amazon Bedrock Converse API The Converse API provides a consistent format for requests and responses across all supported large language models on Amazon Bedrock. This eliminates the need to handle different JSON request and response structures for each model provider. However, it's important to note that the Converse API currently only supports text generation models. Embeddings models, image generation models, and other specialized models like reranking still require the InvokeModel API.
-
Use a third-party abstraction layer like LiteLLM LiteLLM is a versatile open source tool that can standardize inputs across different foundation models. It works both as a Python SDK and as a proxy server (AI gateway) for accessing over 100 different foundation models using a standardized format. LiteLLM automatically handles the transformation of your standardized inputs to match each model provider's specific endpoint requirements. It supports Amazon Bedrock APIs, including both InvokeModel and Converse APIs, and works with all foundation models available on Amazon Bedrock, including imported custom models.
For your specific use case of building a multi-model testing platform, you would likely need a hybrid approach:
- For text generation models, you could use the Converse API where possible.
- For other model types (embeddings, reranking, multimodal), you'll need to use InvokeModel with model-specific payloads.
- Consider implementing LiteLLM as an abstraction layer to standardize the interface.
Since there isn't a built-in way to programmatically discover model parameters, you would indeed need to maintain a model registry that maps:
- Model providers and types
- Supported parameters and their constraints
- Request templates for each model type
When using the InvokeModel API, you'll need to transform the payload for each model into a bytestream before adding it to the API request. This transformation varies by programming language but typically involves using JSON serialization functions (like json.dumps() in Python or JSON.stringify() in JavaScript).
For your UI that allows parameter adjustment, you would need to:
- Define parameter constraints per model
- Validate user inputs against these constraints
- Transform the validated parameters into the correct request format for each model
- Handle the response parsing based on the model type
This approach requires more upfront work to map all the model specifications, but it provides the flexibility needed to support the full range of Bedrock models in your testing platform.
Sources
Community | Embed request payloads into Amazon Bedrock's InvokeModel API
Benchmarking customized models on Amazon Bedrock using LLMPerf and LiteLLM | AWS Machine Learning Blog
Community | Getting started with the Amazon Bedrock Converse API
answered a year ago
There’s no Bedrock API that exposes a unified model schema or parameter contract. Each provider defines its own request JSON for InvokeModel, and Bedrock intentionally passes those bodies through unchanged. The only standardized metadata you can retrieve is from ListFoundationModels and GetFoundationModel, which return the model’s providerName, modelId, and supported inputModalities/outputModalities but not parameter definitions. Because of that, teams usually maintain an internal registry that maps model IDs to their supported parameters and validation logic.
—Taz
answered a year ago
Relevant content
asked 2 months ago
- AWS OFFICIALUpdated 2 months ago
