Hands-On: Call a Model with the Converse API
Send your first prompt from Python using one API that works across models.
The Converse API gives every chat model on Bedrock the same request and response shape, so switching models
really is just changing the modelId.
Before you start:
- Your IAM identity needs
bedrock:InvokeModelpermission. - Some model providers ask you to accept their terms or submit a short use-case form the first time. Check the Model access page in the Bedrock console.
- Copy the exact model ID from the console's model catalog. Some models must be called through a
cross-Region inference profile, whose ID has a geographic prefix such as
us..
Try it
import boto3
client = boto3.client("bedrock-runtime", region_name="us-east-1")
MODEL_ID = "anthropic.claude-opus-5-5" # swap in any chat model ID from the console
response = client.converse(
modelId=MODEL_ID,
system=[{"text": "You are a friendly tutor. Answer in at most 3 short sentences."}],
messages=[
{"role": "user", "content": [{"text": "What is the difference between RAG and fine-tuning?"}]}
],
inferenceConfig={"maxTokens": 300},
)
print(response["output"]["message"]["content"][0]["text"])
print("Tokens used:", response["usage"])Reading the code
system: standing instructions for the whole conversation.messages: the conversation so far. For a follow-up question, append the assistant's reply and the next user message, then callconverseagain.inferenceConfig.maxTokens: a cap on the response length, which also caps cost.response["usage"]: token counts, which are exactly what you're billed for.
For chat UIs, use converse_stream to show the answer word by word as it's generated, instead of waiting for
the whole response.
If you're only using Claude models and want Anthropic-specific features, Anthropic's own SDK can also call Claude on Bedrock. The Converse API is the better choice when you want to switch between model providers.
Key takeaways
- Converse gives all chat models the same request and response format.
- Model access and exact model IDs come from the Bedrock console.
- Use maxTokens to cap length and cost, and converse_stream for live output.
Check your understanding
Pick an answer to see the explanation.
1. How do you switch your app from one Bedrock chat model to another when using Converse?
2. You want the model to remember the previous question. What do you do?