v0-sdk 0.0.7 → 0.0.8

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.
Files changed (2) hide show
  1. package/README.md +23 -205
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # v0 Chat SDK
1
+ # v0 SDK
2
2
 
3
- A TypeScript SDK for interacting with the v0 API to create and manage AI-powered chat conversations, projects, integrations, and more.
3
+ > **⚠️ Developer Preview**: This SDK is currently in beta and is subject to change. Use in production at your own risk.
4
+
5
+ A TypeScript SDK for interacting with the v0 Platform API to create and manage AI-powered chat conversations, projects, integrations, and more.
4
6
 
5
7
  ## Features
6
8
 
@@ -37,15 +39,6 @@ const chat = await v0.chats.create({
37
39
  })
38
40
 
39
41
  console.log(`Chat created: ${chat.url}`)
40
- console.log(`Generated code: ${chat.files?.length} files`)
41
-
42
- // Add a message to the chat
43
- const response = await v0.chats.createMessage({
44
- chatId: chat.chatId,
45
- message: 'Add a dropdown menu to the navbar',
46
- })
47
-
48
- console.log(`AI response: ${response.text}`)
49
42
  ```
50
43
 
51
44
  ## Authentication
@@ -85,33 +78,6 @@ const result = await v0.chats.create({
85
78
 
86
79
  ```typescript
87
80
  const chat = await v0.chats.getById({ chatId: 'chat_id' })
88
- console.log(chat.messages) // Fully typed message array
89
- ```
90
-
91
- #### Manage Chat Favorites
92
-
93
- ```typescript
94
- // Favorite a chat
95
- await v0.chats.favorite({ chatId: 'chat_id' })
96
-
97
- // Unfavorite a chat
98
- await v0.chats.unfavorite({ chatId: 'chat_id' })
99
-
100
- // Get favorite chats
101
- const favorites = await v0.chats.find()
102
- ```
103
-
104
- #### Chat History and Management
105
-
106
- ```typescript
107
- // Get chat history
108
- const chats = await v0.chats.find()
109
-
110
- // Delete a chat
111
- await v0.chats.delete({ chatId: 'chat_id' })
112
-
113
- // Get chat's associated project
114
- const project = await v0.chats.getProject({ chatId: 'chat_id' })
115
81
  ```
116
82
 
117
83
  #### Add Messages to Chat
@@ -120,126 +86,65 @@ const project = await v0.chats.getProject({ chatId: 'chat_id' })
120
86
  const response = await v0.chats.createMessage({
121
87
  chatId: 'chat_id',
122
88
  message: 'Add password strength indicator',
123
- attachments: [{ url: 'https://example.com/mockup.jpg' }],
124
- modelConfiguration: {
125
- imageGenerations: true,
126
- },
127
89
  })
128
90
  ```
129
91
 
130
- #### Get Version Frame Token
92
+ #### Other Chat Operations
131
93
 
132
- ```typescript
133
- const token = await v0.chats.getVersionFrameToken({
134
- chatId: 'chat_id',
135
- versionId: 'version_id',
136
- })
137
- ```
94
+ - `v0.chats.find()` - Get chat history
95
+ - `v0.chats.delete({ chatId })` - Delete a chat
96
+ - `v0.chats.favorite({ chatId })` - Favorite a chat
97
+ - `v0.chats.unfavorite({ chatId })` - Unfavorite a chat
98
+ - `v0.chats.getProject({ chatId })` - Get chat's associated project
99
+ - `v0.chats.getVersionFrameToken({ chatId, versionId })` - Get version frame token
138
100
 
139
101
  ### Project Operations
140
102
 
141
- #### Create a Project
142
-
143
103
  ```typescript
104
+ // Create a project
144
105
  const project = await v0.projects.create({
145
106
  name: 'My New Project',
146
107
  description: 'A sample project',
147
- environmentVariables: [{ key: 'API_KEY', value: 'secret_value' }],
148
- icon: 'https://example.com/icon.png',
149
108
  })
150
- ```
151
109
 
152
- #### Find Projects
153
-
154
- ```typescript
110
+ // Find projects
155
111
  const projects = await v0.projects.find()
156
112
  ```
157
113
 
158
114
  ### Vercel Integration
159
115
 
160
- #### Create Vercel Integration Project
161
-
162
116
  ```typescript
117
+ // Create Vercel integration project
163
118
  const integration = await v0.integrations.vercel.projects.create({
164
119
  projectId: 'vercel_project_id',
165
120
  name: 'project_name',
166
121
  })
167
- ```
168
-
169
- #### Find Vercel Projects
170
122
 
171
- ```typescript
123
+ // Find Vercel projects
172
124
  const projects = await v0.integrations.vercel.projects.find()
173
125
  ```
174
126
 
175
127
  ### User Management
176
128
 
177
- #### Get User Information
178
-
179
129
  ```typescript
130
+ // Get user information
180
131
  const userResponse = await v0.user.get()
181
- console.log(userResponse.user.name, userResponse.user.email)
182
- ```
183
132
 
184
- #### Get User Plan and Billing
185
-
186
- ```typescript
133
+ // Get user plan and billing
187
134
  const planResponse = await v0.user.getPlan()
188
- console.log(planResponse.plan, planResponse.balance)
189
- ```
190
-
191
- ### Deployment and Monitoring
192
-
193
- #### Find Deployment Logs
194
135
 
