|
| 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