Overview

The v0 API gives your product v0's app-building agent, including code generation, secure live previews, integrations, and deployment to Vercel.

Create a full-stack app from a prompt with one API call:

import { v0 } from 'v0'

const result = await v0.chats.create({
  message: 'Create a project management dashboard with a kanban board',
})

if (result.error) {
  throw new Error(result.error.message)
}

console.log('Created chat:', result.data.chat.id)

Why use the v0 API?

Building an app-generation experience requires more than just generating code. You need an agent that can plan and iterate, a secure environment for running its work, and a path from a prompt to a production application. The v0 API provides the complete workflow through one API.

Benefits include:

  • Agentic app generation: Create full-stack applications from natural language, then continue iterating through follow-up messages.
  • Secure live previews: Run generated applications and embed their previews without exposing credentials to the browser.
  • Extensible workflows: Connect MCP servers, integrations, environment variables, and design systems.
  • Built-in deployment: Deploy generated applications to Vercel without building separate deployment infrastructure.

The v0 API supports these primary workflows:

Get Started

Start with a complete app-generation frontend:

npx create-v0-sdk-app

The starter includes a full chat interface with live previews. Follow the Quickstart to configure the starter or add v0 to an existing app.

Error handling

When synchronously creating a chat, sending a message, or resolving a task, a model policy refusal returns HTTP 422 with the following response body:

{
  "message": "The selected model declined to respond to this request. Try rephrasing your request or choosing a different model."
}

Do not automatically retry the unchanged request with the same model. Try rephrasing your request or choosing a different model. Unexpected server failures return HTTP 500 with { "message": "An unexpected error occurred" }.

Reference and migration