195
- ```typescript
196
- const logs = await v0.deployments.findLogs({
197
- deploymentId: 'deployment_id',
198
- })
136
+ // Get user scopes
137
+ const scopesResponse = await v0.user.getScopes()
199
138
  ```
200
139
 
201
- ### Scopes and Rate Limits
202
-
203
- #### Find Scopes
140
+ ### Other Operations
204
141
 
205
142
  ```typescript
206
- const scopesResponse = await v0.scopes.find()
207
- console.log(scopesResponse.scopes)
208
- ```
209
-
210
- #### Check Rate Limits
143
+ // Find deployment logs
144
+ const logs = await v0.deployments.findLogs({ deploymentId: 'deployment_id' })
211
145
 
212
- ```typescript
146
+ // Check rate limits
213
147
  const rateLimits = await v0.rateLimits.find()
214
- console.log(rateLimits.remaining, rateLimits.reset)
215
- ```
216
-
217
- ## Working with Attachments
218
-
219
- The SDK supports URL and base64-encoded attachments:
220
-
221
- ```typescript
222
- // URL attachment
223
- const response = await v0.chats.create({
224
- message: 'Create a component based on this design',
225
- attachments: [{ url: 'https://example.com/design.png' }],
226
- })
227
-
228
- // Base64 attachment
229
- const handleFileUpload = async (file: File) => {
230
- const reader = new FileReader()
231
-
232
- reader.onload = async () => {
233
- const response = await v0.chats.create({
234
- message: 'Create a component based on this image',
235
- attachments: [{ url: reader.result as string }],
236
- })
237
-
238
- console.log(response)
239
- }
240
-
241
- reader.readAsDataURL(file)
242
- }
243
148
  ```
244
149
 
245
150
  ## TypeScript Support
@@ -252,14 +157,7 @@ import type {
252
157
  ChatsCreateResponse,
253
158
  User,
254
159
  Project,
255
- ScopeSummary,
256
160
  } from 'v0-sdk'
257
-
258
- // All request and response types are fully typed
259
- const createChatRequest: ChatsCreateRequest = {
260
- message: 'Create a component',
261
- system: 'You are a helpful assistant',
262
- }
263
161
  ```
264
162
 
265
163
  ## Error Handling
@@ -276,8 +174,6 @@ try {
276
174
  console.error('Authentication error:', error.message)
277
175
  } else if (error.status === 429) {
278
176
  console.error('Rate limit exceeded:', error.message)
279
- } else {
280
- console.error('API error:', error.message)
281
177
  }
282
178
  }
283
179
  ```
@@ -290,39 +186,6 @@ The SDK includes comprehensive test coverage. Run tests with:
290
186
  npm test
291
187
  ```
292
188
 
293
- ### Test Structure
294
-
295
- Tests are organized by functionality:
296
-
297
- ```
298
- tests/
299
- ├── chats/
300
- │ ├── create.test.ts
301
- │ ├── find.test.ts
302
- │ ├── delete.test.ts
303
- │ ├── getById.test.ts
304
- │ ├── favorite.test.ts
305
- │ ├── unfavorite.test.ts
306
- │ ├── getProject.test.ts
307
- │ ├── createMessage.test.ts
308
- │ └── getVersionFrameToken.test.ts
309
- ├── projects/
310
- │ ├── create.test.ts
311
- │ └── find.test.ts
312
- ├── integrations/vercel/projects/
313
- │ ├── create.test.ts
314
- │ └── find.test.ts
315
- ├── user/
316
- │ ├── get.test.ts
317
- │ └── getPlan.test.ts
318
- ├── deployments/
319
- │ └── findLogs.test.ts
320
- ├── scopes/
321
- │ └── find.test.ts
322
- └── rateLimits/
323
- └── find.test.ts
324
- ```
325
-
326
189
  ## Development
327
190
 
328
191
  ### Building
@@ -345,51 +208,6 @@ npm run generate
345
208
  npm test
346
209
  ```
347
210
 
348
- ## Advanced Usage
349
-
350
- ### Custom Configuration
351
-
352
- ```typescript
353
- const client = new V0Client('your_api_key', 'https://custom-api.example.com', {
354
- timeout: 30000,
355
- retries: 3,
356
- })
357
- ```
358
-
359
- ### Team Collaboration
360
-
361
- Share chats with your team:
362
-
363
- ```typescript
364
- const chat = await v0.chats.create({
365
- message: 'Create a component for our design system',
366
- chatPrivacy: 'team-edit',
367
- teamId: 'your-team-id',
368
- })
369
-
370
- // Now team members can view and edit this chat
371
- console.log(`Team chat URL: ${chat.url}`)
372
- ```
373
-
374
- ## Troubleshooting
375
-
376
- ### Rate Limiting
377
-
378
- The API has rate limits. Check your current limits:
379
-
380
- ```typescript
381
- const limits = await v0.rateLimits.find()
382
- console.log(`Remaining requests: ${limits.remaining}`)
383
- ```
384
-
385
- ### Common Errors
386
-
387
- - **403 Forbidden**: Check your API key and ensure you have a valid subscription
388
- - **400 Bad Request**: Verify your request parameters match the API requirements
389
- - **404 Not Found**: Ensure the resource ID exists and is accessible to your API key
390
- - **413 Payload Too Large**: Reduce attachment size (max 10MB per attachment)
391
- - **429 Too Many Requests**: You've hit the rate limit, wait before making more requests
392
-
393
211
  ## Resources
394
212
 
395
213
  - [v0 Documentation](https://v0.dev/docs)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v0-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "TypeScript SDK for the v0 Chats API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",