Bedrock Converse API
The Bedrock Converse API is the unified chat format of Amazon Bedrock. The gateway serves it at /bedrock/model/{model}/converse and /converse-stream, so applications written with the AWS SDK's Converse calls can point at the gateway, authenticate with a virtual key instead of AWS credentials, and reach the Bedrock models the gateway serves. The public model name in the path must point at Amazon Bedrock deployments, because the Converse body is forwarded to Bedrock as it is. Requests are signed with the gateway's AWS credentials and forwarded natively, so application teams never handle AWS keys.
Scenario
A team's application already uses the AWS SDK's Converse call. The security team wants the AWS credentials out of the application and every call budgeted per team. The admin registers the Bedrock model on the gateway with the gateway's own AWS role, the team replaces its AWS endpoint with the gateway URL and uses a virtual key, and the application code stays as it is.
Steps
-
Register the Bedrock model. In the Admin UI open Models + Endpoints (
/ui/models-and-endpoints), click Add Model, pick Amazon Bedrock as the Provider, choose the model, set the Public Model Name toclaude-sonnet-5-5, enter the AWS region and credentials (or leave them empty to use the gateway's IAM role) and click Add Model. Inconfig.yamlthe same deployment looks like this.model_list:- model_name: claude-sonnet-5-5spanway_params:model: bedrock/converse/us.anthropic.claude-sonnet-5-5aws_region_name: us-east-1 -
Create a key in Virtual Keys (
/ui/api-keys) with + Create New Key and pick the model under Models. -
Send a Converse request. The model in the path is the public model name.
curl -X POST "http://localhost:4000/bedrock/model/claude-sonnet-5-5/converse" \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"messages": [{"role": "user", "content": [{"text": "Explain a model group in one sentence."}]}],"system": [{"text": "You are concise."}],"inferenceConfig": {"maxTokens": 200, "temperature": 0.2}}' -
Point the AWS SDK at the gateway. Set the SDK's endpoint URL to
http://localhost:4000/bedrock, with no/v1, and give it the virtual key in one of two ways. SetAWS_BEARER_TOKEN_BEDROCKto the key, which recent SDKs send asAuthorization: Bearer <key>. Or pass the key as the AWS access key id with any secret, and the gateway reads it from theCredential=part of the SigV4 header without checking the signature. The boto3 and JavaScript SDK pages have complete examples, including the HTTP/1.1 setting the JavaScript client needs. -
Check the log. Open Logs (
/ui/logs) and find the request with its tokens and cost.
Expected result
{
"output": {"message": {"role": "assistant", "content": [{"text": "A model group is a public name for deployments."}]}},
"stopReason": "end_turn",
"usage": {"inputTokens": 21, "outputTokens": 27, "totalTokens": 48}
}
/converse-stream returns the Bedrock event stream.
Request fields
messages, system, inferenceConfig, toolConfig, additionalModelRequestFields and guardrailConfig are supported.
Converse or Invoke
The bedrock/converse/ prefix forces the Converse API for a model, and plain bedrock/ lets the gateway choose between Converse and Invoke based on the model. Credentials come from AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, an IAM role, web identity, or aws_role_name and aws_session_name on the deployment for role assumption. See the AWS Bedrock provider page.
Errors
Errors the gateway raises itself come back in the OpenAI shape, {"error": {"message": "...", "type": "...", "param": null, "code": "403"}}. That covers a missing or wrong key, a model the key may not use, a used-up budget and a rate limit. A path the gateway cannot read answers 400 with {"detail": {"error": "..."}}. Only errors AWS itself returns keep the Bedrock shape, {"message": "..."}, and its exception name.
| Status | What it means | Fix |
|---|---|---|
400 ValidationException | A field is malformed, for example content is a string instead of a list of blocks. | Follow the Converse request shape. |
| 401 | The virtual key is missing, wrong or expired. | Send Authorization: Bearer <key>. |
| 403 | The key may not call the model. The message reads The requested model '<model>' is not available for this API key, or the model name is invalid. | Add the model to the key in Virtual Keys. |
403 AccessDeniedException | AWS refused the gateway's credentials, which lack bedrock:InvokeModel for this model. | Fix the IAM policy of the gateway's role. |
| 422 | The key, team or user has spent its budget (Budget has been exceeded!). | Raise the budget or wait for it to reset. |
404 ResourceNotFoundException | The public model name is unknown, or the Bedrock model id is not enabled in the region. | Check Models + Endpoints and the model access in the AWS console. |
429 ThrottlingException | Bedrock is throttling, or the key is over its limit. | Add a deployment in another region and keep retries on. |
Logs
Each call is one row on the Logs page (/ui/logs) with its key, team, model group, deployment, tokens, cost, latency and status, failed calls included. Prompt and response text is kept only when the gateway is set to store it, see what the gateway stores. Operator log lines for routing, retries and fallbacks are in the log reference.
Related
- Bedrock Invoke API for the model specific invoke format.
- Bedrock pass-through for any Bedrock runtime path unchanged.
- AWS Bedrock provider page for credentials and regions.
- Chat completions for the OpenAI format of the same models.
Providers
The gateway's endpoint support matrix marks 1 provider integration as supporting this endpoint: