v0-sdk 0.0.6 → 0.0.7

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 CHANGED
@@ -122,7 +122,7 @@ const response = await v0.chats.createMessage({
122
122
  message: 'Add password strength indicator',
123
123
  attachments: [{ url: 'https://example.com/mockup.jpg' }],
124
124
  modelConfiguration: {
125
- imageGenerations: true
125
+ imageGenerations: true,
126
126
  },
127
127
  })
128
128
  ```
@@ -130,9 +130,9 @@ const response = await v0.chats.createMessage({
130
130
  #### Get Version Frame Token
131
131
 
132
132
  ```typescript
133
- const token = await v0.chats.getVersionFrameToken({
134
- chatId: 'chat_id',
135
- versionId: 'version_id'
133
+ const token = await v0.chats.getVersionFrameToken({
134
+ chatId: 'chat_id',
135
+ versionId: 'version_id',
136
136
  })
137
137
  ```
138
138
 
@@ -144,10 +144,8 @@ const token = await v0.chats.getVersionFrameToken({
144
144
  const project = await v0.projects.create({
145
145
  name: 'My New Project',
146
146
  description: 'A sample project',
147
- environmentVariables: [
148
- { key: 'API_KEY', value: 'secret_value' }
149
- ],
150
- icon: 'https://example.com/icon.png'
147
+ environmentVariables: [{ key: 'API_KEY', value: 'secret_value' }],
148
+ icon: 'https://example.com/icon.png',
151
149
  })
152
150
  ```
153
151
 
@@ -164,7 +162,7 @@ const projects = await v0.projects.find()
164
162
  ```typescript
165
163
  const integration = await v0.integrations.vercel.projects.create({
166
164
  projectId: 'vercel_project_id',
167
- name: 'project_name'
165
+ name: 'project_name',
168
166
  })
169
167
  ```
170
168
 
@@ -196,7 +194,7 @@ console.log(planResponse.plan, planResponse.balance)
196
194
 
197
195
  ```typescript
198
196
  const logs = await v0.deployments.findLogs({
199
- deploymentId: 'deployment_id'
197
+ deploymentId: 'deployment_id',
200
198
  })
201
199
  ```
202
200
 
@@ -230,16 +228,16 @@ const response = await v0.chats.create({
230
228
  // Base64 attachment
231
229
  const handleFileUpload = async (file: File) => {
232
230
  const reader = new FileReader()
233
-
231
+
234
232
  reader.onload = async () => {
235
233
  const response = await v0.chats.create({
236
234
  message: 'Create a component based on this image',
237
235
  attachments: [{ url: reader.result as string }],
238
236
  })
239
-
237
+
240
238
  console.log(response)
241
239
  }
242
-
240
+
243
241
  reader.readAsDataURL(file)
244
242
  }
245
243
  ```
@@ -249,12 +247,12 @@ const handleFileUpload = async (file: File) => {
249
247
  The SDK includes complete type definitions for all API operations:
250
248
 
251
249
  ```typescript
252
- import type {
250
+ import type {
253
251
  ChatsCreateRequest,
254
252
  ChatsCreateResponse,
255
253
  User,
256
254
  Project,
257
- ScopeSummary
255
+ ScopeSummary,
258
256
  } from 'v0-sdk'
259
257
 
260
258
  // All request and response types are fully typed
@@ -354,7 +352,7 @@ npm test
354
352
  ```typescript
355
353
  const client = new V0Client('your_api_key', 'https://custom-api.example.com', {
356
354
  timeout: 30000,
357
- retries: 3
355
+ retries: 3,
358
356
  })
359
357
  ```
360
358
 
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@ async function fetcher(url, method, params = {}) {
10
10
  }
11
11
  const hasBody = method !== 'GET' && params.body;
12
12
  const headers = {
13
- 'Authorization': `Bearer ${apiKey}`,
13
+ Authorization: `Bearer ${apiKey}`,
14
14
  ...params.headers
15
15
  };
16
16
  if (hasBody) {
@@ -37,15 +37,24 @@ const v0 = {
37
37
  system: params.system,
38
38
  chatPrivacy: params.chatPrivacy,
39
39
  projectId: params.projectId,
40
- modelConfiguration: params.modelConfiguration,
41
- chatId: params.chatId
40
+ modelConfiguration: params.modelConfiguration
42
41
  };
43
42
  return fetcher(`/chats`, 'POST', {
44
43
  body
45
44
  });
46
45
  },
47
- async find () {
48
- return fetcher(`/chats`, 'GET', {});
46
+ async find (params) {
47
+ const query = params ? Object.fromEntries(Object.entries({
48
+ limit: params.limit,
49
+ offset: params.offset,
50
+ isFavorite: params.isFavorite
51
+ }).filter(([_, value])=>value !== undefined)) : {};
52
+ const hasQuery = Object.keys(query).length > 0;
53
+ return fetcher(`/chats`, 'GET', {
54
+ ...hasQuery ? {
55
+ query
56
+ } : {}
57
+ });
49
58
  },
50
59
  async delete (params) {
51
60
  const pathParams = {
@@ -61,26 +70,38 @@ const v0 = {
61
70
  return fetcher(`/chats/${pathParams.chatId}`, 'GET', {
62
71
  });
63
72
  },
64
- async favorite (params) {
73
+ async update (params) {
65
74
  const pathParams = {
66
75
  chatId: params.chatId
67
76
  };
68
- return fetcher(`/chats/${pathParams.chatId}/favorite`, 'POST', {
69
- });
77
+ const body = {
78
+ privacy: params.privacy
79
+ };
80
+ return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
81
+ body
82
+ });
70
83
  },
71
- async unfavorite (params) {
84
+ async favorite (params) {
72
85
  const pathParams = {
73
86
  chatId: params.chatId
74
87
  };
75
- return fetcher(`/chats/${pathParams.chatId}/unfavorite`, 'POST', {
76
- });
88
+ const body = {
89
+ isFavorite: params.isFavorite
90
+ };
91
+ return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
92
+ body
93
+ });
77
94
  },
78
- async getProject (params) {
95
+ async fork (params) {
79
96
  const pathParams = {
80
97
  chatId: params.chatId
81
98
  };
82
- return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
83
- });
99
+ const body = {
100
+ versionId: params.versionId
101
+ };
102
+ return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
103
+ body
104
+ });
84
105
  },
85
106
  async createMessage (params) {
86
107
  const pathParams = {
@@ -95,6 +116,14 @@ const v0 = {
95
116
  body
96
117
  });
97
118
  },
119
+ async findIframe (params) {
120
+ const pathParams = {
121
+ chatId: params.chatId,
122
+ versionId: params.versionId
123
+ };
124
+ return fetcher(`/chats/${pathParams.chatId}/versions/${pathParams.versionId}/iframe`, 'GET', {
125
+ });
126
+ },
98
127
  async getVersionFrameToken (params) {
99
128
  const pathParams = {
100
129
  chatId: params.chatId,
@@ -110,17 +139,6 @@ const v0 = {
110
139
  return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
111
140
  });
112
141
  },
113
- async setPrivacy (params) {
114
- const pathParams = {
115
- chatId: params.chatId
116
- };
117
- const body = {
118
- privacy: params.privacy
119
- };
120
- return fetcher(`/chats/${pathParams.chatId}/privacy`, 'POST', {
121
- body
122
- });
123
- },
124
142
  async upload (params) {
125
143
  const pathParams = {
126
144
  chatId: params.chatId
@@ -141,41 +159,14 @@ const v0 = {
141
159
  });
142
160
  }
143
161
  },
144
- deployments: {
145
- async findLogs (params) {
162
+ projects: {
163
+ async getByChatId (params) {
146
164
  const pathParams = {
147
- deploymentId: params.deploymentId
165
+ chatId: params.chatId
148
166
  };
149
- return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
167
+ return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
150
168
  });
151
169
  },
152
- async findErrors (params) {
153
- const pathParams = {
154
- deploymentId: params.deploymentId
155
- };
156
- return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
157
- });
158
- }
159
- },
160
- integrations: {
161
- vercel: {
162
- projects: {
163
- async find () {
164
- return fetcher(`/integrations/vercel/projects`, 'GET', {});
165
- },
166
- async create (params) {
167
- const body = {
168
- projectId: params.projectId,
169
- name: params.name
170
- };
171
- return fetcher(`/integrations/vercel/projects`, 'POST', {
172
- body
173
- });
174
- }
175
- }
176
- }
177
- },
178
- projects: {
179
170
  async find () {
180
171
  return fetcher(`/projects`, 'GET', {});
181
172
  },
@@ -203,22 +194,80 @@ const v0 = {
203
194
  });
