ReqLLM.Providers.AmazonBedrock.Converse (ReqLLM v1.0.0)
View SourceAWS Bedrock Converse API support for unified tool calling across models.
The Converse API provides a standardized interface for tool calling that works across all Bedrock models (Anthropic, OpenAI, Meta, etc.) with consistent request/response formats.
Advantages
- Unified tool calling across all Bedrock models
- Simpler, cleaner API compared to model-specific endpoints
- Better multi-turn conversation handling
Disadvantages
- May lag behind model-specific endpoints for cutting-edge features
- Adds small translation overhead (typically low milliseconds)
API Format
Request:
{
"messages": [
{"role": "user", "content": [{"text": "Hello"}]}
],
"system": [{"text": "You are a helpful assistant"}],
"inferenceConfig": {
"maxTokens": 1000,
"temperature": 0.7
},
"toolConfig": {
"tools": [
{
"toolSpec": {
"name": "get_weather",
"description": "Get weather",
"inputSchema": {
"json": {
"type": "object",
"properties": {...},
"required": [...]
}
}
}
}
]
}
}Response:
{
"output": {
"message": {
"role": "assistant",
"content": [
{"text": "Let me check the weather"},
{
"toolUse": {
"toolUseId": "id123",
"name": "get_weather",
"input": {"location": "SF"}
}
}
]
}
},
"stopReason": "tool_use",
"usage": {
"inputTokens": 100,
"outputTokens": 50,
"totalTokens": 150
}
}
Summary
Functions
Format a ReqLLM context into Bedrock Converse API format.
Parse a Converse API response into ReqLLM format.
Parse a Converse API streaming chunk.
Functions
Format a ReqLLM context into Bedrock Converse API format.
Converts ReqLLM messages and tools into the Converse API request structure.
For :object operations, creates a synthetic "structured_output" tool to leverage unified tool calling for structured JSON output across all models.
Parse a Converse API response into ReqLLM format.
Converts Converse API response structure back to ReqLLM.Response with proper Message and ContentPart structures.
For :object operations, extracts the structured output from the tool call.
Parse a Converse API streaming chunk.
Handles different event types from the Converse stream. Events are already decoded by AWSEventStream.parse_binary before reaching this function.