⚠️ Developer Preview: This SDK is currently in beta and is subject to change. Use in production at your own risk.
A TypeScript SDK for interacting with the v0 Platform API to create and manage AI-powered chat conversations, projects, integrations, and more.
npm install v0-sdk # or yarn add v0-sdk # or pnpm add v0-sdk
Get your API key from v0.dev/chat/settings/keys.
Set V0_API_KEY
environment variable.
import { v0 } from 'v0-sdk' // Create a new chat const chat = await v0.chats.create({ message: 'Create a responsive navbar with Tailwind CSS', system: 'You are an expert React developer', }) console.log(`Chat created: ${chat.url}`) // Preview generated code console.log(`Preview URL: ${chat.demo}`) // Use in your application const previewHtml = `<iframe src="${chat.demo}" width="100%" height="600px"></iframe>`
The SDK supports two ways to create a client:
Use the default client with environment variables:
import { v0 } from 'v0-sdk' // Uses V0_API_KEY environment variable const chat = await v0.chats.create({ message: 'Create a responsive navbar with Tailwind CSS', })
Create a custom client with specific configuration:
import { createClient } from 'v0-sdk' // Create client with custom API key const v0 = createClient({ apiKey: process.env.V0_API_KEY_FOR_MY_ORG, }) // Use the custom client const chat = await v0.chats.create({ message: 'Create a login form', })
Create a new chat conversation with the AI.
const result = await v0.chats.create({ message: 'Create a login form with validation', system: 'You are an expert in React and form validation', chatPrivacy: 'private', attachments: [{ url: 'https://example.com/design.png' }], modelConfiguration: { modelId: 'v0-1.5-md', imageGenerations: false, }, })
const chat = await v0.chats.getById({ chatId: 'chat_id' })
const response = await v0.chats.sendMessage({ chatId: 'chat_id', message: 'Add password strength indicator', })
v0.chats.find()
- Get chat historyv0.chats.delete({ chatId })
- Delete a chatv0.chats.favorite({ chatId })
- Favorite a chatv0.chats.unfavorite({ chatId })
- Unfavorite a chatv0.chats.getProject({ chatId })
- Get chat's associated project// Create a project const project = await v0.projects.create({ name: 'My New Project', description: 'A sample project', }) // Find projects const projects = await v0.projects.find()
// Create Vercel integration project const integration = await v0.integrations.vercel.projects.create({ projectId: 'vercel_project_id', name: 'project_name', }) // Find Vercel projects const projects = await v0.integrations.vercel.projects.find()
// Get user information const userResponse = await v0.user.get() // Get user plan and billing const planResponse = await v0.user.getPlan() // Get user scopes const scopesResponse = await v0.user.getScopes()
// Find deployment logs const logs = await v0.deployments.findLogs({ deploymentId: 'deployment_id' }) // Check rate limits const rateLimits = await v0.rateLimits.find()
The SDK includes complete type definitions for all API operations:
import type { ChatsCreateRequest, ChatsCreateResponse, User, Project, V0ClientConfig, } from 'v0-sdk' // Type-safe client configuration const config: V0ClientConfig = { apiKey: 'your_api_key', baseUrl: 'https://api.v0.dev/v1', // optional } const v0 = createClient(config)
The SDK provides detailed error information:
try { const chat = await v0.chats.create({ message: 'Create a component', }) } catch (error) { if (error.status === 403) { console.error('Authentication error:', error.message) } else if (error.status === 429) { console.error('Rate limit exceeded:', error.message) } }
The SDK includes comprehensive test coverage. Run tests with:
The SDK is generated from the OpenAPI specification:
MIT
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4