Skip to content
Dashboard

Introducing the new v0 API

Copy link to headingHow it works

pnpm add v0@latest

import { v0 } from 'v0'
const result = await v0.chats.create({
message: 'Build an issue triage app for a support team.',
})
if (result.error) {
throw new Error(result.error.message)
}
const chatId = result.data.chat.id

Create a chat and keep its ID for every later request.

const message = await v0.messages.send({
chatId,
message: 'Add a priority filter and an assignee column.',
})
if (message.error) {
throw new Error(message.error.message)
}

Send a follow-up; v0 edits the existing app in place.

<iframe src="/api/v0-preview/chat_abc123/" />

Embed the app by pointing an iframe at your proxy route.

Copy link to headingWhat this unlocks

Copy link to headingStart with a chat

Copy link to headingStream the trace

const stream = await v0.messages.sendStream({
chatId: 'chat_abc123',
message: 'Add authentication and explain the files you changed.',
})
for await (const update of stream.stream) {
console.log(update.parts)
if (update.usage) {
console.log(update.usage)
}
}

Stream a message's work; each update is a full snapshot of parts.

Copy link to headingChoose sync, async, or streaming

const message = 'Build an issue triage app for a support team.'
// Wait for the completed response.
const completed = await v0.chats.create({ message })
if (completed.error) {
throw new Error(completed.error.message)
}
// Queue work and use the returned IDs to retrieve the result later.
const queued = await v0.chats.createAsync({ message })
if (queued.error) {
throw new Error(queued.error.message)
}
console.log(queued.data.chatId, queued.data.messageId)
// Receive the agent's work as it happens.
const stream = await v0.chats.createStream({ message })

Create a chat three ways: await, queue, or stream the same prompt.

Copy link to headingWork from existing code

const result = await v0.chats.createFromRepo({
repo: {
url: 'https://github.com/acme/app',
branch: 'main',
},
title: 'Acme app',
metadata: {
source: 'github',
},
})
if (result.error) {
throw new Error(result.error.message)
}
const chatId = result.data.chat.id
console.log(chatId)

Create a chat from an existing repo.

Copy link to headingRender the dev server preview

import { fetchPreview, v0 } from 'v0'
export async function proxyPreviewRequest(
request: Request,
chatId: string,
path: string[],
) {
const result = await v0.chats.getPreview({ chatId })
if (result.error) {
throw new Error(result.error.message)
}
return fetchPreview({
request,
preview: result.data,
path,
fallbackUrl: `/api/v0-preview/${chatId}/loading`,
})
}

Proxy preview requests through a server route.

Copy link to headingBring your own tools and design systems

const designSystem = {
type: 'memory',
scope: 'team',
skillName: 'geist-ui',
}
const result = await v0.chats.create({
message: 'Build an admin console with filters and charts.',
skills: [
designSystem,
],
})

Create a chat with a design system loaded as a skill.

Copy link to headingUse v0 from agents

Copy link to headingMCP

{
"mcpServers": {
"v0": {
"url": "https://v0.app/api/mcp"
}
}
}

The v0 server entry for your MCP client.

Copy link to headingAI SDK

pnpm add @v0-sdk/ai-tools ai @ai-sdk/openai

Install the v0 tools with the AI SDK and a provider.

import { openai } from '@ai-sdk/openai'
import { generateText, stepCountIs } from 'ai'
import { v0ToolsByCategory } from '@v0-sdk/ai-tools'
const { chats, messages } = v0ToolsByCategory()
const result = await generateText({
model: openai('gpt-5.5'),
system: `Use v0 for creating and modifying web apps. Continue an existing v0 chat when a chat ID is available.`,
prompt: 'Build a customer insights app with charts.',
tools: {
...chats,
...messages,
},
stopWhen: stepCountIs(10),
})

Give an AI SDK agent v0's chat and message tools.

Copy link to headingeve

import { defineOpenAPIConnection } from 'eve/connections'
export default defineOpenAPIConnection({
spec: 'https://api.v0.dev/v2/openapi/json',
baseUrl: 'https://api.v0.dev/v2',
description:
'Build and iterate on web apps with v0. Reuse one v0 chat per app-building task.',
auth: {
getToken: async () => ({ token: process.env.V0_API_KEY! }),
},
operations: {
allow: [
'chats_create',
'messages_send',
'messages_resolve',
'chats_getPreview',
],
},
})

Register v0 as an eve connection, allow-listing its operations.

Copy link to headingConnect a Vercel project

const result = await v0.chats.createVercelProject({
chatId: 'chat_123',
})
if (result.error) {
throw new Error(result.error.message)
}
const vercelProjectId = result.data.vercelProjectId

Attach a Vercel project to a chat.

const result = await v0.chats.deploy({ chatId })
if (result.error) {
throw new Error(result.error.message)
}
const { deploymentId, vercelProjectId } = result.data

Ship the chat to Vercel.

Copy link to headingMigrate your chats

Copy link to headingGet started

pnpm add v0@latest

pnpm create v0-sdk-app@latest my-v0-app

Build your first app-generation interface with the v0 API.

Read the quickstart guide to go from a prompt to a running app in your own UI.

Get Started

Contributors

Ready to deploy?