v0-sdk 0.0.12 → 0.1.0
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 +52 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,17 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
A TypeScript SDK for interacting with the v0 Platform API to create and manage AI-powered chat conversations, projects, integrations, and more.
|
|
6
6
|
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- Full TypeScript support with complete type definitions
|
|
10
|
-
- Chat management - Create, manage, and interact with AI chats
|
|
11
|
-
- Project operations - Create and manage v0 projects
|
|
12
|
-
- Vercel integrations - Seamless Vercel project integration
|
|
13
|
-
- User management - Access user information and billing
|
|
14
|
-
- Deployment logs - Monitor and retrieve deployment information
|
|
15
|
-
- Comprehensive testing - Extensive test coverage for all functions
|
|
16
|
-
- Error handling - Robust error handling with detailed error types
|
|
17
|
-
|
|
18
7
|
## Installation
|
|
19
8
|
|
|
20
9
|
```bash
|
|
@@ -29,6 +18,8 @@ pnpm add v0-sdk
|
|
|
29
18
|
|
|
30
19
|
Get your API key from [v0.dev/chat/settings/keys](https://v0.dev/chat/settings/keys).
|
|
31
20
|
|
|
21
|
+
Set `V0_API_KEY` environment variable.
|
|
22
|
+
|
|
32
23
|
### Create Chat and Generate Code
|
|
33
24
|
|
|
34
25
|
```typescript
|
|
@@ -48,16 +39,50 @@ console.log(`Preview URL: ${chat.demo}`)
|
|
|
48
39
|
const previewHtml = `<iframe src="${chat.demo}" width="100%" height="600px"></iframe>`
|
|
49
40
|
```
|
|
50
41
|
|
|
51
|
-
##
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- Full TypeScript support with complete type definitions
|
|
45
|
+
- Chat management - Create, manage, and interact with AI chats
|
|
46
|
+
- Project operations - Create and manage v0 projects
|
|
47
|
+
- Vercel integrations - Seamless Vercel project integration
|
|
48
|
+
- User management - Access user information and billing
|
|
49
|
+
- Deployment logs - Monitor and retrieve deployment information
|
|
50
|
+
- Comprehensive testing - Extensive test coverage for all functions
|
|
51
|
+
- Error handling - Robust error handling with detailed error types
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
The SDK supports two ways to create a client:
|
|
56
|
+
|
|
57
|
+
### Default Client
|
|
58
|
+
|
|
59
|
+
Use the default client with environment variables:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { v0 } from 'v0-sdk'
|
|
63
|
+
|
|
64
|
+
// Uses V0_API_KEY environment variable
|
|
65
|
+
const chat = await v0.chats.create({
|
|
66
|
+
message: 'Create a responsive navbar with Tailwind CSS',
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Custom Client
|
|
52
71
|
|
|
53
|
-
|
|
72
|
+
Create a custom client with specific configuration:
|
|
54
73
|
|
|
55
74
|
```typescript
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
import { createClient } from 'v0-sdk'
|
|
76
|
+
|
|
77
|
+
// Create client with custom API key
|
|
78
|
+
const v0 = createClient({
|
|
79
|
+
apiKey: process.env.V0_API_KEY_FOR_MY_ORG,
|
|
80
|
+
})
|
|
58
81
|
|
|
59
|
-
//
|
|
60
|
-
|
|
82
|
+
// Use the custom client
|
|
83
|
+
const chat = await v0.chats.create({
|
|
84
|
+
message: 'Create a login form',
|
|
85
|
+
})
|
|
61
86
|
```
|
|
62
87
|
|
|
63
88
|
## API Reference
|
|
@@ -90,7 +115,7 @@ const chat = await v0.chats.getById({ chatId: 'chat_id' })
|
|
|
90
115
|
#### Add Messages to Chat
|
|
91
116
|
|
|
92
117
|
```typescript
|
|
93
|
-
const response = await v0.chats.
|
|
118
|
+
const response = await v0.chats.sendMessage({
|
|
94
119
|
chatId: 'chat_id',
|
|
95
120
|
message: 'Add password strength indicator',
|
|
96
121
|
})
|
|
@@ -163,7 +188,16 @@ import type {
|
|
|
163
188
|
ChatsCreateResponse,
|
|
164
189
|
User,
|
|
165
190
|
Project,
|
|
191
|
+
V0ClientConfig,
|
|
166
192
|
} from 'v0-sdk'
|
|
193
|
+
|
|
194
|
+
// Type-safe client configuration
|
|
195
|
+
const config: V0ClientConfig = {
|
|
196
|
+
apiKey: 'your_api_key',
|
|
197
|
+
baseUrl: 'https://api.v0.dev/v1', // optional
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const v0 = createClient(config)
|
|
167
201
|
```
|
|
168
202
|
|
|
169
203
|
## Error Handling
|