Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,799 changes: 1,764 additions & 3,035 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions packages/agent/test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,30 @@ describe("Agent E2E Tests", () => {
await multiTurnConversation(model);
});
});

describe.skipIf(!process.env.AWS_PROFILE)("Amazon Bedrock Provider (claude-sonnet-4-5)", () => {
const model = getModel("amazon-bedrock", "global.anthropic.claude-sonnet-4-5-20250929-v1:0");

it("should handle basic text prompt", async () => {
await basicPrompt(model);
});

it("should execute tools correctly", async () => {
await toolExecution(model);
});

it("should handle abort during execution", async () => {
await abortExecution(model);
});

it("should emit state updates during streaming", async () => {
await stateUpdates(model);
});

it("should maintain context across multiple turns", async () => {
await multiTurnConversation(model);
});
});
});

describe("Agent.continue()", () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/ai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

- Add Amazon Bedrock provider ([#494](https://github.com/badlogic/pi-mono/pull/494) by [@unexge](https://github.com/unexge))

## [0.42.0] - 2026-01-09

### Added
Expand Down
1 change: 1 addition & 0 deletions packages/ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Unified LLM API with automatic model discovery, provider configuration, token an
- **GitHub Copilot** (requires OAuth, see below)
- **Google Gemini CLI** (requires OAuth, see below)
- **Antigravity** (requires OAuth, see below)
- **Amazon Bedrock**
- **Any OpenAI-compatible API**: Ollama, vLLM, LM Studio, etc.

## Installation
Expand Down
2 changes: 2 additions & 0 deletions packages/ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@anthropic-ai/sdk": "0.71.2",
"@aws-sdk/client-bedrock-runtime": "^3.962.0",
"@google/genai": "1.34.0",
"@mistralai/mistralai": "1.10.0",
"@sinclair/typebox": "^0.34.41",
Expand All @@ -39,6 +40,7 @@
"openai",
"anthropic",
"gemini",
"bedrock",
"unified",
"api"
],
Expand Down
69 changes: 69 additions & 0 deletions packages/ai/scripts/generate-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,75 @@ async function loadModelsDevData(): Promise<Model<any>[]> {

const models: Model<any>[] = [];

// Process Amazon Bedrock models
if (data["amazon-bedrock"]?.models) {
for (const [modelId, model] of Object.entries(data["amazon-bedrock"].models)) {
const m = model as ModelsDevModel;
if (m.tool_call !== true) continue;

let id = modelId;

if (id.startsWith("ai21.jamba")) {
// These models doesn't support tool use in streaming mode
continue;
}

if (id.startsWith("amazon.titan-text-express") ||
id.startsWith("mistral.mistral-7b-instruct-v0")) {
// These models doesn't support system messages
continue;
}

// Some Amazon Bedrock models require cross-region inference profiles to work.
// To use cross-region inference, we need to add a region prefix to the models.
// See https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html#inference-profiles-support-system
// TODO: Remove Claude models once https://github.com/anomalyco/models.dev/pull/607 is merged, and follow-up with other models.

// Models with global cross-region inference profiles
if (id.startsWith("anthropic.claude-haiku-4-5") ||
id.startsWith("anthropic.claude-sonnet-4") ||
id.startsWith("anthropic.claude-opus-4-5") ||
id.startsWith("amazon.nova-2-lite") ||
id.startsWith("cohere.embed-v4") ||
id.startsWith("twelvelabs.pegasus-1-2")) {
id = "global." + id;
}

// Models with US cross-region inference profiles
if (id.startsWith("amazon.nova-lite") ||
id.startsWith("amazon.nova-micro") ||
id.startsWith("amazon.nova-premier") ||
id.startsWith("amazon.nova-pro") ||
id.startsWith("anthropic.claude-3-7-sonnet") ||
id.startsWith("anthropic.claude-opus-4-1") ||
id.startsWith("anthropic.claude-opus-4-20250514") ||
id.startsWith("deepseek.r1") ||
id.startsWith("meta.llama3-2") ||
id.startsWith("meta.llama3-3") ||
id.startsWith("meta.llama4")) {
id = "us." + id;
}

models.push({
id,
name: m.name || id,
api: "bedrock-converse-stream",
provider: "amazon-bedrock",
baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
reasoning: m.reasoning === true,
input: m.modalities?.input?.includes("image") ? ["text", "image"] : ["text"],
cost: {
input: m.cost?.input || 0,
output: m.cost?.output || 0,
cacheRead: m.cost?.cache_read || 0,
cacheWrite: m.cost?.cache_write || 0,
},
contextWindow: m.limit?.context || 4096,
maxTokens: m.limit?.output || 4096,
});
}
}

// Process Anthropic models
if (data.anthropic?.models) {
for (const [modelId, model] of Object.entries(data.anthropic.models)) {
Expand Down
Loading