cd /news/ai-agents/the-smallest-amazon-bedrock-call-in-… · home › topics › ai-agents › article
[ARTICLE · art-181788] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

The smallest Amazon Bedrock call in Python (Converse API)

A developer published a walkthrough showing the minimal Python call to Amazon Bedrock's Converse API, using boto3 to send a single message and read back the text, stopReason, and token usage. The post extends the same call with a toolConfig to demonstrate the agent loop: call the model, check stopReason for tool_use, run the requested tool, and call again, with a turn limit recommended to prevent runaway loops.

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 playbook: Designing agent systems
by read2 min views2 publishedDec 4, 2026

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.

── more in #ai-agents 4 stories · sorted by recency
── more on @amazon bedrock 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/the-smallest-amazon-…] indexed:0 read:2min 2026-12-04 · —