Is your feature request related to a problem? Please describe.
Implement Bedrock V2 Client (ModelClientV2)
Why Implement Bedrock V2 Client?
The current Bedrock client (api_type: "bedrock") uses the legacy ModelClient interface, which returns flattened ChatCompletion responses. This limits access to rich content types and creates inconsistencies across providers.
Current Limitations (V1 Client)
- Lost Rich Content: Tool calls, images, and other structured content are flattened or lost during response processing
- Provider-Specific Parsing: Requires manual parsing of nested structures to access different content types
- No Type Safety: Responses are untyped dictionaries, making it easy to introduce bugs
- Limited Forward Compatibility: New Bedrock features require code changes to support
- Inconsistent API: Different response formats across OpenAI, Anthropic, Gemini, and Bedrock clients
Benefits of V2 Client
-
Rich Content Preservation
- All content types (text, images, tool calls, citations) preserved as typed
ContentBlock objects
- No data loss during response transformation
- Direct access to structured content
-
Better Developer Experience
# V1 - Manual parsing
response = client.create(params)
messages = client.message_retrieval(response)
content = messages[0] if messages else ""
# V2 - Direct property access
response = client.create(params)
text = response.text # All text content
tool_calls = response.get_tool_calls() # Tool calls as objects
images = response.get_content_by_type("image") # Image content blocks
Type Safety
- Pydantic models with automatic validation
- Typed content blocks (
TextContent, ImageContent, ToolCallContent, etc.)
- Enum-based content types
- IDE autocomplete and type checking support
-
Forward Compatibility
- Unknown content types automatically handled via
GenericContent
- No code changes needed when Bedrock adds new features
- Future-proof architecture
-
Provider-Agnostic Format
- Unified response format across OpenAI, Anthropic, Gemini, and Bedrock
- Easier to switch between providers
- Consistent developer experience across all LLM providers
-
Backward Compatible
- Can use
create_v1_compatible() to get V1 format when needed
- Works seamlessly with existing V1 clients in group chats
- No breaking changes to existing code
-
Alignment with AG2 Architecture
- Follows the ModelClientV2 protocol already implemented for OpenAI
- Supports the unified response model across all providers
Use Cases Enabled
- Structured Outputs: Better support for Pydantic models and JSON schemas
- Multimodal Applications: Proper handling of images and other media types
- Tool Calling: Rich access to tool call information
- Cost Tracking: Built-in cost calculation per response
- Future Features: Ready for new Bedrock capabilities without code changes
Migration Path
Migration is simple - just change api_type:
# V1
{"api_type": "bedrock", "model": "...", ...}
V2 (recommended)
{"api_type": "bedrock_v2", "model": "...", ...} # All other configuration parameters remain identical.
Implementation Status
✅ Completed: Bedrock V2 client implementation with full ModelClientV2 protocol support
✅ Completed: Comprehensive unit tests
✅ Completed: Integration tests
✅ Completed: Documentation updates
✅ Completed: Backward compatibility layer
Related
- OpenAI V2 Client: Reference implementation
Describe the solution you'd like
No response
Additional context
No response
Is your feature request related to a problem? Please describe.
Implement Bedrock V2 Client (ModelClientV2)
Why Implement Bedrock V2 Client?
The current Bedrock client (
api_type: "bedrock") uses the legacy ModelClient interface, which returns flattenedChatCompletionresponses. This limits access to rich content types and creates inconsistencies across providers.Current Limitations (V1 Client)
Benefits of V2 Client
Rich Content Preservation
ContentBlockobjectsBetter Developer Experience
Type Safety
TextContent,ImageContent,ToolCallContent, etc.)Forward Compatibility
GenericContentProvider-Agnostic Format
Backward Compatible
create_v1_compatible()to get V1 format when neededAlignment with AG2 Architecture
Use Cases Enabled
Migration Path
Migration is simple - just change
api_type:V2 (recommended)
{"api_type": "bedrock_v2", "model": "...", ...} # All other configuration parameters remain identical.Implementation Status
✅ Completed: Bedrock V2 client implementation with full ModelClientV2 protocol support
✅ Completed: Comprehensive unit tests
✅ Completed: Integration tests
✅ Completed: Documentation updates
✅ Completed: Backward compatibility layer
Related
Describe the solution you'd like
No response
Additional context
No response