204
195
  }
205
196
  },
206
- scopes: {
207
- async find () {
208
- return fetcher(`/scopes`, 'GET', {});
197
+ deployments: {
198
+ async findLogs (params) {
199
+ const pathParams = {
200
+ deploymentId: params.deploymentId
201
+ };
202
+ const query = Object.fromEntries(Object.entries({
203
+ since: params.since
204
+ }).filter(([_, value])=>value !== undefined));
205
+ const hasQuery = Object.keys(query).length > 0;
206
+ return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
207
+ ...hasQuery ? {
208
+ query
209
+ } : {}
210
+ });
211
+ },
212
+ async findErrors (params) {
213
+ const pathParams = {
214
+ deploymentId: params.deploymentId
215
+ };
216
+ return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
217
+ });
218
+ }
219
+ },
220
+ integrations: {
221
+ vercel: {
222
+ projects: {
223
+ async find () {
224
+ return fetcher(`/integrations/vercel/projects`, 'GET', {});
225
+ },
226
+ async create (params) {
227
+ const body = {
228
+ projectId: params.projectId,
229
+ name: params.name
230
+ };
231
+ return fetcher(`/integrations/vercel/projects`, 'POST', {
232
+ body
233
+ });
234
+ }
235
+ }
209
236
  }
210
237
  },
