Skip to main content

AWS Bedrock

Use AWS Bedrock to access a broad catalog of foundation models — Mistral, Amazon Nova, Meta Llama, Cohere, AI21, and more — through RadarOS’s unified ModelProvider interface. All models are accessed via the Bedrock Converse API.
For Claude models on Bedrock, use the dedicated awsClaude() provider instead. It uses the native Anthropic SDK for full Claude feature support (extended thinking, document input, etc.).

Setup

Install the AWS Bedrock Runtime SDK:
npm install @aws-sdk/client-bedrock-runtime

Factory

import { awsBedrock } from "@radaros/core";

const model = awsBedrock("mistral.mistral-large-2402-v1:0");
modelId
string
required
The Bedrock model identifier. Find model IDs in the AWS Bedrock model catalog.
config
AwsBedrockConfig
Optional configuration. See Config below.

Supported Models

Model IDProviderDescription
mistral.mistral-large-2402-v1:0MistralStrong general-purpose performance
mistral.mistral-small-2402-v1:0MistralFast, cost-effective
amazon.nova-pro-v1:0AmazonGeneral-purpose Nova model
amazon.nova-lite-v1:0AmazonLightweight, low-latency
amazon.nova-micro-v1:0AmazonUltra-fast, cost-optimized
meta.llama3-1-70b-instruct-v1:0MetaLlama 3.1 70B Instruct
meta.llama3-1-8b-instruct-v1:0MetaLlama 3.1 8B Instruct
cohere.command-r-plus-v1:0CohereStrong RAG and tool use
cohere.command-r-v1:0CohereFast, efficient
Pass any valid Bedrock model ID to the factory. Manage model access in the AWS Bedrock console. Not all models support all features — check supported features per model.

Config

accessKeyId
string
AWS access key ID. Falls back to AWS_ACCESS_KEY_ID env var, then default credential chain.
secretAccessKey
string
AWS secret access key. Falls back to AWS_SECRET_ACCESS_KEY env var.
region
string
default:"us-east-1"
AWS region. Falls back to AWS_REGION env var.
sessionToken
string
AWS session token for temporary credentials (STS, SSO). Falls back to AWS_SESSION_TOKEN env var.

Authentication Methods

Method 1: Access Key + Secret (Explicit)

const model = awsBedrock("mistral.mistral-large-2402-v1:0", {
  accessKeyId: "AKIA...",
  secretAccessKey: "...",
  region: "us-east-1",
});
export AWS_ACCESS_KEY_ID="AKIA..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_REGION="us-east-1"
const model = awsBedrock("mistral.mistral-large-2402-v1:0");
// Credentials picked up from env automatically

Method 3: Default Credential Chain (SSO, IAM Roles)

If running on EC2, ECS, Lambda, or using aws sso login, credentials are resolved automatically via the AWS SDK’s default credential provider chain:
const model = awsBedrock("amazon.nova-pro-v1:0", {
  region: "us-east-1",
});
// Uses IAM role, SSO session, or ~/.aws/credentials

Method 4: Temporary Credentials (STS)

const model = awsBedrock("mistral.mistral-large-2402-v1:0", {
  accessKeyId: "ASIA...",
  secretAccessKey: "...",
  sessionToken: "FwoGZX...",
  region: "us-east-1",
});

Tool Calling

Tool calling is supported via the Bedrock Converse API. Define tools with defineTool and they work automatically:
import { Agent, awsBedrock, defineTool } from "@radaros/core";
import { z } from "zod";

const agent = new Agent({
  name: "bedrock-assistant",
  model: awsBedrock("mistral.mistral-large-2402-v1:0"),
  instructions: "You are a helpful assistant with tool access.",
  tools: [
    defineTool({
      name: "getWeather",
      description: "Get current weather for a city",
      parameters: z.object({ city: z.string() }),
      execute: async ({ city }) => `${city}: 24°C, Sunny`,
    }),
  ],
});

const result = await agent.run("What's the weather in Mumbai?");
console.log(result.text);
Not all Bedrock models support tool calling. Mistral Large, Amazon Nova, Cohere Command R/R+, and Meta Llama 3.1+ support function calling. Check the Bedrock docs for your model.

Multi-Modal Support

The Bedrock Converse API supports images and documents for models that have vision capabilities (e.g., Amazon Nova).

Images

import { Agent, awsBedrock, type ContentPart } from "@radaros/core";
import { readFileSync } from "node:fs";

const agent = new Agent({
  name: "vision-agent",
  model: awsBedrock("amazon.nova-pro-v1:0"),
  instructions: "Describe images in detail.",
});

const imageData = readFileSync("photo.jpg").toString("base64");
const result = await agent.run([
  { type: "text", text: "What's in this image?" },
  { type: "image", data: imageData, mimeType: "image/jpeg" },
] as ContentPart[]);

Documents

const pdfData = readFileSync("report.pdf").toString("base64");
const result = await agent.run([
  { type: "text", text: "Summarize the key points." },
  { type: "file", data: pdfData, mimeType: "application/pdf", filename: "report.pdf" },
] as ContentPart[]);

Full Example

import { Agent, awsBedrock, CostTracker, defineTool } from "@radaros/core";
import { z } from "zod";

const costTracker = new CostTracker({
  pricing: {
    "mistral.mistral-large-2402-v1:0": { promptPer1k: 0.004, completionPer1k: 0.012 },
  },
});

const agent = new Agent({
  name: "bedrock-agent",
  model: awsBedrock("mistral.mistral-large-2402-v1:0", {
    region: "us-east-1",
  }),
  instructions: "You are a helpful assistant running on AWS Bedrock.",
  tools: [
    defineTool({
      name: "lookup_order",
      description: "Look up an order by ID",
      parameters: z.object({ orderId: z.string() }),
      execute: async ({ orderId }) => JSON.stringify({ id: orderId, status: "shipped", eta: "2026-03-01" }),
    }),
  ],
  costTracker,
  maxToolRoundtrips: 3,
});

const result = await agent.run("Where is my order ORD-12345?");
console.log(result.text);
console.log(`Cost: $${costTracker.getSummary().totalCost.toFixed(4)}`);

AWS Bedrock vs Direct API

FeatureDirect API (openai(), anthropic())awsBedrock()
AuthProvider API keyAWS IAM / credentials
BillingProvider billingAWS billing (consolidated)
VPC / PrivateNoYes (PrivateLink)
Model varietySingle providerMulti-provider catalog
Claude supportFull (thinking, docs)Use awsClaude() instead
ComplianceProvider-dependentSOC2, HIPAA, FedRAMP

Environment Variables

VariableDescription
AWS_ACCESS_KEY_IDAWS access key ID
AWS_SECRET_ACCESS_KEYAWS secret access key
AWS_REGIONAWS region (default: us-east-1)
AWS_SESSION_TOKENTemporary session token (STS/SSO)

Cross-References