@v0-sdk/ai-tools 0.3.9 → 3.0.0-canary.4360778
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -249
- package/dist/index.cjs +1 -1031
- package/dist/index.d.cts +22 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -50
- package/LICENSE +0 -13
- package/dist/index.d.ts +0 -2034
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1021
package/README.md
CHANGED
|
@@ -1,271 +1,55 @@
|
|
|
1
1
|
# @v0-sdk/ai-tools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AI SDK tools for the v0 Platform API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The tools are generated at build time from `packages/v0-sdk/openapi.json`, the
|
|
6
|
+
checked-in SDK copy of the v0 repo's `api/openapi-v2.json` spec. This is the
|
|
7
|
+
same OpenAPI document used to generate the `v0` SDK. Every OpenAPI operation is
|
|
8
|
+
exposed with a canonical key derived from its full `operationId`.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **AI SDK**: ^5.0.0
|
|
10
|
-
- **Zod**: ^3.23.8 (required for AI SDK 5 compatibility)
|
|
11
|
-
- **Node.js**: >=22
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install @v0-sdk/ai-tools ai zod@^3.23.8
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Quick Start
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
10
|
+
```ts
|
|
22
11
|
import { generateText } from 'ai'
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
const result = await generateText({
|
|
26
|
-
model: 'openai/gpt-4',
|
|
27
|
-
prompt: 'Create a new React component for a todo list',
|
|
28
|
-
tools: v0Tools({
|
|
29
|
-
apiKey: process.env.V0_API_KEY,
|
|
30
|
-
}),
|
|
31
|
-
})
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
That's it! `v0Tools()` returns all available tools in a flat structure ready to use with the AI SDK.
|
|
35
|
-
|
|
36
|
-
## Usage Patterns
|
|
37
|
-
|
|
38
|
-
### Organized by Category (Recommended - Better Context Management)
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { v0ToolsByCategory } from '@v0-sdk/ai-tools'
|
|
42
|
-
|
|
43
|
-
const tools = v0ToolsByCategory({ apiKey: process.env.V0_API_KEY })
|
|
44
|
-
|
|
45
|
-
const result = await generateText({
|
|
46
|
-
model: 'openai/gpt-4',
|
|
47
|
-
prompt: 'Help me manage my v0 projects',
|
|
48
|
-
tools: {
|
|
49
|
-
// Only include specific categories you need
|
|
50
|
-
...tools.chat,
|
|
51
|
-
...tools.project,
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### All Tools (High Context Usage)
|
|
57
|
-
|
|
58
|
-
⚠️ **Note**: This includes all ~20+ tools which adds significant context to your AI calls.
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
import { v0Tools } from '@v0-sdk/ai-tools'
|
|
62
|
-
|
|
63
|
-
const result = await generateText({
|
|
64
|
-
model: 'openai/gpt-4',
|
|
65
|
-
prompt: 'Complete workflow: create project, chat, and deploy',
|
|
66
|
-
tools: v0Tools({ apiKey: process.env.V0_API_KEY }), // All tools available
|
|
67
|
-
})
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Organized by Category (Alternative Pattern)
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
import { v0ToolsByCategory } from '@v0-sdk/ai-tools'
|
|
74
|
-
|
|
75
|
-
const tools = v0ToolsByCategory({ apiKey: process.env.V0_API_KEY })
|
|
76
|
-
|
|
77
|
-
const result = await generateText({
|
|
78
|
-
model: 'openai/gpt-4',
|
|
79
|
-
prompt: 'Help me manage my v0 projects',
|
|
80
|
-
tools: {
|
|
81
|
-
// Only include specific categories
|
|
82
|
-
...tools.chat,
|
|
83
|
-
...tools.project,
|
|
84
|
-
},
|
|
85
|
-
})
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Individual Tool Creators (For Granular Control)
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
import { createChatTools, createProjectTools } from '@v0-sdk/ai-tools'
|
|
92
|
-
|
|
93
|
-
const chatTools = createChatTools({ apiKey: process.env.V0_API_KEY })
|
|
94
|
-
const projectTools = createProjectTools({ apiKey: process.env.V0_API_KEY })
|
|
95
|
-
|
|
96
|
-
const result = await generateText({
|
|
97
|
-
model: 'openai/gpt-4',
|
|
98
|
-
prompt: 'Create a chat in my existing project',
|
|
99
|
-
tools: {
|
|
100
|
-
// Pick specific tools
|
|
101
|
-
createChat: chatTools.createChat,
|
|
102
|
-
sendMessage: chatTools.sendMessage,
|
|
103
|
-
getProject: projectTools.getProject,
|
|
104
|
-
assignChatToProject: projectTools.assignChatToProject,
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Available Tools
|
|
110
|
-
|
|
111
|
-
### Chat Tools (`tools.chat`)
|
|
112
|
-
|
|
113
|
-
| Tool | Description |
|
|
114
|
-
| -------------- | --------------------------------------------- |
|
|
115
|
-
| `createChat` | Create a new chat with v0 |
|
|
116
|
-
| `sendMessage` | Send a message to an existing chat |
|
|
117
|
-
| `getChat` | Get details of an existing chat |
|
|
118
|
-
| `updateChat` | Update chat properties (name, privacy) |
|
|
119
|
-
| `deleteChat` | Delete an existing chat |
|
|
120
|
-
| `favoriteChat` | Toggle favorite status of a chat |
|
|
121
|
-
| `forkChat` | Fork an existing chat to create a new version |
|
|
122
|
-
| `listChats` | List all chats with filtering options |
|
|
123
|
-
|
|
124
|
-
### Project Tools (`tools.project`)
|
|
125
|
-
|
|
126
|
-
| Tool | Description |
|
|
127
|
-
| ---------------------------- | ------------------------------------------ |
|
|
128
|
-
| `createProject` | Create a new project in v0 |
|
|
129
|
-
| `getProject` | Get details of an existing project |
|
|
130
|
-
| `updateProject` | Update project properties |
|
|
131
|
-
| `listProjects` | List all projects |
|
|
132
|
-
| `assignChatToProject` | Assign a chat to a project |
|
|
133
|
-
| `getProjectByChat` | Get project details by chat ID |
|
|
134
|
-
| `createEnvironmentVariables` | Create environment variables for a project |
|
|
135
|
-
| `listEnvironmentVariables` | List environment variables for a project |
|
|
136
|
-
| `updateEnvironmentVariables` | Update environment variables |
|
|
137
|
-
| `deleteEnvironmentVariables` | Delete environment variables |
|
|
138
|
-
|
|
139
|
-
### Deployment Tools (`tools.deployment`)
|
|
140
|
-
|
|
141
|
-
| Tool | Description |
|
|
142
|
-
| --------------------- | ---------------------------------------------- |
|
|
143
|
-
| `createDeployment` | Create a new deployment from a chat version |
|
|
144
|
-
| `getDeployment` | Get details of an existing deployment |
|
|
145
|
-
| `deleteDeployment` | Delete an existing deployment |
|
|
146
|
-
| `listDeployments` | List deployments by project, chat, and version |
|
|
147
|
-
| `getDeploymentLogs` | Get logs for a deployment |
|
|
148
|
-
| `getDeploymentErrors` | Get errors for a deployment |
|
|
149
|
-
|
|
150
|
-
### User Tools (`tools.user`)
|
|
151
|
-
|
|
152
|
-
| Tool | Description |
|
|
153
|
-
| ---------------- | ------------------------------------ |
|
|
154
|
-
| `getCurrentUser` | Get current user information |
|
|
155
|
-
| `getUserBilling` | Get current user billing information |
|
|
156
|
-
| `getUserPlan` | Get current user plan information |
|
|
157
|
-
| `getUserScopes` | Get user scopes/permissions |
|
|
158
|
-
| `getRateLimits` | Get current rate limit information |
|
|
159
|
-
|
|
160
|
-
### Hook Tools (`tools.hook`)
|
|
161
|
-
|
|
162
|
-
| Tool | Description |
|
|
163
|
-
| ------------ | ---------------------------------------- |
|
|
164
|
-
| `createHook` | Create a new webhook for v0 events |
|
|
165
|
-
| `getHook` | Get details of an existing webhook |
|
|
166
|
-
| `updateHook` | Update properties of an existing webhook |
|
|
167
|
-
| `deleteHook` | Delete an existing webhook |
|
|
168
|
-
| `listHooks` | List all webhooks |
|
|
169
|
-
|
|
170
|
-
## Configuration
|
|
171
|
-
|
|
172
|
-
### Environment Variables
|
|
173
|
-
|
|
174
|
-
Set your v0 API key as an environment variable:
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
export V0_API_KEY=your_api_key_here
|
|
178
|
-
```
|
|
12
|
+
import { openai } from '@ai-sdk/openai'
|
|
13
|
+
import { v0Tools, v0ToolsByCategory } from '@v0-sdk/ai-tools'
|
|
179
14
|
|
|
180
|
-
|
|
15
|
+
const allTools = v0Tools({ auth: process.env.V0_API_KEY })
|
|
181
16
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const tools = v0Tools({
|
|
186
|
-
apiKey: 'your_api_key_here',
|
|
187
|
-
baseUrl: 'https://api.v0.dev', // optional, defaults to v0's API
|
|
188
|
-
})
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## Examples
|
|
192
|
-
|
|
193
|
-
### Complete Workflow Example
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
import { generateText } from 'ai'
|
|
197
|
-
import { v0Tools } from '@v0-sdk/ai-tools'
|
|
198
|
-
|
|
199
|
-
const result = await generateText({
|
|
200
|
-
model: 'openai/gpt-4',
|
|
201
|
-
prompt: `Help me with a complete v0 workflow:
|
|
202
|
-
1. Create a new project for an e-commerce site
|
|
203
|
-
2. Create a chat in that project to design a product catalog
|
|
204
|
-
3. Send a message asking for a React component
|
|
205
|
-
4. Deploy the result
|
|
206
|
-
5. Check deployment logs`,
|
|
207
|
-
tools: v0Tools({
|
|
208
|
-
apiKey: process.env.V0_API_KEY,
|
|
209
|
-
}),
|
|
17
|
+
const { chats, messages } = v0ToolsByCategory({
|
|
18
|
+
auth: process.env.V0_API_KEY,
|
|
210
19
|
})
|
|
211
20
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
### Project Management Example
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
import { generateText } from 'ai'
|
|
219
|
-
import { v0ToolsByCategory } from '@v0-sdk/ai-tools'
|
|
220
|
-
|
|
221
|
-
const tools = v0ToolsByCategory({ apiKey: process.env.V0_API_KEY })
|
|
222
|
-
|
|
223
|
-
const result = await generateText({
|
|
224
|
-
model: 'openai/gpt-4',
|
|
225
|
-
prompt:
|
|
226
|
-
'Create a new project called "My Portfolio" with environment variables for API keys',
|
|
21
|
+
await generateText({
|
|
22
|
+
model: openai('gpt-4.1'),
|
|
227
23
|
tools: {
|
|
228
|
-
|
|
229
|
-
...
|
|
24
|
+
...chats,
|
|
25
|
+
...messages,
|
|
230
26
|
},
|
|
27
|
+
prompt: 'Create a new v0 chat for a pricing page.',
|
|
231
28
|
})
|
|
232
29
|
```
|
|
233
30
|
|
|
234
|
-
##
|
|
31
|
+
## Tool names
|
|
235
32
|
|
|
236
|
-
|
|
33
|
+
Tool keys are canonical operation names, not friendly aliases:
|
|
237
34
|
|
|
238
|
-
|
|
239
|
-
|
|
35
|
+
- `chats.create` becomes `chatsCreate`
|
|
36
|
+
- `messages.send` becomes `messagesSend`
|
|
37
|
+
- `organizations.teams.listApiKeys` becomes `organizationsTeamsListApiKeys`
|
|
240
38
|
|
|
241
|
-
|
|
242
|
-
apiKey: process.env.V0_API_KEY,
|
|
243
|
-
baseUrl: 'https://api.v0.dev',
|
|
244
|
-
}
|
|
39
|
+
## Categories
|
|
245
40
|
|
|
246
|
-
|
|
247
|
-
|
|
41
|
+
Use `v0ToolsByCategory(config)` to select operations by the first
|
|
42
|
+
`operationId` segment:
|
|
248
43
|
|
|
249
|
-
|
|
44
|
+
```ts
|
|
45
|
+
const tools = v0ToolsByCategory({ auth: process.env.V0_API_KEY })
|
|
250
46
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
model: 'openai/gpt-4',
|
|
257
|
-
prompt: 'Create a chat',
|
|
258
|
-
tools: v0Tools({ apiKey: 'invalid-key' }),
|
|
259
|
-
})
|
|
260
|
-
} catch (error) {
|
|
261
|
-
console.error('Error:', error.message)
|
|
262
|
-
}
|
|
47
|
+
tools.chats
|
|
48
|
+
tools.messages
|
|
49
|
+
tools.mcpServers
|
|
50
|
+
tools.organizations
|
|
51
|
+
tools.webhooks
|
|
263
52
|
```
|
|
264
53
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
This package is part of the v0 SDK monorepo. See the main repository for contribution guidelines.
|
|
268
|
-
|
|
269
|
-
## License
|
|
270
|
-
|
|
271
|
-
Apache 2.0
|
|
54
|
+
The keys inside each category are still globally unique canonical names, so
|
|
55
|
+
multiple categories can be safely spread together.
|