211
238
  rateLimits: {
212
- async find () {
213
- return fetcher(`/rate-limits`, 'GET', {});
239
+ async find (params) {
240
+ const query = params ? Object.fromEntries(Object.entries({
241
+ scope: params.scope
242
+ }).filter(([_, value])=>value !== undefined)) : {};
243
+ const hasQuery = Object.keys(query).length > 0;
244
+ return fetcher(`/rate-limits`, 'GET', {
245
+ ...hasQuery ? {
246
+ query
247
+ } : {}
248
+ });
214
249
  }
215
250
  },
216
251
  user: {
217
252
  async get () {
218
253
  return fetcher(`/user`, 'GET', {});
219
254
  },
255
+ async getBilling (params) {
256
+ const query = params ? Object.fromEntries(Object.entries({
257
+ scope: params.scope
258
+ }).filter(([_, value])=>value !== undefined)) : {};
259
+ const hasQuery = Object.keys(query).length > 0;
260
+ return fetcher(`/user/billing`, 'GET', {
261
+ ...hasQuery ? {
262
+ query
263
+ } : {}
264
+ });
265
+ },
220
266
  async getPlan () {
221
267
  return fetcher(`/user/plan`, 'GET', {});
268
+ },
269
+ async getScopes () {
270
+ return fetcher(`/user/scopes`, 'GET', {});
222
271
  }
223
272
  }
224
273
  };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,73 @@
1
+ type ChatDetail = {
2
+ id: string;
3
+ object: 'chat';
4
+ url: string;
5
+ shareable: boolean;
6
+ privacy?: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted';
7
+ title?: string;
8
+ updatedAt?: string;
9
+ favorite: boolean;
10
+ authorId: string;
11
+ latestBlockId?: string;
12
+ messages: {
13
+ id: string;
14
+ object: 'message';
15
+ content: string;
16
+ createdAt: string;
17
+ type: 'message' | 'refinement' | 'forked-block' | 'forked-chat' | 'open-in-v0' | 'added-environment-variables' | 'added-integration' | 'deleted-file' | 'moved-file' | 'renamed-file' | 'edited-file' | 'replace-src' | 'reverted-block' | 'fix-with-v0' | 'sync-git';
18
+ }[];
19
+ };
20
+ interface ChatSummary {
21
+ id: string;
22
+ object: 'chat';
23
+ shareable: boolean;
24
+ privacy: string;
25
+ title?: string;
26
+ updatedAt: string;
27
+ favorite: boolean;
28
+ authorId: string;
29
+ latestVersionId?: string;
30
+ }
31
+ type MessageDetail = {
32
+ id: string;
33
+ object: 'message';
34
+ chatId: string;
35
+ url: string;
36
+ files?: {
37
+ lang: string;
38
+ meta: Record<string, any>;
39
+ source: string;
40
+ }[];
41
+ demo?: string;
42
+ text: string;
43
+ modelConfiguration: {
44
+ modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg';
45
+ imageGenerations?: boolean;
46
+ thinking?: boolean;
47
+ };
48
+ };
49
+ interface ProjectDetail {
50
+ id: string;
51
+ object: 'project';
52
+ name: string;
53
+ vercelProjectId?: string;
54
+ }
1
55
  interface ScopeSummary {
2
56
  id: string;
57
+ object: 'scope';
3
58
  name?: string;
4
59
  }
