{"slug": "the-smallest-amazon-bedrock-call-in-python-converse-api", "title": "The smallest Amazon Bedrock call in Python (Converse API)", "summary": "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.", "body_md": "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.\n\n`aws configure`), for an IAM user or role that can call Bedrock\n\n```\npython3 -m venv .venv && source .venv/bin/activate\npip install boto3\n```\n\nFind a model ID or inference profile you can call in your Region:\n\n```\naws bedrock list-inference-profiles --region us-east-1 \\\n  --query \"inferenceProfileSummaries[].inferenceProfileId\" --output text\npython\nimport boto3\n\nclient = boto3.client(\"bedrock-runtime\", region_name=\"us-east-1\")\n\nresponse = client.converse(\n    modelId=\"PASTE_YOUR_MODEL_ID_HERE\",\n    messages=[\n        {\"role\": \"user\", \"content\": [{\"text\": \"Explain what an AWS Region is in two sentences.\"}]}\n    ],\n    inferenceConfig={\"maxTokens\": 200, \"temperature\": 0.3},\n)\n\nprint(response[\"output\"][\"message\"][\"content\"][0][\"text\"])\nprint(response[\"stopReason\"])\nprint(response[\"usage\"])\n```\n\nThree things to notice:\n\n`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.\nThe same call takes a `toolConfig`. You describe a tool, and the model can ask for it:\n\n```\ntool_config = {\n    \"tools\": [{\n        \"toolSpec\": {\n            \"name\": \"read_note\",\n            \"description\": \"Read one note file by name, for example week1.md.\",\n            \"inputSchema\": {\"json\": {\n                \"type\": \"object\",\n                \"properties\": {\"name\": {\"type\": \"string\"}},\n                \"required\": [\"name\"],\n            }},\n        }\n    }]\n}\n```\n\nPass 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.\n\nThat'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.\n\nWhat 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.", "url": "https://wpnews.pro/news/the-smallest-amazon-bedrock-call-in-python-converse-api", "canonical_source": "https://dev.to/ramsuryach/the-smallest-amazon-bedrock-call-in-python-converse-api-71c", "published_at": "2026-12-04 13:00:00+00:00", "updated_at": "2026-12-04 13:14:16.299477+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "large-language-models", "developer-tools"], "entities": ["Amazon Bedrock", "AWS", "boto3", "Converse API"], "also_reported_by": [], "takeaway": "Bedrock's Converse API handles both plain messages and tool use through one call: pass toolConfig, then branch on stopReason, running the tool and calling again when it returns tool_use, with a turn limit to bound the loop.", "recommendation": {"advice": "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.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/the-smallest-amazon-bedrock-call-in-python-converse-api", "markdown": "https://wpnews.pro/news/the-smallest-amazon-bedrock-call-in-python-converse-api.md", "text": "https://wpnews.pro/news/the-smallest-amazon-bedrock-call-in-python-converse-api.txt", "jsonld": "https://wpnews.pro/news/the-smallest-amazon-bedrock-call-in-python-converse-api.jsonld"}}