Skip to content

Commit 6373cfe

Browse files
authored
docs(readme): reorganise structure and add new integration examples (#223)
* docs(readme): reorganise structure and add new integration examples Reorganise README for improved readability and discoverability: - Move Development Environment section to the bottom - Convert integrations to collapsible details sections - Add Anthropic Claude integration with toAnthropic() usage - Add OpenAI Responses API integration with toOpenAIResponses() - Include installation commands within each integration section - Add bun as a package manager option throughout - Remove separate "Optional: AI SDK Integration" section The collapsible sections reduce visual clutter while keeping all integration documentation easily accessible. Each integration now includes its required dependencies inline. * docs(readme): move Integrations section after Usage Reorder sections for better logical flow: 1. Installation - how to install the package 2. Usage - basic usage with authentication and account IDs 3. Integrations - framework-specific examples (OpenAI, Anthropic, etc.) 4. Features - advanced functionality 5. Development Environment - contributor setup Users should understand basic usage patterns before seeing framework-specific integration examples. * docs(readme): remove duplicate Optional AI SDK section Each integration example already includes its own installation instructions within the collapsible details section. * docs(readme): add @stackone/ai to all integration install commands Each integration example now includes @stackone/ai in the npm install command to ensure users install all required dependencies. * docs(readme): use gpt-5.1 model in TanStack AI example * docs(examples): use gpt-5.1 model in TanStack AI example
1 parent e890de1 commit 6373cfe

File tree

2 files changed

+165
-81
lines changed

2 files changed

+165
-81
lines changed

README.md

Lines changed: 164 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,74 @@ yarn add @stackone/ai
2121

2222
# Using pnpm
2323
pnpm add @stackone/ai
24+
25+
# Using bun
26+
bun add @stackone/ai
2427
```
2528

26-
### Optional: AI SDK Integration
29+
## Usage
2730

28-
If you plan to use the AI SDK integration (Vercel AI SDK), install it separately:
31+
```typescript
32+
import { StackOneToolSet } from "@stackone/ai";
2933

30-
```bash
31-
# Using npm
32-
npm install ai
34+
const toolset = new StackOneToolSet({
35+
baseUrl: "https://api.stackone.com",
36+
accountId: "your-account-id",
37+
});
3338

34-
# Using yarn
35-
yarn add ai
39+
const tools = await toolset.fetchTools();
40+
const employeeTool = tools.getTool("bamboohr_list_employees");
41+
const employees = await employeeTool.execute();
42+
```
3643

37-
# Using pnpm
38-
pnpm add ai
44+
### Authentication
45+
46+
Set the `STACKONE_API_KEY` environment variable:
47+
48+
```bash
49+
export STACKONE_API_KEY=<your-api-key>
3950
```
4051

41-
## Development Environment
52+
or load from a .env file using your preferred environment variable library.
4253

43-
### Using Nix Flake
54+
### Account IDs
4455

45-
This project includes a Nix flake for reproducible development environments. If you have Nix installed with flakes enabled, you can use it to set up your development environment:
56+
StackOne uses account IDs to identify different integrations. You can specify the account ID at different levels:
4657

47-
```bash
48-
# Enter development shell
49-
nix develop
58+
```typescript
59+
import { StackOneToolSet } from "@stackone/ai";
5060

51-
# Or use direnv for automatic activation
52-
echo "use flake" > .envrc
53-
direnv allow
54-
```
61+
// Single account - simplest approach
62+
const toolset = new StackOneToolSet({ accountId: "your-bamboohr-account" });
63+
const tools = await toolset.fetchTools();
5564

56-
The flake provides all necessary development dependencies including Node.js, pnpm, and other build tools.
65+
// Multiple accounts - returns tools from both integrations
66+
const multiAccountToolset = new StackOneToolSet();
67+
const allTools = await multiAccountToolset.fetchTools({
68+
accountIds: ["bamboohr-account-123", "workday-account-456"],
69+
});
70+
71+
// Filter to specific integration when using multiple accounts
72+
const bamboohrOnly = await multiAccountToolset.fetchTools({
73+
accountIds: ["bamboohr-account-123", "workday-account-456"],
74+
actions: ["bamboohr_*"], // Only BambooHR tools
75+
});
76+
77+
// Set directly on a tool instance
78+
tools.setAccountId("direct-account-id");
79+
const currentAccountId = tools.getAccountId(); // Get the current account ID
80+
```
5781

5882
## Integrations
5983

6084
The StackOneToolSet makes it super easy to use StackOne APIs as tools in your AI applications.
6185

62-
### With OpenAI library
86+
<details>
87+
<summary><strong>With OpenAI Chat Completions API</strong></summary>
88+
89+
```bash
90+
npm install @stackone/ai openai # or: yarn/pnpm/bun add
91+
```
6392

6493
```typescript
6594
import { OpenAI } from "openai";
@@ -90,7 +119,84 @@ await openai.chat.completions.create({
90119

91120
[View full example](examples/openai-integration.ts)
92121

93-
### AI SDK by Vercel
122+
</details>
123+
124+
<details>
125+
<summary><strong>With OpenAI Responses API</strong></summary>
126+
127+
```bash
128+
npm install @stackone/ai openai # or: yarn/pnpm/bun add
129+
```
130+
131+
```typescript
132+
import OpenAI from "openai";
133+
import { StackOneToolSet } from "@stackone/ai";
134+
135+
const toolset = new StackOneToolSet({
136+
baseUrl: "https://api.stackone.com",
137+
accountId: "your-account-id",
138+
});
139+
140+
const tools = await toolset.fetchTools();
141+
142+
const openai = new OpenAI();
143+
144+
await openai.responses.create({
145+
model: "gpt-5.1",
146+
instructions: "You are a helpful HR assistant.",
147+
input: "What is the phone number for employee c28xIQ?",
148+
tools: tools.toOpenAIResponses(),
149+
});
150+
```
151+
152+
[View full example](examples/openai-responses-integration.ts)
153+
154+
</details>
155+
156+
<details>
157+
<summary><strong>With Anthropic Claude</strong></summary>
158+
159+
```bash
160+
npm install @stackone/ai @anthropic-ai/sdk # or: yarn/pnpm/bun add
161+
```
162+
163+
```typescript
164+
import Anthropic from "@anthropic-ai/sdk";
165+
import { StackOneToolSet } from "@stackone/ai";
166+
167+
const toolset = new StackOneToolSet({
168+
baseUrl: "https://api.stackone.com",
169+
accountId: "your-account-id",
170+
});
171+
172+
const tools = await toolset.fetchTools();
173+
174+
const anthropic = new Anthropic();
175+
176+
await anthropic.messages.create({
177+
model: "claude-haiku-4-5-20241022",
178+
max_tokens: 1024,
179+
system: "You are a helpful HR assistant.",
180+
messages: [
181+
{
182+
role: "user",
183+
content: "What is the phone number for employee c28xIQ?",
184+
},
185+
],
186+
tools: tools.toAnthropic(),
187+
});
188+
```
189+
190+
[View full example](examples/anthropic-integration.ts)
191+
192+
</details>
193+
194+
<details>
195+
<summary><strong>With AI SDK by Vercel</strong></summary>
196+
197+
```bash
198+
npm install @stackone/ai ai @ai-sdk/openai # or: yarn/pnpm/bun add
199+
```
94200

95201
```typescript
96202
import { openai } from "@ai-sdk/openai";
@@ -113,7 +219,14 @@ await generateText({
113219

114220
[View full example](examples/ai-sdk-integration.ts)
115221

116-
### TanStack AI
222+
</details>
223+
224+
<details>
225+
<summary><strong>With TanStack AI</strong></summary>
226+
227+
```bash
228+
npm install @stackone/ai @tanstack/ai @tanstack/ai-openai zod # or: yarn/pnpm/bun add
229+
```
117230

118231
```typescript
119232
import { chat } from "@tanstack/ai";
@@ -144,7 +257,7 @@ const getEmployeeTool = {
144257
const adapter = openai();
145258
const stream = chat({
146259
adapter,
147-
model: "gpt-4o",
260+
model: "gpt-5.1",
148261
messages: [{ role: "user", content: "Get employee with id: abc123" }],
149262
tools: [getEmployeeTool],
150263
});
@@ -156,7 +269,14 @@ for await (const chunk of stream) {
156269

157270
[View full example](examples/tanstack-ai-integration.ts)
158271

159-
### Claude Agent SDK
272+
</details>
273+
274+
<details>
275+
<summary><strong>With Claude Agent SDK</strong></summary>
276+
277+
```bash
278+
npm install @stackone/ai @anthropic-ai/claude-agent-sdk zod # or: yarn/pnpm/bun add
279+
```
160280

161281
```typescript
162282
import { query, tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
@@ -207,58 +327,7 @@ for await (const message of result) {
207327

208328
[View full example](examples/claude-agent-sdk-integration.ts)
209329

210-
## Usage
211-
212-
```typescript
213-
import { StackOneToolSet } from "@stackone/ai";
214-
215-
const toolset = new StackOneToolSet({
216-
baseUrl: "https://api.stackone.com",
217-
accountId: "your-account-id",
218-
});
219-
220-
const tools = await toolset.fetchTools();
221-
const employeeTool = tools.getTool("bamboohr_list_employees");
222-
const employees = await employeeTool.execute();
223-
```
224-
225-
### Authentication
226-
227-
Set the `STACKONE_API_KEY` environment variable:
228-
229-
```bash
230-
export STACKONE_API_KEY=<your-api-key>
231-
```
232-
233-
or load from a .env file using your preferred environment variable library.
234-
235-
### Account IDs
236-
237-
StackOne uses account IDs to identify different integrations. You can specify the account ID at different levels:
238-
239-
```typescript
240-
import { StackOneToolSet } from "@stackone/ai";
241-
242-
// Single account - simplest approach
243-
const toolset = new StackOneToolSet({ accountId: "your-bamboohr-account" });
244-
const tools = await toolset.fetchTools();
245-
246-
// Multiple accounts - returns tools from both integrations
247-
const multiAccountToolset = new StackOneToolSet();
248-
const allTools = await multiAccountToolset.fetchTools({
249-
accountIds: ["bamboohr-account-123", "workday-account-456"],
250-
});
251-
252-
// Filter to specific integration when using multiple accounts
253-
const bamboohrOnly = await multiAccountToolset.fetchTools({
254-
accountIds: ["bamboohr-account-123", "workday-account-456"],
255-
actions: ["bamboohr_*"], // Only BambooHR tools
256-
});
257-
258-
// Set directly on a tool instance
259-
tools.setAccountId("direct-account-id");
260-
const currentAccountId = tools.getAccountId(); // Get the current account ID
261-
```
330+
</details>
262331

263332
## Features
264333

@@ -306,7 +375,7 @@ This is especially useful when you want to:
306375

307376
Meta tools enable dynamic tool discovery and execution, allowing AI agents to search for relevant tools based on natural language queries without hardcoding tool names.
308377

309-
> ⚠️ **Beta Feature**: Meta tools are currently in beta and the API may change in future versions.
378+
> **Beta Feature**: Meta tools are currently in beta and the API may change in future versions.
310379
311380
#### How Meta Tools Work
312381

@@ -382,8 +451,6 @@ import { StackOneToolSet } from "@stackone/ai";
382451
const toolset = new StackOneToolSet({ baseUrl: "https://api.example-dev.com" });
383452
```
384453

385-
[View full example](examples/custom-base-url.ts)
386-
387454
### Testing with dryRun
388455

389456
You can use the `dryRun` option to return the api arguments from a tool call without making the actual api call:
@@ -528,3 +595,20 @@ When AI agents use this tool, they will:
528595
5. **Report results**: Show which accounts received the feedback successfully
529596

530597
The tool description includes clear instructions for AI agents to always ask for explicit user consent before submitting feedback.
598+
599+
## Development Environment
600+
601+
### Using Nix Flake
602+
603+
This project includes a Nix flake for reproducible development environments. If you have Nix installed with flakes enabled, you can use it to set up your development environment:
604+
605+
```bash
606+
# Enter development shell
607+
nix develop
608+
609+
# Or use direnv for automatic activation
610+
echo "use flake" > .envrc
611+
direnv allow
612+
```
613+
614+
The flake provides all necessary development dependencies including Node.js, pnpm, and other build tools.

examples/tanstack-ai-integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const tanstackAiIntegration = async (): Promise<void> => {
5555
const adapter = openai();
5656
const stream = chat({
5757
adapter,
58-
model: 'gpt-4o',
58+
model: 'gpt-5.1',
5959
messages: [
6060
{
6161
role: 'user',

0 commit comments

Comments
 (0)