v0-sdk 0.0.2 → 0.0.3

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 (3) hide show
  1. package/README.md +5 -11
  2. package/package.json +1 -1
  3. package/dist/index.js +0 -105
package/README.md CHANGED
@@ -17,10 +17,10 @@ pnpm add v0-sdk
17
17
  Get your API key from [v0.dev/chat/settings/keys](https://v0.dev/chat/settings/keys) and start creating chats.
18
18
 
19
19
  ```javascript
20
- import { ChatsClient } from 'v0-sdk'
20
+ import { V0Client } from 'v0-sdk'
21
21
 
22
22
  // Initialize with your API key
23
- const client = new ChatsClient('your_v0_api_key')
23
+ const client = new V0Client('your_v0_api_key')
24
24
 
25
25
  // Create a new chat
26
26
  const chat = await client.createChat({
@@ -45,7 +45,7 @@ The client requires a v0 API key, which you can create at [v0.dev/chat/settings/
45
45
 
46
46
  ```javascript
47
47
  // Initialize with API key
48
- const client = new ChatsClient('your_v0_api_key')
48
+ const client = new V0Client('your_v0_api_key')
49
49
 
50
50
  // Or set it later
51
51
  client.setApiKey('your_v0_api_key')
@@ -65,7 +65,6 @@ const result = await client.createChat({
65
65
  attachments: [{ url: 'https://example.com/design.png' }],
66
66
  modelConfiguration: {
67
67
  modelId: 'v0-1.5-md',
68
- thinking: true,
69
68
  imageGenerations: false,
70
69
  },
71
70
  })
@@ -97,9 +96,7 @@ Add a message to an existing chat.
97
96
  const response = await client.addMessage('abc123', {
98
97
  message: 'Add password strength indicator',
99
98
  attachments: [{ url: 'https://example.com/mockup.jpg' }],
100
- modelConfiguration: {
101
- thinking: true,
102
- },
99
+ modelConfiguration: {},
103
100
  })
104
101
  ```
105
102
 
@@ -151,9 +148,6 @@ const response = await client.createChat({
151
148
 
152
149
  // Enable AI-generated images in the response
153
150
  imageGenerations: true,
154
-
155
- // Show the AI's reasoning process
156
- thinking: true,
157
151
  },
158
152
  })
159
153
  ```
@@ -217,7 +211,7 @@ The API has rate limits of 100 requests per minute and 1,000 requests per hour.
217
211
  Enable debug mode to see detailed request and response information:
218
212
 
219
213
  ```javascript
220
- const client = new ChatsClient('your_api_key', undefined, { debug: true })
214
+ const client = new V0Client('your_api_key', undefined, { debug: true })
221
215
  ```
222
216
 
223
217
  ## Resources
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v0-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "TypeScript SDK for the v0 Chats API",
5
5
  "main": "dist/index.js",
6
6
  "files": [
package/dist/index.js DELETED
@@ -1,105 +0,0 @@
1
- /**
2
- * v0 Chats API SDK
3
- * A client library for interacting with the v0 Chats API
4
- */ class V0ChatsError extends Error {
5
- constructor(message, status, data){
6
- super(message);
7
- this.name = 'V0ChatsError';
8
- this.status = status;
9
- this.data = data;
10
- }
11
- }
12
- /**
13
- * Client for the v0 Chats API
14
- */ class V0Client {
15
- /**
16
- * Create a new v0 Chats API client
17
- *
18
- * @param options Client configuration options
19
- */ constructor(options){
20
- this.apiKey = options.apiKey;
21
- this.baseUrl = options.baseUrl || 'https://api.v0.dev/api';
22
- this.fetchFn = options.fetch || fetch;
23
- }
24
- /**
25
- * Create a new chat
26
- *
27
- * @param options Options for creating a new chat
28
- * @returns Promise with the created chat details
29
- */ async createChat(options) {
30
- const response = await this.request('POST', '/chats', options);
31
- return response;
32
- }
33
- /**
34
- * Add a message to an existing chat
35
- *
36
- * @param chatId The ID of the chat to add a message to
37
- * @param options Options for adding a message
38
- * @returns Promise with the updated chat details
39
- */ async addMessage(chatId, options) {
40
- const response = await this.request('POST', `/chats/${chatId}`, options);
41
- return response;
42
- }
43
- /**
44
- * Get chat details and message history
45
- *
46
- * @param chatId The ID of the chat to retrieve
47
- * @returns Promise with the chat details and messages
48
- */ async getChat(chatId) {
49
- const response = await this.request('GET', `/chats/${chatId}`);
50
- return response;
51
- }
52
- /**
53
- * Continue an existing chat (deprecated)
54
- *
55
- * This method is deprecated. Use addMessage() instead.
56
- *
57
- * @deprecated Use addMessage() instead
58
- * @param chatId The ID of the chat to continue
59
- * @param options Options for continuing the chat
60
- * @returns Promise with the updated chat details
61
- */ async continueChat(chatId, options) {
62
- console.warn('continueChat() is deprecated. Use addMessage() instead.');
63
- const payload = {
64
- ...options,
65
- chatId
66
- };
67
- const response = await this.request('POST', '/chats', payload);
68
- return response;
69
- }
70
- /**
71
- * Make a request to the v0 Chats API
72
- *
73
- * @param method HTTP method
74
- * @param path API path
75
- * @param data Request data
76
- * @returns Promise with the response data
77
- */ async request(method, path, data) {
78
- const url = `${this.baseUrl}${path}`;
79
- const headers = {
80
- Authorization: `Bearer ${this.apiKey}`,
81
- 'Content-Type': 'application/json'
82
- };
83
- const options = {
84
- method,
85
- headers,
86
- body: data && method !== 'GET' ? JSON.stringify(data) : undefined
87
- };
88
- try {
89
- const response = await this.fetchFn(url, options);
90
- const responseData = await response.json();
91
- if (!response.ok) {
92
- throw new V0ChatsError(responseData.error || `API request failed with status ${response.status}`, response.status, responseData);
93
- }
94
- return responseData;
95
- } catch (error) {
96
- if (error instanceof V0ChatsError) {
97
- throw error;
98
- }
99
- throw new V0ChatsError(error instanceof Error ? error.message : 'Unknown error occurred', 500);
100
- }
101
- }
102
- }
103
-
104
- exports.V0ChatsError = V0ChatsError;
105
- exports.V0Client = V0Client;