# The smallest Amazon Bedrock call in Python (Converse API)

> Source: <https://dev.to/ramsuryach/the-smallest-amazon-bedrock-call-in-python-converse-api-71c>
> Published: 2026-12-04 13:00:00+00:00

**Recommendation:** Build agent loops around the Converse API by checking stopReason for tool_use, executing the requested tool, and calling again, and always cap the number of turns to prevent infinite loops.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

If Amazon Bedrock feels big, start with one function call. This is the smallest useful thing you can do with it from Python: send a message to a model and read the answer. Once this works, everything else (tools, agents, guardrails) is the same call with more around it.

`aws configure`), for an IAM user or role that can call Bedrock

```
python3 -m venv .venv && source .venv/bin/activate
pip install boto3
```

Find a model ID or inference profile you can call in your Region:

```
aws bedrock list-inference-profiles --region us-east-1 \
  --query "inferenceProfileSummaries[].inferenceProfileId" --output text
python
import boto3

client = boto3.client("bedrock-runtime", region_name="us-east-1")

response = client.converse(
    modelId="PASTE_YOUR_MODEL_ID_HERE",
    messages=[
        {"role": "user", "content": [{"text": "Explain what an AWS Region is in two sentences."}]}
    ],
    inferenceConfig={"maxTokens": 200, "temperature": 0.3},
)

print(response["output"]["message"]["content"][0]["text"])
print(response["stopReason"])
print(response["usage"])
```

Three things to notice:

`messages` is a list of turns.`converse` again.`stopReason` tells you why the model stopped.`end_turn`. Hold on to this field, because it becomes important in a minute.`usage` has the token counts.
The same call takes a `toolConfig`. You describe a tool, and the model can ask for it:

```
tool_config = {
    "tools": [{
        "toolSpec": {
            "name": "read_note",
            "description": "Read one note file by name, for example week1.md.",
            "inputSchema": {"json": {
                "type": "object",
                "properties": {"name": {"type": "string"}},
                "required": ["name"],
            }},
        }
    }]
}
```

Pass it as `toolConfig=tool_config`. Now there's a new possible `stopReason`: `tool_use`. When you see it, the model hasn't answered yet. It's asking *your code* to run the tool and send the result back.

That's the whole idea of an agent: call, check `stopReason`, run the tool if asked, call again. One rule I'd add from day one: put a turn limit on the loop, so a bug can't make it run forever.

What was the first thing you made a model do from code? And if you've used the Converse API with tools, what tripped you up first? I'd like to hear it in the comments.
