llama-index llms bedrock integration
Project Links
Meta
Author: Your Name
Requires Python: <4.0,>=3.10
Classifiers
LlamaIndex Llms Integration: Bedrock
Installation
%pip install llama-index-llms-bedrock
!pip install llama-index
Basic Usage
from llama_index.llms.bedrock import Bedrock
# Set your AWS profile name
profile_name = "Your aws profile name"
# Simple completion call
resp = Bedrock(
model="amazon.titan-text-express-v1", profile_name=profile_name
).complete("Paul Graham is ")
print(resp)
# Expected output:
# Paul Graham is a computer scientist and entrepreneur, best known for co-founding
# the Silicon Valley startup incubator Y Combinator. He is also a prominent writer
# and speaker on technology and business topics...
Call chat with a list of messages
from llama_index.core.llms import ChatMessage
from llama_index.llms.bedrock import Bedrock
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality"
),
ChatMessage(role="user", content="Tell me a story"),
]
resp = Bedrock(
model="amazon.titan-text-express-v1", profile_name=profile_name
).chat(messages)
print(resp)
# Expected output:
# assistant: Alright, matey! Here's a story for you: Once upon a time, there was a pirate
# named Captain Jack Sparrow who sailed the seas in search of his next adventure...
Streaming
Using stream_complete endpoint
from llama_index.llms.bedrock import Bedrock
llm = Bedrock(model="amazon.titan-text-express-v1", profile_name=profile_name)
resp = llm.stream_complete("Paul Graham is ")
for r in resp:
print(r.delta, end="")
# Expected Output (Stream):
# Paul Graham is a computer programmer, entrepreneur, investor, and writer, best known
# for co-founding the internet firm Y Combinator...
Streaming chat
from llama_index.llms.bedrock import Bedrock
llm = Bedrock(model="amazon.titan-text-express-v1", 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="")
# Expected Output (Stream):
# Once upon a time, there was a pirate with a colorful personality who sailed the
# high seas in search of adventure...
Configure Model
from llama_index.llms.bedrock import Bedrock
llm = Bedrock(model="amazon.titan-text-express-v1", profile_name=profile_name)
resp = llm.complete("Paul Graham is ")
print(resp)
# Expected Output:
# Paul Graham is a computer scientist, entrepreneur, investor, and writer. He co-founded
# Viaweb, the first commercial web browser...
Connect to Bedrock with Access Keys
from llama_index.llms.bedrock import Bedrock
llm = Bedrock(
model="amazon.titan-text-express-v1",
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, e.g. us-east-1",
)
resp = llm.complete("Paul Graham is ")
print(resp)
# Expected Output:
# Paul Graham is an American computer scientist, entrepreneur, investor, and author,
# best known for co-founding Viaweb, the first commercial web browser...
LLM Implementation example
0.5.0
Mar 12, 2026
0.4.2
Sep 08, 2025
0.4.1
Aug 08, 2025
0.4.0
Jul 31, 2025
0.3.8
Mar 26, 2025
0.3.7
Mar 24, 2025
0.3.6
Mar 20, 2025
0.3.5
Mar 19, 2025
0.3.4
Feb 27, 2025
0.3.3
Dec 17, 2024
0.3.2
Dec 17, 2024
0.3.1
Nov 18, 2024
0.3.0
Nov 18, 2024
0.2.6
Nov 05, 2024
0.2.5
Oct 29, 2024
0.2.4
Oct 25, 2024
0.2.3
Oct 25, 2024
0.2.2
Oct 08, 2024
0.2.1
Aug 30, 2024
0.2.0
Aug 22, 2024
0.1.13
Aug 20, 2024
0.1.12
Jul 08, 2024
0.1.11
Jul 05, 2024
0.1.10
Jul 01, 2024
0.1.9
Jun 18, 2024
0.1.8
May 14, 2024
0.1.7
Apr 23, 2024
0.1.6
Apr 13, 2024
0.1.5
Mar 19, 2024
0.1.4
Mar 16, 2024
0.1.3
Feb 21, 2024
0.1.2
Feb 20, 2024
0.1.1
Feb 12, 2024
0.1.0
Feb 10, 2024
0.0.1
Feb 03, 2024
Wheel compatibility matrix
Files in release
Extras:
None
Dependencies:
boto3
(<2,>=1.34.26)
llama-index-core
(<0.15,>=0.13.0)
llama-index-llms-anthropic
(<0.9,>=0.8.0)