Functions
assistant-message
fn (content: Vec
Helper to create an assistant message for the Converse API.
Example
msg ::aws::bedrock::converse/assistant-message("The capital of France is Paris.")
// => Message({role: "assistant", content: [{text: "The capital of France is Paris."}]})
converse
fn (model_id: Str, messages: Vec
Use the Bedrock Converse API for a unified interface across all models.
The Converse API works with any Bedrock model (Claude, Titan, Llama, Mistral, etc.) using the same message format.
Example
// Simple text conversation
result ::aws::bedrock::converse/converse("us.amazon.nova-micro-v1:0", "What is 2+2?")
content result.output.message.content
text first(content).text
// => "4"
// With message history
messages [
{role: "user", content: [{text: "My name is Alice"}]},
{role: "assistant", content: [{text: "Hello Alice!"}]},
{role: "user", content: [{text: "What is my name?"}]}
]
result ::aws::bedrock::converse/converse("us.amazon.nova-micro-v1:0", messages)
// Check usage metrics
result.usage.inputTokens // => 15
result.usage.outputTokens // => 5
converse-stream
fn (model_id: Str, messages: Vec, system: Vec, inference_config: Map, tool_config: Map): HttpResponse | AwsError
fn (model_id: Str, messages: Vec, system: Vec): HttpResponse | AwsError
fn (model_id: Str, messages: Vec): HttpResponse | AwsError
Use the Bedrock Converse API with streaming response.
Returns the raw HTTP response with an event stream body. Note: Streaming requires parsing the AWS Event Stream binary format.
image-content
fn (format: Str, source_bytes: Str): Map
Helper to create an image content block for the Converse API.
Example
block ::aws::bedrock::converse/image-content("png", base64-image-data)
// => {image: {format: "png", source: {bytes: "..."}}}
inference-config
fn (max_tokens: Int, temperature: Dec, top_p: Dec, stop_sequences: Vec): Map
fn (max_tokens: Int, temperature: Dec): Map
fn (max_tokens: Int): Map
Helper to create inference configuration for the Converse API.
Example
// Max tokens only
config ::aws::bedrock::converse/inference-config(100)
// => {maxTokens: 100}
// Max tokens with temperature
config ::aws::bedrock::converse/inference-config(200, 0.5)
// => {maxTokens: 200, temperature: 0.5}
text-content
fn (text: Str): Map
Helper to create a text content block for the Converse API.
Example
block ::aws::bedrock::converse/text-content("Hello")
// => {text: "Hello"}
user-message
fn (content: Vec): Message
fn (text: Str): Message
Helper to create a user message for the Converse API.
Example
msg ::aws::bedrock::converse/user-message("What is the capital of France?")
// => Message({role: "user", content: [{text: "What is the capital of France?"}]})
Types
ContentBlock
ContentBlock type {
text: Str?,
image: Map?,
tool_use: Map?,
tool_result: Map?
}
ConverseResponse
ConverseResponse type {
output: Map?,
stop_reason: StopReason?,
usage: Map?,
metrics: Map?
}
ConverseStreamEvent
ConverseStreamEvent type {
message_start: Map?,
content_block_start: Map?,
content_block_delta: Map?,
content_block_stop: Map?,
message_stop: Map?,
metadata: Map?
}
Message
Message type {
role: Role,
content: Vec
}
Role
Role type "user" | "assistant"
StopReason
StopReason type "end_turn" | "tool_use" | "max_tokens" | "stop_sequence" | "guardrail_intervened" | "content_filtered"
ToolConfig
ToolConfig type {
tools: Vec,
tool_choice: Map?
}