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

# AWS Bedrock

> Track costs for Claude, Llama, Titan, and all models hosted on AWS Bedrock

This guide covers how to send AWS Bedrock usage data to Fenra.

## Bedrock Runtime API

<CodeGroup>
  ```javascript Node.js theme={null}
  import { BedrockRuntimeClient, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime';

  const client = new BedrockRuntimeClient({ region: 'us-east-1' });

  async function chat(messages) {
    const command = new InvokeModelCommand({
      modelId: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
      contentType: 'application/json',
      accept: 'application/json',
      body: JSON.stringify({
        anthropic_version: 'bedrock-2023-05-31',
        max_tokens: 1024,
        messages
      })
    });

    const response = await client.send(command);
    const result = JSON.parse(new TextDecoder().decode(response.body));

    // Send to Fenra
    await fetch('https://ingest.fenra.io/usage/transactions', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-Api-Key': process.env.FENRA_API_KEY
      },
      body: JSON.stringify({
        provider: 'bedrock',
        model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
        usage: [{
          type: 'tokens',
          metrics: {
            input_tokens: result.usage.input_tokens,
            output_tokens: result.usage.output_tokens,
            total_tokens: result.usage.input_tokens + result.usage.output_tokens
          }
        }],
        context: {
          billable_customer_id: process.env.BILLABLE_CUSTOMER_ID
        }
      })
    });

    return result;
  }
  ```

  ```python Python theme={null}
  import boto3
  import json
  import requests
  import os

  bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')

  def chat(messages):
      response = bedrock.invoke_model(
          modelId='anthropic.claude-3-5-sonnet-20241022-v2:0',
          contentType='application/json',
          accept='application/json',
          body=json.dumps({
              'anthropic_version': 'bedrock-2023-05-31',
              'max_tokens': 1024,
              'messages': messages
          })
      )

      result = json.loads(response['body'].read())

      # Send to Fenra
      requests.post(
          'https://ingest.fenra.io/usage/transactions',
          headers={
              'Content-Type': 'application/json',
              'X-Api-Key': os.getenv('FENRA_API_KEY')
          },
          json={
              'provider': 'bedrock',
              'model': 'anthropic.claude-3-5-sonnet-20241022-v2:0',
              'usage': [{
                  'type': 'tokens',
                  'metrics': {
                      'input_tokens': result['usage']['input_tokens'],
                      'output_tokens': result['usage']['output_tokens'],
                      'total_tokens': result['usage']['input_tokens'] + result['usage']['output_tokens']
                  }
              }],
              'context': {
                  'billable_customer_id': os.getenv('BILLABLE_CUSTOMER_ID')
              }
          }
      )

      return result
  ```
</CodeGroup>

## Supported Models

Fenra supports all models hosted on AWS Bedrock. Common providers include:

| Provider  | Models                                                     |
| --------- | ---------------------------------------------------------- |
| Anthropic | All Claude models (claude-3.5-sonnet, claude-3-opus, etc.) |
| Meta      | All Llama models (llama-3.2, llama-3.1, llama-3)           |
| Amazon    | All Titan models (titan-text, titan-embeddings)            |
| Mistral   | All Mistral models (mistral-large, mistral-7b)             |

Use the full Bedrock model ID (e.g., `anthropic.claude-3-5-sonnet-20241022-v2:0`) for accurate cost calculation.

## Next Steps

* [Compare Bedrock vs. Direct API](/product-overview/cost-explorer/breakdown)
* [Set up alerts](/guides/alerts) for Bedrock spending
