Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .changeset/smooth-beds-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ai-gateway-provider": patch
---

Add Amazon Bedrock endpoint routing for AI Gateway provider requests.
1 change: 1 addition & 0 deletions packages/ai-gateway-provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const aigateway = createAiGateway({

- OpenAI
- Anthropic
- Amazon Bedrock
- DeepSeek
- Google AI Studio
- Grok
Expand Down
15 changes: 15 additions & 0 deletions packages/ai-gateway-provider/src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ export const providers = [
},
headerKey: "api-key",
},
{
name: "aws-bedrock",
regex: /^https:\/\/bedrock-runtime\.(?<region>[^.]+)\.amazonaws\.com\/(?<rest>.*)$/,
transformEndpoint: (url: string) => {
const match = url.match(
/^https:\/\/bedrock-runtime\.(?<region>[^.]+)\.amazonaws\.com\/(?<rest>.*)$/,
);
if (!match || !match.groups) return url;
const { region, rest } = match.groups;
if (!region || rest === undefined) {
throw new Error("Failed to parse Amazon Bedrock endpoint URL.");
}
return `bedrock-runtime/${region}/${rest}`;
},
},
{
name: "openrouter",
regex: /^https:\/\/openrouter\.ai\/api\//,
Expand Down
6 changes: 6 additions & 0 deletions packages/ai-gateway-provider/test/endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const testCases = [
name: "azure-openai",
url: "https://myresource.openai.azure.com/openai/deployments/mydeployment/chat/completions?api-version=2024-02-15-preview",
},
{
expected:
"bedrock-runtime/us-east-1/model/us.anthropic.claude-haiku-4-5-20251001-v1:0/invoke",
name: "aws-bedrock",
url: "https://bedrock-runtime.us-east-1.amazonaws.com/model/us.anthropic.claude-haiku-4-5-20251001-v1:0/invoke",
},
];

describe("ProvidersConfigs endpoint parsing", () => {
Expand Down