Skip to content

Commit 6ce7eb3

Browse files
scottiducatiScott Nelson
andauthored
feat: add AWS Bedrock provider integration (#395)
Co-authored-by: Scott Nelson <snelson@Scotts-MacBook-Pro.local>
1 parent b44f534 commit 6ce7eb3

File tree

10 files changed

+921
-0
lines changed

10 files changed

+921
-0
lines changed

src/ax-ai-aws-bedrock/.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.test.ts
2+
*.test-d.ts
3+
tsconfig.json
4+
tsup.config.ts
5+
.gitignore
6+
.npmignore
7+
src/
8+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Package files are formatted by package managers
2+
package.json
3+
package-lock.json
4+
yarn.lock
5+
pnpm-lock.yaml
6+
7+
# Build outputs and distributions
8+
dist
9+
build
10+
11+
# Generated indexes
12+
index.ts
13+
14+
# Dependencies
15+
node_modules
16+
.pnpm-store
17+
18+
# Documentation
19+
docs
20+
21+
# Cache directories
22+
.cache
23+
.temp

src/ax-ai-aws-bedrock/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# AWS Bedrock Provider for AX
2+
3+
Production-ready AWS Bedrock integration for AX library. Supports Claude, GPT OSS, and Titan Embed models.
4+
5+
## Features
6+
7+
- **Claude models**: Sonnet 3.5, 3.7, 4.0
8+
- **GPT OSS models**: 120B, 20B
9+
- **Embeddings**: Titan Embed V2
10+
- Regional failover (separate configs for Claude and GPT)
11+
- Token usage tracking
12+
- Works with AX signatures, flows, and optimizers
13+
14+
## Installation
15+
16+
```bash
17+
npm install @ax-llm/ax-ai-aws-bedrock @ax-llm/ax @aws-sdk/client-bedrock-runtime
18+
```
19+
20+
## Quick Start
21+
22+
```typescript
23+
import { AxAIBedrock, AxAIBedrockModel } from '@ax-llm/ax-ai-aws-bedrock';
24+
25+
const ai = new AxAIBedrock({
26+
region: 'us-east-2',
27+
fallbackRegions: ['us-west-2', 'us-east-1'],
28+
config: {
29+
model: AxAIBedrockModel.ClaudeSonnet4,
30+
temperature: 0.7,
31+
maxTokens: 4096,
32+
},
33+
});
34+
35+
const response = await ai.chat({
36+
chatPrompt: [
37+
{ role: 'system', content: 'You are a helpful assistant.' },
38+
{ role: 'user', content: 'What is AWS Bedrock?' },
39+
],
40+
});
41+
```
42+
43+
## With AX Signatures
44+
45+
```typescript
46+
import { AxSignature, AxGen } from '@ax-llm/ax';
47+
48+
const ai = new AxAIBedrock({ config: { model: AxAIBedrockModel.ClaudeSonnet4 } });
49+
const summarize = new AxSignature('document: string -> summary: string');
50+
const program = new AxGen(summarize, { ai });
51+
52+
const result = await program.forward({ document: 'Your text...' });
53+
```
54+
55+
## Available Models
56+
57+
```typescript
58+
// Claude
59+
AxAIBedrockModel.ClaudeSonnet4; // us.anthropic.claude-sonnet-4-20250514-v1:0
60+
AxAIBedrockModel.Claude37Sonnet; // anthropic.claude-3-7-sonnet-20250219-v1:0
61+
AxAIBedrockModel.Claude35Sonnet; // anthropic.claude-3-5-sonnet-20240620-v1:0
62+
63+
// GPT OSS
64+
AxAIBedrockModel.GptOss120B; // openai.gpt-oss-120b-1:0
65+
AxAIBedrockModel.GptOss20B; // openai.gpt-oss-20b-1:0
66+
67+
// Embeddings
68+
AxAIBedrockEmbedModel.TitanEmbedV2; // amazon.titan-embed-text-v2:0
69+
```
70+
71+
## Testing
72+
73+
```bash
74+
bun test packages/api/src/agent/ax-main/src/ax/ai/bedrock/api.test.ts
75+
```
76+
77+
See `examples.ts` and `QUICKSTART.md` for more examples.

0 commit comments

Comments
 (0)