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

# AWS Bedrock

> Trace AWS Bedrock SDK calls and use Bedrock models in Braintrust

If you are a coding agent, prefer the Braintrust [`bt` CLI](/reference/cli/quickstart) for repeatable, scriptable work: running evals, instrumenting code, querying logs, syncing data, managing functions, and configuring coding agents. Use the MCP server for reasoning over Braintrust data in conversation, such as ad-hoc lookups and exploration from your IDE.

Braintrust integrates with [Amazon Bedrock](https://aws.amazon.com/bedrock/) so you can call Amazon's foundation models from the Braintrust playground, API, and SDKs. Braintrust also traces AWS Bedrock SDK calls from your application.

<View title="TypeScript" icon="https://img.logo.dev/typescriptlang.org?token=pk_BdcHD9e5SCW3j1rnJkNyMQ">
  <h2 id="tracing-typescript">
    Tracing
  </h2>

  The Braintrust TypeScript SDK traces the AWS Bedrock Runtime client (`@aws-sdk/client-bedrock-runtime`) automatically with the `braintrust/hook.mjs` import hook, or manually with `wrapBedrockRuntime`. Both paths produce the same spans.

  <Note>
    The Bedrock Runtime TypeScript integration requires Node.js v20 or later.
  </Note>

  <Tabs>
    <Tab title="Auto-instrumentation">
      <h3 id="setup-typescript-auto">
        Setup
      </h3>

      Install Braintrust alongside the AWS Bedrock Runtime SDK, then configure your Braintrust API key and AWS credentials.

      <Steps>
        <Step title="Install packages">
          <CodeGroup>
            ```bash pnpm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
            pnpm add braintrust @aws-sdk/client-bedrock-runtime
            ```

            ```bash npm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
            npm install braintrust @aws-sdk/client-bedrock-runtime
            ```
          </CodeGroup>
        </Step>

        <Step title="Set environment variables">
          AWS credentials are resolved via the standard credential chain. Set `AWS_REGION` or `AWS_DEFAULT_REGION`. If you authenticate with an Amazon Bedrock API key, set `AWS_BEARER_TOKEN_BEDROCK`.

          ```bash title=".env" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
          BRAINTRUST_API_KEY=<your-braintrust-api-key>
          AWS_REGION=us-east-1

          # Use either the standard AWS credential chain:
          AWS_ACCESS_KEY_ID=<your-aws-access-key-id>
          AWS_SECRET_ACCESS_KEY=<your-aws-secret-access-key>

          # Or use an Amazon Bedrock API key:
          # AWS_BEARER_TOKEN_BEDROCK=<your-bedrock-api-key>
          ```
        </Step>
      </Steps>

      <h3 id="auto-instrumentation-typescript">
        Trace your application
      </h3>

      Run your app with Braintrust's import hook to patch Bedrock Runtime calls at startup. The hook traces `ConverseCommand`, `ConverseStreamCommand`, `InvokeModelCommand`, and `InvokeModelWithResponseStreamCommand` calls sent through the client.

      <CodeGroup>
        ```typescript title="trace-bedrock-auto.ts" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
        import {
          BedrockRuntimeClient,
          ConverseCommand,
        } from "@aws-sdk/client-bedrock-runtime";
        import { initLogger } from "braintrust";

        initLogger({
          projectName: "My Project", // Replace with your project name
          apiKey: process.env.BRAINTRUST_API_KEY,
        });

        const client = new BedrockRuntimeClient({
          region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION,
        });

        const response = await client.send(
          new ConverseCommand({
            modelId: "us.amazon.nova-lite-v1:0",
            messages: [
              {
                role: "user",
                content: [{ text: "What is the capital of France?" }],
              },
            ],
          }),
        );
        ```
      </CodeGroup>

      Run with the import hook:

      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      node --import braintrust/hook.mjs trace-bedrock-auto.ts
      ```

      The auto-instrumentation example uses plain JavaScript so `node --import` can run the file directly. The Braintrust APIs work the same in TypeScript projects — compile your TypeScript to JavaScript, then run the compiled file with the import hook.

      <Note>
        If you're using a bundler, see [Trace LLM calls](/instrument/trace-llm-calls#auto-instrumentation) for plugin and loader setup.
      </Note>
    </Tab>

    <Tab title="Manual instrumentation">
      <h3 id="setup-typescript-manual">
        Setup
      </h3>

      Install Braintrust alongside the AWS Bedrock Runtime SDK, then configure your Braintrust API key and AWS credentials.

      <Steps>
        <Step title="Install packages">
          <CodeGroup>
            ```bash pnpm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
            pnpm add braintrust @aws-sdk/client-bedrock-runtime
            ```

            ```bash npm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
            npm install braintrust @aws-sdk/client-bedrock-runtime
            ```
          </CodeGroup>
        </Step>

        <Step title="Set environment variables">
          AWS credentials are resolved via the standard credential chain. Set `AWS_REGION` or `AWS_DEFAULT_REGION`. If you authenticate with an Amazon Bedrock API key, set `AWS_BEARER_TOKEN_BEDROCK`.

          ```bash title=".env" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
          BRAINTRUST_API_KEY=<your-braintrust-api-key>
          AWS_REGION=us-east-1

          # Use either the standard AWS credential chain:
          AWS_ACCESS_KEY_ID=<your-aws-access-key-id>
          AWS_SECRET_ACCESS_KEY=<your-aws-secret-access-key>

          # Or use an Amazon Bedrock API key:
          # AWS_BEARER_TOKEN_BEDROCK=<your-bedrock-api-key>
          ```
        </Step>
      </Steps>

      <h3 id="manual-instrumentation-typescript">
        Trace your application
      </h3>

      Wrap the Bedrock Runtime client with `wrapBedrockRuntime` when you want to opt into tracing explicitly.

      <CodeGroup>
        ```typescript title="trace-bedrock-manual.ts" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
        import {
          BedrockRuntimeClient,
          ConverseCommand,
        } from "@aws-sdk/client-bedrock-runtime";
        import { initLogger, wrapBedrockRuntime } from "braintrust";

        initLogger({
          projectName: "My Project", // Replace with your project name
          apiKey: process.env.BRAINTRUST_API_KEY,
        });

        const client = wrapBedrockRuntime(
          new BedrockRuntimeClient({
            region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION,
          }),
        );

        const response = await client.send(
          new ConverseCommand({
            modelId: "us.amazon.nova-lite-v1:0",
            messages: [
              {
                role: "user",
                content: [{ text: "What is the capital of France?" }],
              },
            ],
          }),
        );
        ```
      </CodeGroup>
    </Tab>
  </Tabs>

  <h3 id="anthropic-bedrock-typescript">
    Trace Anthropic's Bedrock SDK
  </h3>

  If you use Anthropic's [`@anthropic-ai/bedrock-sdk`](https://www.npmjs.com/package/@anthropic-ai/bedrock-sdk) instead of the native AWS Runtime client, use the Anthropic integration. Braintrust records those calls as `anthropic.messages.create` spans with `provider: "anthropic"` metadata. See [Using Anthropic through AWS Bedrock](/integrations/ai-providers/anthropic#anthropic-bedrock-typescript).

  <h3 id="what-traced-typescript">
    What Braintrust traces
  </h3>

  Braintrust emits LLM spans for these Bedrock Runtime commands:

  | Span                                    | Command                                |
  | --------------------------------------- | -------------------------------------- |
  | `bedrock.converse`                      | `ConverseCommand`                      |
  | `bedrock.converseStream`                | `ConverseStreamCommand`                |
  | `bedrock.invokeModel`                   | `InvokeModelCommand`                   |
  | `bedrock.invokeModelWithResponseStream` | `InvokeModelWithResponseStreamCommand` |

  Each span includes `provider: "aws-bedrock"`, the Bedrock model ID in `metadata.model`, command and operation metadata, request input, response output, and model parameters such as `maxTokens`, `temperature`, `topP`, and `stopSequences` when present.

  **Metrics**

  | Metric                         | Description                                        |
  | ------------------------------ | -------------------------------------------------- |
  | `prompt_tokens`                | Input tokens.                                      |
  | `completion_tokens`            | Output tokens.                                     |
  | `tokens`                       | Total tokens.                                      |
  | `prompt_cache_creation_tokens` | Tokens written to the prompt cache.                |
  | `prompt_cached_tokens`         | Tokens read from the prompt cache.                 |
  | `time_to_first_token`          | First-token latency for streaming responses.       |
  | `latency_ms`                   | Bedrock response latency when returned by the SDK. |

  <h3 id="tracing-resources-typescript">
    Tracing resources
  </h3>

  * [AWS Bedrock Runtime JavaScript SDK](https://www.npmjs.com/package/@aws-sdk/client-bedrock-runtime)
  * [AWS Bedrock Runtime documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html)
  * [Trace LLM calls](/instrument/trace-llm-calls)
</View>

<View title="Go" icon="https://img.logo.dev/go.dev?token=pk_BdcHD9e5SCW3j1rnJkNyMQ">
  <h2 id="tracing-go">
    Tracing
  </h2>

  The Braintrust Go SDK ships a Bedrock Runtime middleware that you can attach manually, or apply automatically at compile time with [Orchestrion](https://github.com/DataDog/orchestrion). Either path produces the same traces.

  <h3 id="setup-go">
    Setup
  </h3>

  Install the Braintrust Go SDK alongside the AWS Bedrock Runtime SDK, then configure your Braintrust API key and AWS credentials.

  <Steps>
    <Step title="Install packages">
      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      go get github.com/braintrustdata/braintrust-sdk-go
      go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/bedrockruntime
      go get github.com/aws/aws-sdk-go-v2/config
      go get github.com/aws/aws-sdk-go-v2/service/bedrockruntime
      ```
    </Step>

    <Step title="Set environment variables">
      AWS credentials are resolved via the standard credential chain, and `AWS_REGION` (or `AWS_DEFAULT_REGION`) must be set.

      ```bash title=".env" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      BRAINTRUST_API_KEY=your-braintrust-api-key
      AWS_REGION=us-east-1
      AWS_ACCESS_KEY_ID=your-aws-access-key-id
      AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key
      ```
    </Step>
  </Steps>

  <h3 id="auto-instrumentation-go">
    Auto-instrumentation
  </h3>

  To trace Bedrock Runtime calls without modifying your application code, build your app with [Orchestrion](https://github.com/DataDog/orchestrion), a compile-time tool that rewrites every `bedrockruntime.NewFromConfig` call to attach Braintrust's middleware automatically.

  <Steps>
    <Step title="Install Orchestrion">
      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      go install github.com/DataDog/orchestrion@v1.6.1
      ```
    </Step>

    <Step title="Create orchestrion.tool.go in your project root">
      ```go title="orchestrion.tool.go" #skip-compile theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      //go:build tools

      package main

      import (
      _ "github.com/DataDog/orchestrion"
      _ "github.com/braintrustdata/braintrust-sdk-go/trace/contrib/bedrockruntime"
      )
      ```
    </Step>

    <Step title="Write your app">
      Orchestrion instruments every `bedrockruntime.NewFromConfig` call at build time, so no middleware wiring is needed.

      <CodeGroup>
        ```go Go theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
        package main

        import (
        "context"
        "fmt"
        "log"
        "os"

        "github.com/aws/aws-sdk-go-v2/aws"
        "github.com/aws/aws-sdk-go-v2/config"
        "github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
        "github.com/aws/aws-sdk-go-v2/service/bedrockruntime/types"
        "go.opentelemetry.io/otel"
        "go.opentelemetry.io/otel/sdk/trace"

        "github.com/braintrustdata/braintrust-sdk-go"
        )

        func main() {
        tp := trace.NewTracerProvider()
        defer tp.Shutdown(context.Background())
        otel.SetTracerProvider(tp)

        bt, err := braintrust.New(tp,
        	braintrust.WithProject("bedrock-example"),
        	braintrust.WithAPIKey(os.Getenv("BRAINTRUST_API_KEY")),
        )
        if err != nil {
        	log.Fatal(err)
        }

        ctx := context.Background()
        tracer := otel.Tracer("bedrock-example")
        ctx, span := tracer.Start(ctx, "trace-bedrock")
        defer span.End()

        cfg, err := config.LoadDefaultConfig(ctx)
        if err != nil {
        	log.Fatal(err)
        }

        client := bedrockruntime.NewFromConfig(cfg)

        resp, err := client.Converse(ctx, &bedrockruntime.ConverseInput{
        	ModelId: aws.String("us.anthropic.claude-sonnet-4-5-20250929-v1:0"),
        	Messages: []types.Message{{
        		Role: types.ConversationRoleUser,
        		Content: []types.ContentBlock{
        			&types.ContentBlockMemberText{Value: "What is the capital of France?"},
        		},
        	}},
        })
        if err != nil {
        	log.Fatal(err)
        }

        if out, ok := resp.Output.(*types.ConverseOutputMemberMessage); ok {
        	for _, block := range out.Value.Content {
        		if text, ok := block.(*types.ContentBlockMemberText); ok {
        			fmt.Printf("Response: %s\n", text.Value)
        		}
        	}
        }
        fmt.Printf("View trace: %s\n", bt.Permalink(span))
        }
        ```
      </CodeGroup>
    </Step>

    <Step title="Build with Orchestrion and run">
      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      go mod tidy
      orchestrion go build -o myapp
      ./myapp
      ```

      <Accordion title="Enable Orchestrion via GOFLAGS">
        Instead of running `orchestrion go build`, you can set a `GOFLAGS` environment variable to enable Orchestrion for normal `go build` commands:

        ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
        export GOFLAGS="-toolexec='orchestrion toolexec'"
        go build ./...
        ```
      </Accordion>
    </Step>
  </Steps>

  <h3 id="manual-instrumentation-go">
    Manual instrumentation
  </h3>

  To trace Bedrock Runtime calls manually, attach Braintrust's tracing middleware yourself by passing `tracebedrockruntime.NewMiddleware()` as a functional option on `bedrockruntime.NewFromConfig`. Once attached, `Converse`, `ConverseStream`, and `InvokeModel` calls are traced.

  <CodeGroup>
    ```go Go theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    package main

    import (
    	"context"
    	"fmt"
    	"log"
    	"os"

    	"github.com/aws/aws-sdk-go-v2/aws"
    	"github.com/aws/aws-sdk-go-v2/config"
    	"github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
    	"github.com/aws/aws-sdk-go-v2/service/bedrockruntime/types"
    	"go.opentelemetry.io/otel"
    	"go.opentelemetry.io/otel/sdk/trace"

    	"github.com/braintrustdata/braintrust-sdk-go"
    	tracebedrockruntime "github.com/braintrustdata/braintrust-sdk-go/trace/contrib/bedrockruntime"
    )

    func main() {
    	tp := trace.NewTracerProvider()
    	defer tp.Shutdown(context.Background())
    	otel.SetTracerProvider(tp)

    	bt, err := braintrust.New(tp,
    		braintrust.WithProject("bedrock-example"),
    		braintrust.WithAPIKey(os.Getenv("BRAINTRUST_API_KEY")),
    	)
    	if err != nil {
    		log.Fatal(err)
    	}

    	ctx := context.Background()
    	tracer := otel.Tracer("bedrock-example")
    	ctx, span := tracer.Start(ctx, "trace-bedrock")
    	defer span.End()

    	cfg, err := config.LoadDefaultConfig(ctx)
    	if err != nil {
    		log.Fatal(err)
    	}

    	// Attach the Braintrust tracing middleware to the Bedrock Runtime client.
    	client := bedrockruntime.NewFromConfig(cfg, tracebedrockruntime.NewMiddleware())

    	resp, err := client.Converse(ctx, &bedrockruntime.ConverseInput{
    		ModelId: aws.String("us.anthropic.claude-sonnet-4-5-20250929-v1:0"),
    		Messages: []types.Message{{
    			Role: types.ConversationRoleUser,
    			Content: []types.ContentBlock{
    				&types.ContentBlockMemberText{Value: "What is the capital of France?"},
    			},
    		}},
    	})
    	if err != nil {
    		log.Fatal(err)
    	}

    	if out, ok := resp.Output.(*types.ConverseOutputMemberMessage); ok {
    		for _, block := range out.Value.Content {
    			if text, ok := block.(*types.ContentBlockMemberText); ok {
    				fmt.Printf("Response: %s\n", text.Value)
    			}
    		}
    	}
    	fmt.Printf("View trace: %s\n", bt.Permalink(span))
    }
    ```
  </CodeGroup>

  <h3 id="what-traced-go">
    What Braintrust traces
  </h3>

  Braintrust captures:

  * Inputs and outputs for `Converse`, `ConverseStream`, and `InvokeModel`. Converse APIs capture structured messages (text, tool calls and results, images, documents); `InvokeModel` captures the raw model-specific request and response bodies.
  * Streaming output for `ConverseStream` reconstructed from delta events, with `time_to_first_token` captured on the first event
  * Token usage for Converse APIs and for `InvokeModel` calls to Anthropic Claude models, including cache read and cache write tokens
  * Model parameters (model, max\_tokens, temperature, top\_p, stop\_sequences), tool definitions, `tool_choice`, and stop reason in span metadata
  * Extended thinking / reasoning content in span output, for both non-streaming and streaming Converse responses

  <h3 id="tracing-resources-go">
    Tracing resources
  </h3>

  * [Go SDK example](https://github.com/braintrustdata/braintrust-sdk-go/tree/main/examples/bedrockruntime)
  * [AWS Bedrock Runtime documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html)
</View>

<View title="Java" icon="https://img.logo.dev/java.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ">
  <h2 id="tracing-java">
    Tracing
  </h2>

  The Braintrust Java SDK ships a Bedrock Runtime interceptor that you can attach manually with `BraintrustAWSBedrock.wrap()`, or have applied automatically by the [Braintrust Java agent](/instrument/trace-llm-calls#auto-instrumentation). Both paths produce the same spans.

  <h3 id="setup-java">
    Setup
  </h3>

  Install the Braintrust Java SDK alongside the AWS Bedrock Runtime SDK, then configure your Braintrust API key and AWS credentials.

  <Steps>
    <Step title="Add dependencies">
      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      # build.gradle
      dependencies {
          implementation 'dev.braintrust:braintrust-sdk-java:+'
          implementation 'software.amazon.awssdk:bedrockruntime:2.30.0+'
      }
      ```

      Requires the AWS Bedrock Runtime SDK at version 2.30.0 or later.
    </Step>

    <Step title="Set environment variables">
      AWS credentials are resolved via the standard credential chain, and `AWS_REGION` (or `AWS_DEFAULT_REGION`) must be set.

      ```bash title=".env" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      BRAINTRUST_API_KEY=your-braintrust-api-key
      AWS_REGION=us-east-1
      AWS_ACCESS_KEY_ID=your-aws-access-key-id
      AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key
      ```
    </Step>
  </Steps>

  <h3 id="auto-instrumentation-java">
    Auto-instrumentation
  </h3>

  To trace Bedrock Runtime calls without modifying your application code, attach the [`braintrust-java-agent`](/instrument/trace-llm-calls#auto-instrumentation) at JVM startup. The agent intercepts every `BedrockRuntimeClient` and `BedrockRuntimeAsyncClient` build and applies the Braintrust interceptor automatically.

  <Steps>
    <Step title="Add the agent dependency">
      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      # build.gradle
      configurations {
          braintrustAgent
      }

      dependencies {
          braintrustAgent 'dev.braintrust:braintrust-java-agent:+'
      }

      tasks.withType(JavaExec).configureEach {
          jvmArgs "-javaagent:${configurations.braintrustAgent.asPath}"
      }
      ```
    </Step>

    <Step title="Run your app">
      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      ./gradlew run
      ```

      Bedrock client builds in your application code are now intercepted automatically. No call to `BraintrustAWSBedrock.wrap()` is required.
    </Step>
  </Steps>

  <h3 id="manual-instrumentation-java">
    Manual instrumentation
  </h3>

  To trace Bedrock Runtime calls manually, attach Braintrust's interceptor yourself by passing your client builder through `BraintrustAWSBedrock.wrap()` before calling `.build()`. Use it on `BedrockRuntimeClient.builder()` for sync `converse` calls, and on `BedrockRuntimeAsyncClient.builder()` for async `converseStream` calls.

  <CodeGroup>
    ```java Java theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    import dev.braintrust.Braintrust;
    import dev.braintrust.config.BraintrustConfig;
    import dev.braintrust.instrumentation.awsbedrock.v2_30_0.BraintrustAWSBedrock;
    import software.amazon.awssdk.regions.Region;
    import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient;
    import software.amazon.awssdk.services.bedrockruntime.model.ContentBlock;
    import software.amazon.awssdk.services.bedrockruntime.model.ConversationRole;
    import software.amazon.awssdk.services.bedrockruntime.model.ConverseRequest;
    import software.amazon.awssdk.services.bedrockruntime.model.Message;

    class Main {
        public static void main(String[] args) {
            var config = BraintrustConfig.builder()
                .apiKey(System.getenv("BRAINTRUST_API_KEY"))
                .defaultProjectName("My Project (Java)")
                .build();
            var braintrust = Braintrust.get(config);
            var openTelemetry = braintrust.openTelemetryCreate();

            // Wrap the Bedrock client builder to trace Converse calls
            BedrockRuntimeClient client = BraintrustAWSBedrock.wrap(
                    openTelemetry, BedrockRuntimeClient.builder())
                .region(Region.US_EAST_1)
                .build();

            var response = client.converse(ConverseRequest.builder()
                .modelId("us.anthropic.claude-sonnet-4-5-20250929-v1:0")
                .messages(Message.builder()
                    .role(ConversationRole.USER)
                    .content(ContentBlock.fromText("What is the capital of France?"))
                    .build())
                .build());

            System.out.println(response.output().message().content().get(0).text());
        }
    }
    ```
  </CodeGroup>

  For async/streaming `converseStream` calls, wrap a `BedrockRuntimeAsyncClient.builder()` instead. The wrap signature is the same and produces a span built from the streaming events.

  <h3 id="what-traced-java">
    What Braintrust traces
  </h3>

  Braintrust captures:

  * Inputs and outputs for `Converse` (sync) and `ConverseStream` (async/streaming) calls. Other Bedrock operations such as `InvokeModel` and `ApplyGuardrail` are not traced.
  * Streaming output for `ConverseStream` reconstructed from `contentBlockDelta` events into the span output, with `time_to_first_token` captured on the first delta event.
  * Token usage (`prompt_tokens`, `completion_tokens`, total tokens) from the response usage block.
  * Model ID and `inferenceConfig` parameters (max\_tokens, temperature, top\_p, stop\_sequences) in span metadata.
  * Stop reason from streaming `messageStop` events.

  <Note>
    Image, video, audio, and document content blocks in Converse messages are automatically extracted as Braintrust attachments and rendered as previewable attachments in the trace viewer.
  </Note>

  <h3 id="tracing-resources-java">
    Tracing resources
  </h3>

  * [Braintrust Java SDK](https://github.com/braintrustdata/braintrust-sdk-java)
  * [Trace LLM calls](/instrument/trace-llm-calls) for general Java agent setup
  * [AWS Bedrock Runtime documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html)
</View>

## Connect Bedrock to Braintrust

To use Bedrock models in the Braintrust playground, API, and proxy, connect Bedrock as a provider in your organization or project AI providers.

<Steps>
  <Step title="Confirm model access in AWS">
    Before configuring Braintrust, make sure you can access the Bedrock models you want to use in AWS.

    1. Confirm the model is available in your target AWS region. See [Supported foundation models in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html).
    2. Confirm your AWS account is allowed to invoke that model. See [Manage access to Amazon Bedrock foundation models](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html).
    3. If you plan to use Bedrock API keys, confirm your region supports them. See [Supported Regions and SDKs for Amazon Bedrock API keys](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-supported.html).
  </Step>

  <Step title="Configure the integration">
    Open the Bedrock provider settings, choose how Braintrust should authenticate to AWS, and pick the region and model registry options:

    1. Go to **<Icon icon="settings-2" /> Settings** > [**<Icon icon="sparkle" /> AI providers**](https://www.braintrust.dev/app/~/configuration/org/secrets).
    2. Add a new [organization or project provider](/admin/ai-providers) and choose **Bedrock**.
    3. Choose your authentication method:

       * **IAM credentials**: Use an AWS access key ID and secret access key.
       * **API key**: Use an Amazon Bedrock bearer token.
       * **Assume role**: Use AWS STS `AssumeRole` with an IAM role in your AWS account, instead of storing long-lived AWS access keys in Braintrust.

           <Note>
             Assume role authentication is only available for Braintrust-hosted organizations. For self-hosted deployments, use **IAM credentials** or **API key** instead.
           </Note>

           <Note>
             API keys are stored as one-way cryptographic hashes, never in plaintext.
           </Note>
    4. If you chose **Assume role**, create the IAM role in your AWS account. Braintrust assumes this role, receives temporary AWS credentials from STS, and uses those credentials to invoke Bedrock.

       1. Expand **Role creation instructions**. The UI shows the trusted AWS account ID, external ID, IAM permissions policy, and trust policy for your organization.
       2. In your AWS account, create an IAM role using those values.
       3. Copy the role ARN from AWS.
    5. Set **Region** to the AWS region where Braintrust should send Bedrock requests.

       Choose a region where your target model is available. If you use a region-specific model ID such as `us.anthropic.claude-sonnet-4-5-20250929-v1:0`, make sure the selected region is compatible with that model.
    6. Enter credentials:
       * **IAM credentials**: Fill in **Access key**, then enter the secret access key in the **Secret** field. Use **Session token** if you are using temporary AWS credentials such as STS.
       * **API key**: Paste your Amazon Bedrock API key into the **Secret** field.
       * **Assume role**: Paste the role ARN into **Role ARN**.
    7. Optional: Set **API base** if you need a custom Bedrock endpoint.
    8. Many [Bedrock models](/deploy/supported-models) are available in Braintrust by default. To access these, leave **Include the default registry of Bedrock models** enabled. If the model you want is not supported by default, add it manually in the next step.
    9. Click **Save**.
  </Step>

  <Step title="Add models manually">
    You only need to do this step if the model you want does not appear in Braintrust's [supported models](/deploy/supported-models) list. This is common for newly released models, preview access models, or models your account has special access to.

    When you add a model manually:

    1. Copy the exact Bedrock model ID from AWS.
    2. Add it under **Models** in the Bedrock provider settings.
    3. Choose the matching Braintrust format.

    <AccordionGroup>
      <Accordion title="Common model IDs">
        * `anthropic.claude-sonnet-4-5-20250929-v1:0` - base model ID (`provider.model-version:variant`)
        * `us.anthropic.claude-sonnet-4-5-20250929-v1:0` - cross-region inference profile (`region.provider.model-version:variant`)
        * `amazon.nova-pro-v1:0` - base model ID
        * `us.amazon.nova-pro-v1:0` - cross-region inference profile

        <Note>
          If AWS offers both a base model ID and a fully versioned variation, prefer the fully versioned model ID.
        </Note>
      </Accordion>

      <Accordion title="How to find model IDs">
        Use the AWS page that matches the kind of ID you need:

        * **Base model IDs** such as `anthropic.claude-sonnet-4-5-20250929-v1:0` or `amazon.nova-pro-v1:0`:
          Check [Supported foundation models in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) and copy the value from the **Model ID** column.
        * **Cross-Region inference profile IDs** such as `us.*`, `eu.*`, `apac.*`, or `global.*`:
          Check [Supported Regions and models for inference profiles](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html).
      </Accordion>

      <Accordion title="Format guide">
        Use the model ID prefix to choose the format:

        | Bedrock model ID pattern             | Braintrust format |
        | ------------------------------------ | ----------------- |
        | `anthropic.*`                        | **Anthropic**     |
        | `amazon.*`                           | **Converse**      |
        | `us.*`, `eu.*`, `apac.*`, `global.*` | **Converse**      |

        You can also select the **OpenAI** format for a Bedrock model. Braintrust then routes the model through Bedrock's OpenAI-compatible Chat Completions endpoint, including streaming responses.

        <Note>
          The **OpenAI** format for Bedrock models requires data plane v2.2.0 or later.
        </Note>
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

### Bedrock provider resources

* [Use models in the Braintrust playground](/evaluate/playgrounds)
* [Supported models in Braintrust](/deploy/supported-models)
* [AWS Bedrock documentation](https://docs.aws.amazon.com/bedrock/)
* [Bedrock pricing](https://aws.amazon.com/bedrock/pricing/)
