llama-index-llms-bedrock-converse 0.14.17


pip install llama-index-llms-bedrock-converse

  Latest version

Released: Jul 24, 2026

Project Links

Meta
Author: Your Name
Requires Python: <4.0,>=3.10

Classifiers

LlamaIndex Llms Integration: Bedrock Converse

Installation

%pip install llama-index-llms-bedrock-converse
!pip install llama-index

Usage

from llama_index.llms.bedrock_converse import BedrockConverse

# Set your AWS profile name
profile_name = "Your aws profile name"

# Simple completion call
resp = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    profile_name=profile_name,
).complete("Paul Graham is ")
print(resp)

Call chat with a list of messages

from llama_index.core.llms import ChatMessage
from llama_index.llms.bedrock_converse import BedrockConverse

messages = [
    ChatMessage(
        role="system", content="You are a pirate with a colorful personality"
    ),
    ChatMessage(role="user", content="Tell me a story"),
]

resp = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    profile_name=profile_name,
).chat(messages)
print(resp)

Streaming

# Using stream_complete endpoint
from llama_index.llms.bedrock_converse import BedrockConverse

llm = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    profile_name=profile_name,
)
resp = llm.stream_complete("Paul Graham is ")
for r in resp:
    print(r.delta, end="")

# Using stream_chat endpoint
from llama_index.llms.bedrock_converse import BedrockConverse

llm = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    profile_name=profile_name,
)
messages = [
    ChatMessage(
        role="system", content="You are a pirate with a colorful personality"
    ),
    ChatMessage(role="user", content="Tell me a story"),
]
resp = llm.stream_chat(messages)
for r in resp:
    print(r.delta, end="")

Configure Model

from llama_index.llms.bedrock_converse import BedrockConverse

llm = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    profile_name=profile_name,
)
resp = llm.complete("Paul Graham is ")
print(resp)

Connect to Bedrock with Access Keys

from llama_index.llms.bedrock_converse import BedrockConverse

llm = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    aws_access_key_id="AWS Access Key ID to use",
    aws_secret_access_key="AWS Secret Access Key to use",
    aws_session_token="AWS Session Token to use",
    region_name="AWS Region to use, eg. us-east-1",
)

resp = llm.complete("Paul Graham is ")
print(resp)

Use an Application Inference Profile

AWS Bedrock supports Application Inference Profiles which are a sort of provisioned proxy to Bedrock LLMs.

Since these profile ARNs are account-specific, they must be handled specially in BedrockConverse.

When an application inference profile is created as an AWS resource, it references an existing Bedrock foundation model or a cross-region inference profile. The referenced model must be provided to the BedrockConverse initializer as the model argument, and the ARN of the application inference profile must be provided as the application_inference_profile_arn argument.

Important: BedrockConverse does not validate that the model argument in fact matches the underlying model referenced by the application inference profile provided. The caller is responsible for making sure they match. Behavior when they do not match is undefined.

# Assumes the existence of a provisioned application inference profile
# that references a foundation model or cross-region inference profile.

from llama_index.llms.bedrock_converse import BedrockConverse


# Instantiate the BedrockConverse model
# with the model and application inference profile
# Make sure the model is the one that the
# application inference profile refers to in AWS
llm = BedrockConverse(
    model="us.anthropic.claude-3-5-sonnet-20240620-v1:0",  # this is the referenced model/profile
    application_inference_profile_arn="arn:aws:bedrock:us-east-1:012345678901:application-inference-profile/fake-profile-name",
)

Function Calling

# Claude, Command, and Mistral Large models support native function calling through AWS Bedrock Converse.
# There is seamless integration with LlamaIndex tools through the predict_and_call function on the LLM.

from llama_index.llms.bedrock_converse import BedrockConverse
from llama_index.core.tools import FunctionTool


# Define some functions
def multiply(a: int, b: int) -> int:
    """Multiply two integers and return the result"""
    return a * b


def mystery(a: int, b: int) -> int:
    """Mystery function on two integers."""
    return a * b + a + b


# Create tools from functions
mystery_tool = FunctionTool.from_defaults(fn=mystery)
multiply_tool = FunctionTool.from_defaults(fn=multiply)

# Instantiate the BedrockConverse model
llm = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    profile_name=profile_name,
)

# Use function tools with the LLM
response = llm.predict_and_call(
    [mystery_tool, multiply_tool],
    user_msg="What happens if I run the mystery function on 5 and 7",
)
print(str(response))

response = llm.predict_and_call(
    [mystery_tool, multiply_tool],
    user_msg=(
        """What happens if I run the mystery function on the following pairs of numbers?
        Generate a separate result for each row:
        - 1 and 2
        - 8 and 4
        - 100 and 20

        NOTE: you need to run the mystery function for all of the pairs above at the same time"""
    ),
    allow_parallel_tool_calls=True,
)
print(str(response))

for s in response.sources:
    print(f"Name: {s.tool_name}, Input: {s.raw_input}, Output: {str(s)}")

Async usage

from llama_index.llms.bedrock_converse import BedrockConverse

llm = BedrockConverse(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    aws_access_key_id="AWS Access Key ID to use",
    aws_secret_access_key="AWS Secret Access Key to use",
    aws_session_token="AWS Session Token to use",
    region_name="AWS Region to use, eg. us-east-1",
)

# Use async complete
resp = await llm.acomplete("Paul Graham is ")
print(resp)

