Skip to content

Context7 Platform -- Up-to-date docs for AI agents

test(tools-ai-sdk): run model tests through OpenRouter (#3254)

Fahreddin Özcan713b0a80be71
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 461d40ca..2377e2ee 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -21,7 +21,6 @@ concurrency:
permissions:
contents: read
- id-token: write
jobs:
test:
@@ -68,20 +67,11 @@ jobs:
- name: Typecheck
run: pnpm typecheck
- - name: Configure AWS credentials
- if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
- uses: aws-actions/configure-aws-credentials@v6
- with:
- role-to-assume: ${{ secrets.AWS_BEDROCK_ROLE_ARN }}
- aws-region: ${{ secrets.AWS_REGION }}
- allowed-account-ids: ${{ secrets.AWS_ACCOUNT_ID }}
- mask-aws-account-id: true
- role-session-name: context7-bedrock-${{ github.run_id }}
-
- name: Test
run: pnpm test
env:
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
+ OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
- name: SDK Integration Test
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
diff --git a/packages/tools-ai-sdk/package.json b/packages/tools-ai-sdk/package.json
index 7b9f2372..c8b15501 100644
--- a/packages/tools-ai-sdk/package.json
+++ b/packages/tools-ai-sdk/package.json
@@ -37,7 +37,7 @@
"@upstash/context7-sdk": "workspace:*",
"ai": "^6.0.5",
"zod": "^4.4.3",
- "@ai-sdk/amazon-bedrock": "^4.0.9",
+ "@openrouter/ai-sdk-provider": "^2.10.0",
"@types/node": "^25.0.3",
"dotenv": "^17.4.2",
"tsup": "^8.5.1",
diff --git a/packages/tools-ai-sdk/src/index.test.ts b/packages/tools-ai-sdk/src/index.test.ts
index 591aac53..b51353d0 100644
--- a/packages/tools-ai-sdk/src/index.test.ts
+++ b/packages/tools-ai-sdk/src/index.test.ts
@@ -1,6 +1,6 @@
import { describe, test, expect } from "vitest";
import { generateText, stepCountIs, tool } from "ai";
-import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock";
+import { createOpenRouter } from "@openrouter/ai-sdk-provider";
import { z } from "zod";
import {
resolveLibraryId,
@@ -11,10 +11,12 @@ import {
RESOLVE_LIBRARY_ID_DESCRIPTION,
} from "./index";
-const bedrock = createAmazonBedrock({
- region: process.env.AWS_REGION,
+const openrouter = createOpenRouter({
+ apiKey: process.env.OPENROUTER_API_KEY,
});
+const model = openrouter("anthropic/claude-haiku-4.5");
+
describe("@upstash/context7-tools-ai-sdk", () => {
describe("Tool structure", () => {
test("resolveLibraryId() should return a tool object with correct structure", () => {
@@ -54,7 +56,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
describe("Tool usage with generateText", () => {
test("resolveLibraryId tool should be called when searching for a library", async () => {
const result = await generateText({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
tools: {
resolveLibraryId: resolveLibraryId(),
},
@@ -73,7 +75,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
test("queryDocs tool should fetch documentation", async () => {
const result = await generateText({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
tools: {
queryDocs: queryDocs(),
},
@@ -92,7 +94,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
test("both tools can work together in a multi-step flow", async () => {
const result = await generateText({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
tools: {
resolveLibraryId: resolveLibraryId(),
queryDocs: queryDocs(),
@@ -112,7 +114,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
describe("Context7Agent class", () => {
test("should create an agent instance with model", () => {
const agent = new Context7Agent({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
});
expect(agent).toBeDefined();
@@ -122,7 +124,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
test("should accept custom stopWhen condition", () => {
const agent = new Context7Agent({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
stopWhen: stepCountIs(3),
});
@@ -131,7 +133,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
test("should accept custom instructions", () => {
const agent = new Context7Agent({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
instructions: "Custom instructions for testing",
});
@@ -140,7 +142,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
test("should accept Context7 config options", () => {
const agent = new Context7Agent({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
apiKey: "ctx7sk-test-key",
});
@@ -157,7 +159,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
});
const agent = new Context7Agent({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
tools: {
customTool,
},
@@ -168,7 +170,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
test("should generate response using agent workflow", async () => {
const agent = new Context7Agent({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
stopWhen: stepCountIs(5),
});
@@ -186,7 +188,7 @@ describe("@upstash/context7-tools-ai-sdk", () => {
test("should include Context7 tools in generate result", async () => {
const agent = new Context7Agent({
- model: bedrock("anthropic.claude-3-haiku-20240307-v1:0"),
+ model,
stopWhen: stepCountIs(5),
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d4c26dcb..e25a0ad0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -230,9 +230,9 @@ importers:
packages/tools-ai-sdk:
devDependencies:
- '@ai-sdk/amazon-bedrock':
- specifier: ^4.0.9
- version: 4.0.12([email protected])
+ '@openrouter/ai-sdk-provider':
+ specifier: ^2.10.0
'@types/node':
specifier: ^25.0.3
version: 25.0.3
@@ -260,18 +260,6 @@ importers:
packages:
- '@ai-sdk/[email protected]':
- resolution: {integrity: sha512-5NvAnCa8mQy9bxWv8tMR8u77fcOhXnxozxRtjB/to69RBFyy4ncxsTHhJEK3ypHEvaYHheBkAxSOwzEu79dW3A==}
- engines: {node: '>=18'}
- peerDependencies:
- zod: ^3.25.76 || ^4.1.8
-
- '@ai-sdk/[email protected]':
- resolution: {integrity: sha512-QBD4qDnwIHd+N5PpjxXOaWJig1aRB43J0PM5ZUe6Yyl9Qq2bUmraQjvNznkuFKy+hMFDgj0AvgGogTiO5TC+qA==}
- engines: {node: '>=18'}
- peerDependencies:
- zod: ^3.25.76 || ^4.1.8
-
'@ai-sdk/[email protected]':
resolution: {integrity: sha512-sRlPMKd38+fdp2y11USW44c0o8tsIsT6T/pgyY04VXC3URjIRnkxugxd9AkU2ogfpPDMz50cBAGPnMxj+6663Q==}
engines: {node: '>=18'}
@@ -1204,30 +1192,35 @@ packages:
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
'@mariozechner/[email protected]':
resolution: {integrity: sha512-AGuJdgKsmJdm4Pych7kv3sqe591ERRaAHW3xjLooiFzn8J+PxUyof++7YZrB5Y5tpnTO+K18Og3taj2NpluCRQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
+ libc: [musl]
'@mariozechner/[email protected]':
resolution: {integrity: sha512-DXBEAiuMpk7dhS1a9NzNxVAFi1vaKoPu7rQNgY8LIDLGrK3lnIp3nT10DUum+PKVJoJppIP+NAA8IZe4DMNDPw==}
engines: {node: '>= 10'}
cpu: [riscv64]
os: [linux]
+ libc: [glibc]
'@mariozechner/[email protected]':
resolution: {integrity: sha512-WORrMLd6EpElEME7JRKfSaY34nW1P5LbdgK5YNCS1ncG2LqmITsSMEJ8nh2mpvxb3TxqbOOKgY7k9eMJYlW9Mw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
+ libc: [glibc]
'@mariozechner/[email protected]':
resolution: {integrity: sha512-/DHn+1DrfL6oRaPPWXaOKvonFFrni666fxd+zFqiQEfvBH0tsHVWjq9iqBk0oDp0qaPA72lIMy5BptxISBEhZQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
+ libc: [musl]
'@mariozechner/[email protected]':
resolution: {integrity: sha512-O5FHD3ErkMwMhNzAfu3ggy0ug4z7btZuoQgwwxlzPrwV2bxlD6WDpqBY4NCgICAgZdDKdp+loUEKVAVt8aYnhQ==}
@@ -1342,6 +1335,13 @@ packages:
'@opencode-ai/[email protected]':
resolution: {integrity: sha512-yDImmNv4PhxdMgtiHVNWQWEVwQlAm7Dr0y4XU7CT4dOIbzgO+VP+9I02lAP7Zva1FhGeyI7oKMI2tzB9RUsWaQ==}
+ '@openrouter/[email protected]':
+ resolution: {integrity: sha512-FMsAEjLUt5pWuRE2LDC/LCvVrFjLlrEzUITH5+5SZtfq7KZ2wrOHjQVxzz92sju8S9ltpzW87CLW8/b0oBXVCw==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ ai: ^6.0.0
+ zod: ^3.25.0 || ^4.0.0
+
'@opentelemetry/[email protected]':
resolution: {integrity: sha512-OlanaW1vv7ufTqQ3/fPLI4arGt5ZoM+P8abOMki6uEYnpRazepSWDwDnnw+la7kE26SHVC18//SMccrDvLKOXQ==}
engines: {node: '>=8.0.0'}
@@ -1480,56 +1480,67 @@ packages:
resolution: {integrity: sha512-k9oD15soC/Ln6d2Wv/JOFPzZXIAIFLp6B+i14KhxAfnq76ajt0EhYc5YPeX6W1xJkAdItcVT+JhKl1QZh44/qw==}
cpu: [arm]
os: [linux]
+ libc: [glibc]
'@rollup/[email protected]':
resolution: {integrity: sha512-vTNlKq+N6CK/8UktsrFuc+/7NlEYVxgaEgRXVUVK258Z5ymho29skzW1sutgYjqNnquGwVUObAaxae8rZ6YMhg==}
cpu: [arm]
os: [linux]
+ libc: [musl]
'@rollup/[email protected]':
resolution: {integrity: sha512-RGrFLWgMhSxRs/EWJMIFM1O5Mzuz3Xy3/mnxJp/5cVhZ2XoCAxJnmNsEyeMJtpK+wu0FJFWz+QF4mjCA7AUQ3w==}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
'@rollup/[email protected]':
resolution: {integrity: sha512-kASyvfBEWYPEwe0Qv4nfu6pNkITLTb32p4yTgzFCocHnJLAHs+9LjUu9ONIhvfT/5lv4YS5muBHyuV84epBo/A==}
cpu: [arm64]
os: [linux]
+ libc: [musl]
'@rollup/[email protected]':
resolution: {integrity: sha512-JiuKcp2teLJwQ7vkJ95EwESWkNRFJD7TQgYmCnrPtlu50b4XvT5MOmurWNrCj3IFdyjBQ5p9vnrX4JM6I8OE7g==}
cpu: [loong64]
os: [linux]
+ libc: [glibc]
'@rollup/[email protected]':
resolution: {integrity: sha512-EoGSa8nd6d3T7zLuqdojxC20oBfNT8nexBbB/rkxgKj5T5vhpAQKKnD+h3UkoMuTyXkP5jTjK/ccNRmQrPNDuw==}
cpu: [ppc64]
os: [linux]
+ libc: [glibc]
'@rollup/[email protected]':
resolution: {integrity: sha512-4s+Wped2IHXHPnAEbIB0YWBv7SDohqxobiiPA1FIWZpX+w9o2i4LezzH/NkFUl8LRci/8udci6cLq+jJQlh+0g==}
cpu: [riscv64]
os: [linux]
+ libc: [glibc]
'@rollup/[email protected]':
resolution: {integrity: sha512-68k2g7+0vs2u9CxDt5ktXTngsxOQkSEV/xBbwlqYcUrAVh6P9EgMZvFsnHy4SEiUl46Xf0IObWVbMvPrr2gw8A==}
cpu: [riscv64]
os: [linux]
+ libc: [musl]
'@rollup/[email protected]':
resolution: {integrity: sha512-VYsFMpULAz87ZW6BVYw3I6sWesGpsP9OPcyKe8ofdg9LHxSbRMd7zrVrr5xi/3kMZtpWL/wC+UIJWJYVX5uTKg==}
cpu: [s390x]
os: [linux]
+ libc: [glibc]
'@rollup/[email protected]':
resolution: {integrity: sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==}
cpu: [x64]
os: [linux]
+ libc: [glibc]
'@rollup/[email protected]':
resolution: {integrity: sha512-eoROhjcc6HbZCJr+tvVT8X4fW3/5g/WkGvvmwz/88sDtSJzO7r/blvoBDgISDiCjDRZmHpwud7h+6Q9JxFwq1Q==}
cpu: [x64]
os: [linux]
+ libc: [musl]
'@rollup/[email protected]':
resolution: {integrity: sha512-OueLAWgrNSPGAdUdIjSWXw+u/02BRTcnfw9PN41D2vq/JSEPnJnVuBgw18VkN8wcd4fjUs+jFHVM4t9+kBSNLw==}
@@ -1567,10 +1578,6 @@ packages:
resolution: {integrity: sha512-vKW0MEFRU4Y3MkVZUkpJm+g9qyPGLCXhc0YLggUdSdBB4g7IaSSsCE75P9rBXyWHrXY1UYSQUl8/DwsTR7QciA==}
engines: {node: '>=18.0.0'}
- '@smithy/[email protected]':
- resolution: {integrity: sha512-Ogt4Zi9hEbIP17oQMd68qYOHUzmH47UkK7q7Gl55iIm9oKt27MUGrC5JfpMroeHjdkOliOA4Qt3NQ1xMq/nrlA==}
- engines: {node: '>=18.0.0'}
-
'@smithy/[email protected]':
resolution: {integrity: sha512-qM7AUKI4G6d7lNgaZD3lA1tWSolh5r6gcixfTZAPstVURfjIbvreVTPz+994M0yC3HbX4YYhDRgr31Xy3XwWOQ==}
engines: {node: '>=18.0.0'}
@@ -1579,10 +1586,6 @@ packages:
resolution: {integrity: sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==}
engines: {node: '>=14.0.0'}
- '@smithy/[email protected]':
- resolution: {integrity: sha512-DZZZBvC7sjcYh4MazJSGiWMI2L7E0oCiRHREDzIxi/M2LY79/21iXt6aPLHge82wi5LsuRF5A06Ds3+0mlh6CQ==}
- engines: {node: '>=18.0.0'}
-
'@smithy/[email protected]':
resolution: {integrity: sha512-/jPhevcTFPMVl6KNjbaI47iOg1zxC7IsnX4PQDGVZKMFceOXtB8IEYaB7a9VvkP/3oC60WzTeKocvSI7vLT0vA==}
engines: {node: '>=18.0.0'}
@@ -1607,22 +1610,10 @@ packages:
resolution: {integrity: sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==}
engines: {node: '>=14.0.0'}
- '@smithy/[email protected]':
- resolution: {integrity: sha512-kAY9hTKulTNevM2nlRtxAG2FQ3B2OR6QIrPY3zE5LqJy1oxzmgBGsHLWTcNhWXKchgA0WHW+mZkQrng/pgcCew==}
- engines: {node: '>=18.0.0'}
-
- '@smithy/[email protected]':
- resolution: {integrity: sha512-CCQBwJIvXMLKxVbO88IukazJD9a4kQ9ZN7/UMGBjBcJYvatpWk+9g870El4cB8/EJxfe+k+y0GmR9CAzkF+Nbw==}
- engines: {node: '>=18.0.0'}
-
'@smithy/[email protected]':
resolution: {integrity: sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==}
engines: {node: '>=14.0.0'}
- '@smithy/[email protected]':
- resolution: {integrity: sha512-zBPfuzoI8xyBtR2P6WQj63Rz8i3AmfAaJLuNG8dWsfvPe8lO4aCPYLn879mEgHndZH1zQ2oXmG8O1GGzzaoZiw==}
- engines: {node: '>=18.0.0'}
-
'@standard-schema/[email protected]':
resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
@@ -1859,9 +1850,6 @@ packages:
resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
engines: {node: '>=12'}
- resolution: {integrity: sha512-/djoAN709iY65ETD6LKCtyyEI04XIBP5xVvfmNxsEP0uJB5tyaGBztSryRr4HqMStr9R06PisQE7m9zDTXKu6g==}
-
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
@@ -3520,22 +3508,6 @@ packages:
snapshots:
- dependencies:
- '@ai-sdk/anthropic': 3.0.9([email protected])
- '@ai-sdk/provider': 3.0.2
- '@ai-sdk/provider-utils': 4.0.4([email protected])
- '@smithy/eventstream-codec': 4.2.5
- '@smithy/util-utf8': 4.2.0
- aws4fetch: 1.0.20
- zod: 4.4.3
-
- dependencies:
- '@ai-sdk/provider': 3.0.2
- '@ai-sdk/provider-utils': 4.0.4([email protected])
- zod: 4.4.3
-
dependencies:
'@ai-sdk/provider': 3.0.2
@@ -4633,6 +4605,11 @@ snapshots:
dependencies:
cross-spawn: 7.0.6
+ dependencies:
+ ai: 6.0.23([email protected])
+ zod: 4.4.3
+
'@opentelemetry/[email protected]':
dependencies:
'@opentelemetry/api': 1.9.1
@@ -4809,13 +4786,6 @@ snapshots:
'@smithy/types': 4.14.2
tslib: 2.8.1
- '@smithy/[email protected]':
- dependencies:
- '@aws-crypto/crc32': 5.2.0
- '@smithy/types': 4.9.0
- '@smithy/util-hex-encoding': 4.2.0
- tslib: 2.8.1
-
'@smithy/[email protected]':
dependencies:
'@smithy/core': 3.24.4
@@ -4826,10 +4796,6 @@ snapshots:
dependencies:
tslib: 2.8.1
- '@smithy/[email protected]':
- dependencies:
- tslib: 2.8.1
-
'@smithy/[email protected]':
dependencies:
'@smithy/core': 3.24.4
@@ -4861,25 +4827,11 @@ snapshots:
'@smithy/is-array-buffer': 2.2.0
tslib: 2.8.1
- '@smithy/[email protected]':
- dependencies:
- '@smithy/is-array-buffer': 4.2.0
- tslib: 2.8.1
-
- '@smithy/[email protected]':
- dependencies:
- tslib: 2.8.1
-
'@smithy/[email protected]':
dependencies:
'@smithy/util-buffer-from': 2.2.0
tslib: 2.8.1
- '@smithy/[email protected]':
- dependencies:
- '@smithy/util-buffer-from': 4.2.0
- tslib: 2.8.1
-
'@standard-schema/[email protected]': {}
@@ -5177,8 +5129,6 @@ snapshots:
-