Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ await anthropic.messages.create({
npm install @stackone/ai ai @ai-sdk/openai # or: yarn/pnpm/bun add
```

> Supports AI SDK v5–v7 (`ai` `>=5.0.108 <8.0.0`). AI SDK v7 requires Node.js 22+.

```typescript
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { generateText, isStepCount } from 'ai';
import { StackOneToolSet } from '@stackone/ai';

// Reads STACKONE_API_KEY and STACKONE_ACCOUNT_ID from environment
Expand All @@ -207,9 +209,9 @@ const toolset = new StackOneToolSet();
const tools = await toolset.fetchTools();

await generateText({
model: openai('gpt-5.1'),
tools: await tools.toAISDK(),
maxSteps: 3,
model: openai('gpt-5.1'),
tools: await tools.toAISDK(),
stopWhen: isStepCount(3),
Comment thread
ybidois marked this conversation as resolved.
Outdated
});
```

Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Converts StackOne tools to Anthropic format with `tools.toAnthropic()` and sends

### [`ai-sdk-integration.ts`](./ai-sdk-integration.ts) -- Vercel AI SDK

Integrates with the Vercel AI SDK via `tools.toAISDK()`. Runs a multi-step agent loop using `generateText` with `stopWhen: stepCountIs(3)`, letting the model autonomously call tools and reason over results.
Integrates with the Vercel AI SDK via `tools.toAISDK()`. Runs a multi-step agent loop using `generateText` with `stopWhen: isStepCount(3)`, letting the model autonomously call tools and reason over results. Compatible with AI SDK v5–v7; AI SDK v7 requires Node.js 22+.
Comment thread
ybidois marked this conversation as resolved.
Outdated

### [`claude-agent-sdk-integration.ts`](./claude-agent-sdk-integration.ts) -- Claude Agent SDK

Expand Down
11 changes: 6 additions & 5 deletions examples/ai-sdk-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
* This example shows how to use StackOne tools with the AI SDK.
*
* The AI SDK provides an agent-like pattern through the `stopWhen` parameter
* with `stepCountIs()`. This creates a multi-step tool loop where the model
* with `isStepCount()`. This creates a multi-step tool loop where the model
* can autonomously call tools and reason over results until the stop condition
* is met.
*
* In AI SDK v6+, you can use the `ToolLoopAgent` class for more explicit
* agent functionality.
* Compatible with AI SDK v5–v7 (`ai` peer `>=5.0.108 <8.0.0`). AI SDK v7
* requires Node.js 22+. You can also use the `ToolLoopAgent` class for more
* explicit agent functionality.
*/

import process from 'node:process';
import { openai } from '@ai-sdk/openai';
import { StackOneToolSet } from '@stackone/ai';
import { generateText, stepCountIs } from 'ai';
import { generateText, isStepCount } from 'ai';
Comment thread
ybidois marked this conversation as resolved.
Outdated

const apiKey = process.env.STACKONE_API_KEY;
if (!apiKey) {
Expand Down Expand Up @@ -43,7 +44,7 @@ const aiSdkIntegration = async (): Promise<void> => {
model: openai('gpt-5.1'),
tools: aiSdkTools,
prompt: 'List the first 5 employees',
stopWhen: stepCountIs(3),
stopWhen: isStepCount(3),
});

console.log(`AI response: ${text}`);
Expand Down
4 changes: 2 additions & 2 deletions examples/search-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async function searchAndExecute(): Promise<void> {
console.log('\n=== 5. Search & Execute (Vercel AI SDK) ===\n');

// Dynamic imports — these are optional peer dependencies
const [{ openai }, { generateText, stepCountIs }] = await Promise.all([
const [{ openai }, { generateText, isStepCount }] = await Promise.all([
Comment thread
ybidois marked this conversation as resolved.
Outdated
import('@ai-sdk/openai'),
import('ai'),
]);
Expand All @@ -142,7 +142,7 @@ async function searchAndExecute(): Promise<void> {
model: openai('gpt-5.1'),
tools: await tools.toAISDK(),
prompt: 'List employees and return a short summary.',
stopWhen: stepCountIs(5),
stopWhen: isStepCount(5),
});

console.log(` Model completed in ${steps.length} step(s)`);
Expand Down
Loading