> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stigg.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon Bedrock

> Wrap the Bedrock Runtime client to meter and gate Converse API calls to any model Bedrock serves.

Amazon Bedrock serves models from many vendors, such as Anthropic, Amazon, Meta and Mistral, through one AWS API.

## Set up

Wrap an instance of `BedrockRuntimeClient` from `@aws-sdk/client-bedrock-runtime`. The SDK recognizes it automatically.

```typescript theme={null}
import { BedrockRuntimeClient, ConverseCommand } from '@aws-sdk/client-bedrock-runtime';

const bedrock = stigg.wrap(new BedrockRuntimeClient({ region: 'us-east-1' }), {
  stiggContext: { customerId: 'customer-acme', entitlement: { currencyId: 'credits' } },
});

await bedrock.send(
  new ConverseCommand({
    modelId: 'anthropic.claude-sonnet-4-5-20250929-v1:0',
    messages: [{ role: 'user', content: [{ text: 'Summarize this ticket' }] }],
    inferenceConfig: { maxTokens: 1024 },
  }),
);
```

* **Use the Converse API.** `ConverseCommand` and `ConverseStreamCommand` are checked and metered, for every model Bedrock serves. Other commands sent through the same client, such as `InvokeModelCommand`, go through without a check and are not metered. `InvokeModel` returns each model vendor's own response format, so the SDK cannot read its usage.
* **Set the `stiggContext` in `wrap()`.** A Bedrock call takes a command object rather than a parameter object, so it has no place for a `stiggContext`. To serve several customers, wrap a client for each.
* **A streamed call** is reported once, when the stream finishes. Iterate the `stream` property of the response with `for await`.
* **Credentials** come from the standard AWS credential chain, as for any AWS SDK client.

To check against an estimate of the call's usage rather than 1, pass the recipe with an `estimate`, for example from the call's `maxTokens`:

```typescript theme={null}
import { bedrockRecipe } from '@stigg/agent-sdk-js';

const bedrock = stigg.wrap(new BedrockRuntimeClient({ region: 'us-east-1' }), {
  recipe: bedrockRecipe({ estimate: (command) => command?.input?.inferenceConfig?.maxTokens ?? 1 }),
  stiggContext: { customerId: 'customer-acme', entitlement: { currencyId: 'credits' } },
});
```

See [Requested usage](/documentation/ai-agents/llm-wrappers/gating#requested-usage).

## What is reported

Every Converse response includes a `usage` object with the number of tokens the call consumed, in the same format for every model. The wrapper reads it and reports it to Stigg as the metrics below. For details, see AWS's [Converse API reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html).

| Method | Event name |
| - | - |
| `send(ConverseCommand)`, `send(ConverseStreamCommand)` | `bedrock.send` |

| Metric | What it counts |
| - | - |
| `inputTokens` | Input tokens, not including cache reads or cache writes |
| `outputTokens` | Output tokens |
| `cacheReadInputTokens` | Input tokens read from the prompt cache |
| `cacheWriteInputTokens` | Input tokens written to the prompt cache |
| `totalTokens` | Input and output tokens, as reported by the vendor |

* **No `cost`.** Unlike OpenRouter and LiteLLM, Bedrock does not return a price, so you can bill tokens but not what the call cost. The price appears only on your AWS bill.
* **No `model` dimension.** Bedrock serves exactly the model you name and does not fall back to another, so there is no routing drift to track.
* **Cache tokens are separate.** Like Anthropic, Bedrock counts cache reads and writes separately from `inputTokens`. AWS defines `totalTokens` as the input and output tokens, so on a call that uses the prompt cache it can be lower than the sum of the four counters. Price the total or the parts, never both.

The idempotency key is the AWS request ID, which stays the same when the AWS SDK retries the call, so a retried call is not counted twice.

Every usage field the vendor returns is also included, with a `raw.` prefix. See [How usage is reported](/documentation/ai-agents/llm-wrappers/supported-providers#how-usage-is-reported).


## Related topics

- [Gateways](/documentation/ai-agents/llm-wrappers/gateways.md)
- [Supported providers and gateways](/documentation/ai-agents/llm-wrappers/supported-providers.md)
- [Metering usage](/documentation/ai-agents/llm-wrappers/metering.md)
- [JavaScript](/api-and-sdks/changelog/agent-sdk/javascript.md)
- [Amazon Redshift](/documentation/importing-and-exporting-data/export/redshift.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.