Skip to main content
A type-safe API client for the v0 by Vercel API, auto-generated from the official OpenAPI specification with full TypeScript support and MCP integration.

Features

  • Type-Safe - Full TypeScript support with auto-generated types from OpenAPI spec
  • Zod Schemas - Runtime validation with Zod schemas for all API types
  • MCP Support - Model Context Protocol integration for AI assistants
  • Auto-Updated - Daily regeneration from upstream OpenAPI specs

Installation

pnpm add v0-api

Usage

Basic Usage

import { createClient } from "v0-api";

const client = createClient({
  baseUrl: "https://api.v0.dev",
  headers: {
    Authorization: `Bearer ${process.env.V0_TOKEN}`,
  },
});

// List projects
const projects = await client.getProjects();

// Generate a component
const generation = await client.createGeneration({
  prompt: "Create a login form with email and password",
});

Type Exports

import type { Types } from "v0-api";

// Use TypeScript types for your application
type Project = Types.Project;
type Generation = Types.Generation;

Zod Schemas

import { Schemas } from "v0-api";

// Validate API responses at runtime
const projectSchema = Schemas.project;
const validated = projectSchema.parse(response);

MCP Integration

The package includes MCP (Model Context Protocol) support for AI assistants.

Remote MCP Server

Add to your MCP client configuration:
{
  "mcpServers": {
    "v0": {
      "url": "https://openapi.sferadev.com/api/v0/mcp"
    }
  }
}

Local MCP Server

import { initMcpTools } from "v0-api/mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

const server = new McpServer({ name: "v0" });

initMcpTools(server, {
  baseUrl: "https://api.v0.dev",
  headers: {
    Authorization: `Bearer ${process.env.V0_TOKEN}`,
  },
});

API Reference

The client exposes v0 API endpoints for AI-powered component generation and project management.