5
- interface User {
60
+ interface UserDetail {
6
61
  id: string;
62
+ object: 'user';
7
63
  name?: string;
8
64
  email: string;
9
65
  avatar: string;
10
- createdAt: string;
66
+ }
67
+ interface VercelProjectDetail {
68
+ id: string;
69
+ object: 'vercel_project';
70
+ name: string;
11
71
  }
12
72
  interface ChatsCreateRequest {
13
73
  message: string;
@@ -22,10 +82,10 @@ interface ChatsCreateRequest {
22
82
  imageGenerations?: boolean;
23
83
  thinking?: boolean;
24
84
  };
25
- chatId?: string;
26
85
  }
27
86
  type ChatsCreateResponse = {
28
- chatId: string;
87
+ id: string;
88
+ object: 'chat';
29
89
  url: string;
30
90
  files?: {
31
91
  lang: string;
@@ -39,62 +99,34 @@ type ChatsCreateResponse = {
39
99
  imageGenerations?: boolean;
40
100
  thinking?: boolean;
41
101
  };
42
- _deprecation?: {
43
- message: string;
44
- migration: string;
45
- sunset: string;
46
- };
47
102
  };
48
103
  interface ChatsFindResponse {
49
- favorites: {
50
- chatId: string;
51
- shareable: boolean;
52
- privacy: string;
53
- title: string;
54
- updatedAt: string;
55
- favorite: boolean;
56
- authorId: string;
57
- }[];
58
- history: {
59
- chatId: string;
60
- shareable: boolean;
61
- privacy: string;
62
- title: string;
63
- updatedAt: string;
64
- }[];
104
+ object: 'list';
105
+ data: ChatSummary[];
65
106
  }
66
107
  interface ChatsDeleteResponse {
67
- success: boolean;
108
+ id: string;
109
+ object: 'chat';
110
+ deleted: true;
68
111
  }
69
- type ChatsGetByIdResponse = {
70
- chatId: string;
71
- url: string;
72
- messages: {
73
- messageId: string;
74
- content: string;
75
- createdAt: string;
76
- type: 'message' | 'refinement' | 'forked-block' | 'forked-chat' | 'open-in-v0' | 'added-environment-variables' | 'added-integration' | 'deleted-file' | 'moved-file' | 'renamed-file' | 'edited-file' | 'replace-src' | 'reverted-block' | 'fix-with-v0' | 'sync-git';
77
- }[];
78
- };
79
- type ChatsFavoriteResponse = {
80
- success: boolean;
81
- } | {
82
- error: string;
83
- success?: any;
84
- };
85
- type ChatsUnfavoriteResponse = {
86
- success: boolean;
87
- } | {
88
- error: string;
89
- success?: any;
90
- };
91
- interface ChatsGetProjectResponse {
92
- project: {
93
- id: string;
94
- name: string;
95
- url: string;
96
- };
112
+ type ChatsGetByIdResponse = ChatDetail;
113
+ interface ChatsUpdateRequest {
114
+ privacy?: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted';
97
115
  }
116
+ type ChatsUpdateResponse = ChatDetail;
117
+ interface ChatsFavoriteRequest {
118
+ isFavorite: boolean;
119
+ }
120
+ interface ChatsFavoriteResponse {
121
+ id: string;
122
+ object: 'chat';
123
+ favorited: boolean;
124
+ }
125
+ interface ChatsForkRequest {
126
+ versionId: string;
127
+ }
128
+ type ChatsForkResponse = ChatDetail;
129
+ type ProjectsGetByChatIdResponse = ProjectDetail;
98
130
  interface ChatsCreateMessageRequest {
99
131
  message: string;
100
132
  attachments?: {
@@ -106,22 +138,12 @@ interface ChatsCreateMessageRequest {
106
138
  thinking?: boolean;
107
139
  };
108
140
  }
109
- type ChatsCreateMessageResponse = {
110
- chatId: string;
141
+ type ChatsCreateMessageResponse = MessageDetail;
142
+ interface ChatsFindIframeResponse {
143
+ id: string;
144
+ object: 'iframe';
111
145
  url: string;
112
- files?: {
113
- lang: string;
114
- meta: Record<string, any>;
115
- source: string;
116
- }[];
117
- demo?: string;
118
- text: string;
119
- modelConfiguration: {
120
- modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg';
121
- imageGenerations?: boolean;
122
- thinking?: boolean;
123
- };
124
- };
146
+ }
125
147
  interface ChatsGetVersionFrameTokenResponse {
126
148
  token: string;
127
149
  }
@@ -139,28 +161,13 @@ interface ChatsGetMetadataResponse {
139
161
  url: string;
140
162
  };
141
163
  }
142
- interface ChatsSetPrivacyRequest {
143
- privacy: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted';
144
- }
145
- type ChatsSetPrivacyResponse = {
146
- success: 'true';
147
- } | {
148
- error: string;
149
- };
150
164
  interface ChatsUploadRequest {
151
165
  file: any;
152
166
  }
153
167
  interface ChatsUploadResponse {
154
168
  url: string;
155
169
  }
156
- interface ChatsResumeResponse {
157
- message: {
158
- id: string;
159
- content: string;
160
- createdAt: string;
161
- finishReason?: string;
162
- };
163
- }
170
+ type ChatsResumeResponse = MessageDetail;
164
171
  interface DeploymentsFindLogsResponse {
165
172
  error?: string;
166
173
  logs: string[];
@@ -173,24 +180,17 @@ interface DeploymentsFindErrorsResponse {
173
180
  formattedError?: string;
174
181
  }
175
182
  interface IntegrationsVercelProjectsFindResponse {
176
- projects: {
177
- id: string;
178
- name: string;
179
- url: string;
180
- }[];
183
+ object: 'list';
184
+ data: VercelProjectDetail[];
181
185
  }
182
186
  interface IntegrationsVercelProjectsCreateRequest {
183
187
  projectId: string;
184
188
  name: string;
185
189
  }
186
- interface IntegrationsVercelProjectsCreateResponse {
187
- success: boolean;
188
- }
190
+ type IntegrationsVercelProjectsCreateResponse = VercelProjectDetail;
189
191
  interface ProjectsFindResponse {
190
- id: string;
191
- name: string;
192
- url: string;
193
- env: string[];
192
+ object: 'list';
193
+ data: ProjectDetail[];
194
194
  }
195
195
  interface ProjectsCreateRequest {
196
196
  name: string;
@@ -202,29 +202,55 @@ interface ProjectsCreateRequest {
202
202
  }[];
203
203
  instructions?: string;
204
204
  }
205
- interface ProjectsCreateResponse {
206
- id: string;
207
- name: string;
208
- vercelProjectId?: string;
209
- }
205
+ type ProjectsCreateResponse = ProjectDetail;
210
206
  interface ProjectsAssignRequest {
211
207
  chatId: string;
212
208
  }
213
209
  interface ProjectsAssignResponse {
214
- success: boolean;
215
- }
216
- interface ScopesFindResponse {
217
- scopes: ScopeSummary[];
210
+ object: 'project';
211
+ id: string;
212
+ assigned: true;
218
213
  }
219
214
  interface RateLimitsFindResponse {
220
215
  remaining?: number;
221
216
  reset?: number;
222
217
  limit: number;
223
218
  }
224
- interface UserGetResponse {
225
- user: User;
226
- }
219
+ type UserGetResponse = UserDetail;
220
+ type UserGetBillingResponse = {
221
+ billingType: 'token';
222
+ data: {
223
+ plan: string;
224
+ billingMode?: 'test';
225
+ role: string;
226
+ billingCycle: {
227
+ start: number;
228
+ end: number;
229
+ };
230
+ balance: {
231
+ remaining: number;
232
+ total: number;
233
+ };
234
+ onDemand: {
235
+ balance: number;
236
+ blocks?: {
237
+ expirationDate?: number;
238
+ effectiveDate: number;
239
+ originalBalance: number;
240
+ currentBalance: number;
241
+ }[];
242
+ };
243
+ };
244
+ } | {
245
+ billingType: 'legacy';
246
+ data: {
247
+ remaining?: number;
248
+ reset?: number;
249
+ limit: number;
250
+ };
251
+ };
227
252
  interface UserGetPlanResponse {
253
+ object: 'plan';
228
254
  plan: string;
229
255
  billingCycle: {
230
256
  start: number;
@@ -235,28 +261,40 @@ interface UserGetPlanResponse {
235
261
  total: number;
236
262
  };
237
263
  }
264
+ interface UserGetScopesResponse {
265
+ object: 'list';
266
+ data: ScopeSummary[];
267
+ }
238
268
  declare const v0: {
239
269
  chats: {
240
270
  create(params: ChatsCreateRequest): Promise<ChatsCreateResponse>;
241
- find(): Promise<ChatsFindResponse>;
271
+ find(params?: {
272
+ limit?: string;
273
+ offset?: string;
274
+ isFavorite?: string;
275
+ }): Promise<ChatsFindResponse>;
242
276
  delete(params: {
243
277
  chatId: string;
244
278
  }): Promise<ChatsDeleteResponse>;
245
279
  getById(params: {
246
280
  chatId: string;
247
281
  }): Promise<ChatsGetByIdResponse>;
248
- favorite(params: {
282
+ update(params: {
249
283
  chatId: string;
250
- }): Promise<ChatsFavoriteResponse>;
251
- unfavorite(params: {
284
+ } & ChatsUpdateRequest): Promise<ChatsUpdateResponse>;
285
+ favorite(params: {
252
286
  chatId: string;
253
- }): Promise<ChatsUnfavoriteResponse>;
254
- getProject(params: {
287
+ } & ChatsFavoriteRequest): Promise<ChatsFavoriteResponse>;
288
+ fork(params: {
255
289
  chatId: string;
256
- }): Promise<ChatsGetProjectResponse>;
290
+ } & ChatsForkRequest): Promise<ChatsForkResponse>;
257
291
  createMessage(params: {
258
292
  chatId: string;
259
293
  } & ChatsCreateMessageRequest): Promise<ChatsCreateMessageResponse>;
294
+ findIframe(params: {
295
+ chatId: string;
296
+ versionId: string;
297
+ }): Promise<ChatsFindIframeResponse>;
260
298
  getVersionFrameToken(params: {
261
299
  chatId: string;
262
300
  versionId: string;
@@ -264,9 +302,6 @@ declare const v0: {
264
302
  getMetadata(params: {
265
303
  chatId: string;
266
304
  }): Promise<ChatsGetMetadataResponse>;
267
- setPrivacy(params: {
268
- chatId: string;
269
- } & ChatsSetPrivacyRequest): Promise<ChatsSetPrivacyResponse>;
270
305
  upload(params: {
271
306
  chatId: string;
272
307
  } & ChatsUploadRequest): Promise<ChatsUploadResponse>;
@@ -275,9 +310,20 @@ declare const v0: {
275
310
  messageId: string;
276
311
  }): Promise<ChatsResumeResponse>;
277
312
  };
313
+ projects: {
314
+ getByChatId(params: {
315
+ chatId: string;
316
+ }): Promise<ProjectsGetByChatIdResponse>;
317
+ find(): Promise<ProjectsFindResponse>;
318
+ create(params: ProjectsCreateRequest): Promise<ProjectsCreateResponse>;
319
+ assign(params: {
320
+ projectId: string;
321
+ } & ProjectsAssignRequest): Promise<ProjectsAssignResponse>;
322
+ };
278
323
  deployments: {
279
324
  findLogs(params: {
280
325
  deploymentId: string;
326
+ since?: string;
281
327
  }): Promise<DeploymentsFindLogsResponse>;
282
328
  findErrors(params: {
283
329
  deploymentId: string;
@@ -291,22 +337,18 @@ declare const v0: {
291
337
  };
292
338
  };
293
339
  };
294
- projects: {
295
- find(): Promise<ProjectsFindResponse>;
296
- create(params: ProjectsCreateRequest): Promise<ProjectsCreateResponse>;
297
- assign(params: {
298
- projectId: string;
299
- } & ProjectsAssignRequest): Promise<ProjectsAssignResponse>;
300
- };
301
- scopes: {
302
- find(): Promise<ScopesFindResponse>;
303
- };
304
340
  rateLimits: {
305
- find(): Promise<RateLimitsFindResponse>;
341
+ find(params?: {
342
+ scope?: string;
343
+ }): Promise<RateLimitsFindResponse>;
306
344
  };
307
345
  user: {
308
346
  get(): Promise<UserGetResponse>;
347
+ getBilling(params?: {
348
+ scope?: string;
349
+ }): Promise<UserGetBillingResponse>;
309
350
  getPlan(): Promise<UserGetPlanResponse>;
351
+ getScopes(): Promise<UserGetScopesResponse>;
310
352
  };
311
353
  };
312
354
 
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ async function fetcher(url, method, params = {}) {
8
8
  }
9
9
  const hasBody = method !== 'GET' && params.body;
10
10
  const headers = {
11
- 'Authorization': `Bearer ${apiKey}`,
11
+ Authorization: `Bearer ${apiKey}`,
12
12
  ...params.headers
13
13
  };
14
14
  if (hasBody) {
@@ -35,15 +35,24 @@ const v0 = {
35
35
  system: params.system,
36
36
  chatPrivacy: params.chatPrivacy,
37
37
  projectId: params.projectId,
38
- modelConfiguration: params.modelConfiguration,
39
- chatId: params.chatId
38
+ modelConfiguration: params.modelConfiguration
40
39
  };
41
40
  return fetcher(`/chats`, 'POST', {
42
41
  body
43
42
  });
44
43
  },
45
- async find () {
46
- return fetcher(`/chats`, 'GET', {});
44
+ async find (params) {
45
+ const query = params ? Object.fromEntries(Object.entries({
46
+ limit: params.limit,
47
+ offset: params.offset,
48
+ isFavorite: params.isFavorite
49
+ }).filter(([_, value])=>value !== undefined)) : {};
50
+ const hasQuery = Object.keys(query).length > 0;
51
+ return fetcher(`/chats`, 'GET', {
52
+ ...hasQuery ? {
53
+ query
54
+ } : {}
55
+ });
47
56
  },
48
57
  async delete (params) {
49
58
  const pathParams = {
@@ -59,26 +68,38 @@ const v0 = {
59
68
  return fetcher(`/chats/${pathParams.chatId}`, 'GET', {
60
69
  });
61
70
  },
62
- async favorite (params) {
71
+ async update (params) {
63
72
  const pathParams = {
64
73
  chatId: params.chatId
65
74
  };
66
- return fetcher(`/chats/${pathParams.chatId}/favorite`, 'POST', {
67
- });
75
+ const body = {
76
+ privacy: params.privacy
77
+ };
78
+ return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
79
+ body
80
+ });
68
81
  },
69
- async unfavorite (params) {
82
+ async favorite (params) {
70
83
  const pathParams = {
71
84
  chatId: params.chatId
72
85
  };
73
- return fetcher(`/chats/${pathParams.chatId}/unfavorite`, 'POST', {
74
- });
86
+ const body = {
87
+ isFavorite: params.isFavorite
88
+ };
89
+ return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
90
+ body
91
+ });
75
92
  },
76
- async getProject (params) {
93
+ async fork (params) {
77
94
  const pathParams = {
78
95
  chatId: params.chatId
79
96
  };
80
- return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
81
- });
97
+ const body = {
98
+ versionId: params.versionId
99
+ };
100
+ return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
101
+ body
102
+ });
82
103
  },
83
104
  async createMessage (params) {
84
105
  const pathParams = {
@@ -93,6 +114,14 @@ const v0 = {
93
114
  body
94
115
  });
95
116
  },
117
+ async findIframe (params) {
118
+ const pathParams = {
119
+ chatId: params.chatId,
120
+ versionId: params.versionId
121
+ };
122
+ return fetcher(`/chats/${pathParams.chatId}/versions/${pathParams.versionId}/iframe`, 'GET', {
123
+ });
124
+ },
96
125
  async getVersionFrameToken (params) {
97
126
  const pathParams = {
98
127
  chatId: params.chatId,
@@ -108,17 +137,6 @@ const v0 = {
108
137
  return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
109
138
  });
110
139
  },
111
- async setPrivacy (params) {
112
- const pathParams = {
113
- chatId: params.chatId
114
- };
115
- const body = {
116
- privacy: params.privacy
117
- };
118
- return fetcher(`/chats/${pathParams.chatId}/privacy`, 'POST', {
119
- body
120
- });
121
- },
122
140
  async upload (params) {
123
141
  const pathParams = {
124
142
  chatId: params.chatId
@@ -139,41 +157,14 @@ const v0 = {
139
157
  });
140
158
  }
141
159
  },
142
- deployments: {
143
- async findLogs (params) {
160
+ projects: {
161
+ async getByChatId (params) {
144
162
  const pathParams = {
145
- deploymentId: params.deploymentId
163
+ chatId: params.chatId
146
164
  };
147
- return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
165
+ return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
148
166
  });
149
167
  },
150
- async findErrors (params) {
151
- const pathParams = {
152
- deploymentId: params.deploymentId
153
- };
154
- return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
155
- });
156
- }
157
- },
158
- integrations: {
159
- vercel: {
160
- projects: {
161
- async find () {
162
- return fetcher(`/integrations/vercel/projects`, 'GET', {});
163
- },
164
- async create (params) {
165
- const body = {
166
- projectId: params.projectId,
167
- name: params.name
168
- };
169
- return fetcher(`/integrations/vercel/projects`, 'POST', {
170
- body
171
- });
172
- }
173
- }
174
- }
175
- },
176
- projects: {
177
168
  async find () {
178
169
  return fetcher(`/projects`, 'GET', {});
179
170
  },
@@ -201,22 +192,80 @@ const v0 = {
201
192
  });
202
193
  }
203
194
  },
204
- scopes: {
205
- async find () {
206
- return fetcher(`/scopes`, 'GET', {});
195
+ deployments: {
196
+ async findLogs (params) {
197
+ const pathParams = {
198
+ deploymentId: params.deploymentId
199
+ };
200
+ const query = Object.fromEntries(Object.entries({
201
+ since: params.since
202
+ }).filter(([_, value])=>value !== undefined));
203
+ const hasQuery = Object.keys(query).length > 0;
204
+ return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
205
+ ...hasQuery ? {
206
+ query
207
+ } : {}
208
+ });
209
+ },
210
+ async findErrors (params) {
211
+ const pathParams = {
212
+ deploymentId: params.deploymentId
213
+ };
214
+ return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
215
+ });
216
+ }
217
+ },
218
+ integrations: {
219
+ vercel: {
220
+ projects: {
221
+ async find () {
222
+ return fetcher(`/integrations/vercel/projects`, 'GET', {});
223
+ },
224
+ async create (params) {
225
+ const body = {
226
+ projectId: params.projectId,
227
+ name: params.name
228
+ };
229
+ return fetcher(`/integrations/vercel/projects`, 'POST', {
230
+ body
231
+ });
232
+ }
233
+ }
207
234
  }
208
235
  },
