-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
I try to to create a minimal agent with pre-configured boto3 client as described here: https://ai.pydantic.dev/models/bedrock/#provider-argument.
Callstack:
$ uv run main.py
Traceback (most recent call last):
File "/home/jtremesay/projects/llm_sandbox/main.py", line 21, in <module>
run(main())
~~~^^^^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/home/jtremesay/projects/llm_sandbox/main.py", line 16, in main
response = await agent.run("What color is Henri IV's white horse?")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_ai/agent/abstract.py", line 235, in run
async for node in agent_run:
...<4 lines>...
await event_stream_handler(_agent_graph.build_run_context(agent_run.ctx), stream)
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_ai/run.py", line 150, in __anext__
next_node = await self._graph_run.__anext__()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_graph/graph.py", line 758, in __anext__
return await self.next(self._next_node)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_graph/graph.py", line 731, in next
self._next_node = await node.run(ctx)
^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_ai/_agent_graph.py", line 397, in run
return await self._make_request(ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_ai/_agent_graph.py", line 439, in _make_request
model_response = await ctx.deps.model.request(message_history, model_settings, model_request_parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_ai/models/bedrock.py", line 272, in request
response = await self._messages_create(messages, False, settings, model_request_parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/pydantic_ai/models/bedrock.py", line 414, in _messages_create
model_response = await anyio.to_thread.run_sync(functools.partial(self.client.converse, **params))
^^^^^^^^^^^^^^^^^^^^
File "/home/jtremesay/projects/llm_sandbox/.venv/lib/python3.13/site-packages/botocore/client.py", line 969, in __getattr__
raise AttributeError(
f"'{self.__class__.__name__}' object has no attribute '{item}'"
)
AttributeError: 'Bedrock' object has no attribute 'converse'Example Code
from asyncio import run
import boto3
from pydantic_ai.agent import Agent
from pydantic_ai.models.bedrock import BedrockConverseModel
from pydantic_ai.providers.bedrock import BedrockProvider
model_name = "eu.anthropic.claude-3-haiku-20240307-v1:0"
bedrock_client = boto3.client("bedrock")
provider = BedrockProvider(bedrock_client=bedrock_client)
model = BedrockConverseModel(provider=provider, model_name=model_name)
agent = Agent(model=model)
async def main():
response = await agent.run("What color is Henri IV's white horse?")
print(response.output)
if __name__ == "__main__":
run(main())Python, Pydantic AI & LLM client version
$ uv run python --version
Python 3.13.7
$ uv pip freeze
annotated-types==0.7.0
anyio==4.11.0
boto3==1.40.51
botocore==1.40.51
certifi==2025.10.5
colorama==0.4.6
genai-prices==0.0.31
griffe==1.14.0
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
idna==3.11
importlib-metadata==8.7.0
jmespath==1.0.1
logfire-api==4.13.2
opentelemetry-api==1.37.0
pydantic==2.12.1
pydantic-ai-slim==1.0.18
pydantic-core==2.41.3
pydantic-graph==1.0.18
python-dateutil==2.9.0.post0
s3transfer==0.14.0
six==1.17.0
sniffio==1.3.1
typing-extensions==4.15.0
typing-inspection==0.4.2
urllib3==2.5.0
zipp==3.23.0