Prompt Caching System and regular messages

You can cache normal and system messages by placing cache points strategically:

from llama_index.core.llms import ChatMessage
from llama_index.core.base.llms.types import (
    TextBlock,
    CacheControl,
    CachePoint,
    MessageRole,
)

# Cache expensive context but keep dynamic instructions uncached
cached_context = (
    """[Large context about company policies, knowledge base, etc...]"""
)
dynamic_instructions = (
    "Today's date is 2024-01-15. Focus on recent developments."
)
document_text = "[Long document]"
messages = [
    ChatMessage(
        role=MessageRole.SYSTEM,
        blocks=[
            TextBlock(text=cached_context),
            CachePoint(cache_control=CacheControl(type="default")),
            TextBlock(text=dynamic_instructions),
        ],
    ),
    ChatMessage(
        role=MessageRole.USER,
        blocks=[
            TextBlock(
                text=f"{document_text}",
                type="text",
            ),
            CachePoint(cache_control=CacheControl(type="default")),
            TextBlock(
                text="What's our current policy on remote work?",
                type="text",
            ),
        ],
    ),
]

response = llm.chat(messages)

LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/bedrock_converse/

0.14.17 Jul 24, 2026
0.14.16 Jul 01, 2026
0.14.15 Jun 30, 2026
0.14.14 Jun 17, 2026
0.14.13 May 28, 2026
0.14.12 May 28, 2026
0.14.11 May 15, 2026
0.14.10 May 08, 2026
0.14.9 Apr 21, 2026
0.14.8 Apr 21, 2026
0.14.7 Apr 21, 2026
0.14.6 Apr 16, 2026
0.14.5 Apr 01, 2026
0.14.4 Mar 30, 2026
0.14.3 Mar 20, 2026
0.14.2 Mar 13, 2026
0.14.1 Mar 13, 2026
0.14.0 Mar 12, 2026
0.13.0 Mar 03, 2026
0.12.11 Feb 18, 2026
0.12.10 Feb 17, 2026
0.12.9 Feb 12, 2026
0.12.8 Feb 10, 2026
0.12.7 Feb 05, 2026
0.12.6 Feb 02, 2026
0.12.5 Jan 28, 2026
0.12.4 Jan 06, 2026
0.12.3 Dec 14, 2025
0.12.2 Nov 28, 2025
0.12.1 Nov 27, 2025
0.12.0 Nov 21, 2025
0.11.1 Nov 10, 2025
0.11.0 Nov 03, 2025
0.10.7 Oct 29, 2025
0.10.6 Oct 28, 2025
0.10.5 Oct 15, 2025
0.10.4 Oct 14, 2025
0.10.3 Oct 13, 2025
0.10.2 Oct 10, 2025
0.10.1 Oct 04, 2025
0.10.0 Oct 04, 2025
0.9.5 Sep 30, 2025
0.9.4 Sep 29, 2025
0.9.3 Sep 29, 2025
0.9.2 Sep 08, 2025
0.9.1 Sep 07, 2025
0.9.0 Sep 04, 2025
0.8.3 Aug 24, 2025
0.8.2 Aug 12, 2025
0.8.1 Aug 08, 2025
0.8.0 Jul 30, 2025
0.7.6 Jul 16, 2025
0.7.5 Jul 10, 2025
0.7.4 Jun 29, 2025
0.7.3 Jun 26, 2025
0.7.2 Jun 13, 2025
0.7.1 Jun 03, 2025
0.7.0 May 30, 2025
0.6.1 May 29, 2025
0.6.0 May 23, 2025
0.5.6 May 20, 2025
0.5.5 May 20, 2025
0.5.4 May 19, 2025
0.5.3 May 18, 2025
0.5.2 May 16, 2025
0.5.1 May 15, 2025
0.5.0 May 01, 2025
0.4.15 Apr 04, 2025
0.4.14 Apr 04, 2025
0.4.13 Mar 20, 2025
0.4.12 Mar 19, 2025
0.4.11 Mar 19, 2025
0.4.10 Mar 17, 2025
0.4.9 Mar 17, 2025
0.4.8 Mar 04, 2025
0.4.7 Feb 27, 2025
0.4.6 Feb 25, 2025
0.4.5 Jan 28, 2025
0.4.4 Jan 24, 2025
0.4.3 Dec 24, 2024
0.4.2 Dec 17, 2024
0.4.1 Dec 03, 2024
0.4.0 Nov 18, 2024
0.3.9 Nov 13, 2024
0.3.8 Nov 07, 2024
0.3.7 Nov 05, 2024
0.3.6 Oct 29, 2024
0.3.5 Oct 28, 2024
0.3.4 Oct 25, 2024
0.3.3 Oct 25, 2024
0.3.2 Oct 08, 2024
0.3.1 Sep 13, 2024
0.3.0 Sep 06, 2024
0.2.3 Aug 29, 2024
0.2.2 Aug 26, 2024
0.2.1 Aug 22, 2024
0.2.0 Aug 22, 2024
0.1.6 Jul 23, 2024
0.1.5 Jul 19, 2024
0.1.4 Jun 28, 2024
0.1.3 Jun 21, 2024
0.1.2 Jun 19, 2024
0.1.1 Jun 18, 2024
0.1.0 Jun 17, 2024
Extras:
Dependencies:
boto3 (<2,>=1.38.27)
llama-index-core (<0.15,>=0.14.5)