209
236
  rateLimits: {
210
- async find () {
211
- return fetcher(`/rate-limits`, 'GET', {});
237
+ async find (params) {
238
+ const query = params ? Object.fromEntries(Object.entries({
239
+ scope: params.scope
240
+ }).filter(([_, value])=>value !== undefined)) : {};
241
+ const hasQuery = Object.keys(query).length > 0;
242
+ return fetcher(`/rate-limits`, 'GET', {
243
+ ...hasQuery ? {
244
+ query
245
+ } : {}
246
+ });
212
247
  }
213
248
  },
214
249
  user: {
215
250
  async get () {
216
251
  return fetcher(`/user`, 'GET', {});
217
252
  },
253
+ async getBilling (params) {
254
+ const query = params ? Object.fromEntries(Object.entries({
255
+ scope: params.scope
256
+ }).filter(([_, value])=>value !== undefined)) : {};
257
+ const hasQuery = Object.keys(query).length > 0;
258
+ return fetcher(`/user/billing`, 'GET', {
259
+ ...hasQuery ? {
260
+ query
261
+ } : {}
262
+ });
263
+ },
218
264
  async getPlan () {
219
265
  return fetcher(`/user/plan`, 'GET', {});
266
+ },
267
+ async getScopes () {
268
+ return fetcher(`/user/scopes`, 'GET', {});
220
269
  }
221
270
  }
222
271
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v0-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "TypeScript SDK for the v0 Chats API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,8 @@
19
19
  "type-check": "tsc --noEmit",
20
20
  "type-check:go": "tsgo --noEmit",
21
21
  "build": "bunchee",
22
- "generate": "tsx src/scripts/generate.ts",
22
+ "generate": "tsx src/scripts/generate.ts && pnpm format",
23
+ "format": "prettier --write \"**/*.{ts,tsx,md}\"",
23
24
  "test": "vitest"
24
25
  },
25
26
  "keywords": [
@@ -35,6 +36,7 @@
35
36
  "@types/node": "22.5.5",
36
37
  "@typescript/native-preview": "7.0.0-dev.20250613.1",
37
38
  "bunchee": "^6.5.2",
39
+ "prettier": "^3.3.3",
38
40
  "tsx": "^4.19.2",
39
41
  "typescript": "5.7.3"
40
42
  }