---
title: Initialize Chat
description: Initializes a new chat from source content such as files, repositories, registries, or zip archives. Enables context-rich conversations based on code or assets.
docs_index: /docs/llms.txt
lastUpdated: 2026-10-23
product: v0 API
type: reference
prerequisites:
  - /docs/api/v1/quickstart
---

> For an index of all documentation, see [/docs/llms.txt](/docs/llms.txt).

Initializes a new chat from source content such as files, repositories, registries, or zip archives. Enables context-rich conversations based on code or assets.

#### `POST /v1/chats/init`

> `v0-auto` is deprecated. Requests using it are handled as `v0-pro`. Use `v0-pro` for new integrations.

## Usage

```typescript
import { v0 } from 'v0-sdk'

const result = await v0.chats.init({
  type: 'files',
  files: [
    {
      name: 'app/globals.css',
      content: "body { background-color: black; color: white; }"
    },
  ],
})

console.log(result)
```

```bash
curl -X POST "https://api.v0.dev/v1/chats/init"   -H "Authorization: Bearer $V0_API_KEY"   -H "Content-Type: application/json"   -d '{
    "type": "files",
    "files": [
      {
        "name": "app/globals.css",
        "content": "body { background-color: black; color: white; }"
      }
    ]
  }'
```

```typescript
import { v0 } from 'v0-sdk'

const result = await v0.chats.init({
  type: 'repo',
  repo: {
    url: 'https://github.com/vercel/next.js',
    branch: 'canary',
  },
  name: 'Analyze Next.js repo',
})

console.log(result)
```

```bash
curl -X POST "https://api.v0.dev/v1/chats/init"   -H "Authorization: Bearer $V0_API_KEY"   -H "Content-Type: application/json"   -d '{
    "type": "repo",
    "repo": {
      "url": "https://github.com/vercel/next.js",
      "branch": "canary"
    },
    "name": "Analyze Next.js repo"
  }'
```

```typescript
import { v0 } from 'v0-sdk'

const result = await v0.chats.init({
  type: 'registry',
  registry: {
    url: 'https://ui.shadcn.com/registry/blocks/dashboard-01.json',
  },
  name: 'Customize dashboard component',
})

console.log(result)
```

```bash
curl -X POST "https://api.v0.dev/v1/chats/init"   -H "Authorization: Bearer $V0_API_KEY"   -H "Content-Type: application/json"   -d '{
    "type": "registry",
    "registry": {
      "url": "https://ui.shadcn.com/registry/blocks/dashboard-01.json"
    },
    "name": "Customize dashboard component"
  }'
```

```typescript
import { v0 } from 'v0-sdk'

const result = await v0.chats.init({
  type: 'zip',
  zip: {
    url: 'https://example.com/starter-template.zip',
  },
  lockAllFiles: true,
  name: 'Modify starter template',
})

console.log(result)
```

```bash
curl -X POST "https://api.v0.dev/v1/chats/init"   -H "Authorization: Bearer $V0_API_KEY"   -H "Content-Type: application/json"   -d '{
    "type": "zip",
    "zip": {
      "url": "https://example.com/starter-template.zip"
    },
    "lockAllFiles": true,
    "name": "Modify starter template"
  }'
```

```typescript
import { v0 } from 'v0-sdk'

const result = await v0.chats.init({
  type: 'files',
  files: [
    {
      name: 'app/page.tsx',
      content: 'export default function Page() { return <div>Hello</div> }'
    },
  ],
  metadata: {
    userId: 'user_abc123',
    organizationId: 'org_xyz789',
    source: 'mobile-app',
  },
})

// Later, retrieve the metadata
console.log(result.metadata.userId) // 'user_abc123'
```

```bash
curl -X POST "https://api.v0.dev/v1/chats/init"   -H "Authorization: Bearer $V0_API_KEY"   -H "Content-Type: application/json"   -d '{
    "type": "files",
    "files": [
      {
        "name": "app/page.tsx",
        "content": "export default function Page() { return <div>Hello</div> }"
      }
    ],
    "metadata": {
      "userId": "user_abc123",
      "organizationId": "org_xyz789",
      "source": "mobile-app"
    }
  }'
```

## API Signature

### Request

#### Body

- `name?: string` A user-defined name for the chat. Helps identify or describe the purpose of the chat session in the UI or API responses.
- `chatPrivacy?: 'public' | 'private' | 'team-edit' | 'team' | 'unlisted'` Controls the visibility of the chat. Defines whether the chat is private, shared with a team, or publicly accessible.
- `projectId?: string` **Deprecated.** Associates the chat with a specific project. Useful for organizing and grouping chats in a workspace.
- `metadata?: Record<string, string>` Arbitrary key-value data to attach to the chat. Useful for storing additional data about the chat, such as external user IDs. Keys must be 1-40 characters, values must be 1-500 characters, and a maximum of 50 key-value pairs are allowed.
- `type?: 'template'` Specifies the initialization method. For this endpoint, it defines the source of content being used to initialize the chat.
- `files?: object | object[]` An array of inline file objects used to initialize the chat. Each object must contain a file `name` and its `content`.
  - `item: object | object`
    - `name?: string`
    - `url?: string`
    - `locked?: boolean` Whether to lock this file to prevent AI from overwriting it during generation
    - `content?: string`
- `repo?: object` Specifies a repository source for initialization. Supports both public and private GitHub repositories. For private repositories, ensure your GitHub account is connected through Vercel.
  - `url: string`
  - `branch?: string`
- `lockAllFiles?: boolean` Whether to lock all files from the zip archive to prevent AI from overwriting them during generation
- `registry?: object` Allows initialization from a predefined component or code registry. Includes the registry source and identifier for the desired component/module.
  - `url: string`
- `zip?: object` Provides a zipped bundle of files as the input source. Typically includes a base64-encoded archive or a remote URL reference.
  - `url: string`
- `templateId?: string` The ID of the template to initialize the chat from. This should be a valid template ID from the v0 template system.

### Response

- `id: string` A unique identifier for the chat.
- `object: 'chat'` Fixed value identifying this object as a chat.
- `shareable: boolean` **Deprecated.** Deprecated: Use the `privacy` field instead. A chat is shareable when privacy is public or unlisted.
- `privacy: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted'` Defines the visibility of the chat—private, team-only, or public.
- `name?: string` An optional name assigned to the chat by the user.
- `title?: string` **Deprecated.** Deprecated title field preserved for backward compatibility.
- `createdAt: string` The ISO timestamp representing when the chat was created.
- `updatedAt?: string` The ISO timestamp of the last update to the chat.
- `favorite: boolean` Indicates whether the chat is marked as a favorite.
- `authorId: string` The ID of the user who created the chat.
- `projectId?: string` **Deprecated.** Optional ID of the v0 project associated with this chat.
- `vercelProjectId?: string` Optional ID of the linked Vercel project, if connected.
- `webUrl: string` Web URL to view this chat in the browser.
- `apiUrl: string` API URL to access this chat via the API.
- `latestVersion?: object` Full details of the most recent generated version, if available.
  - `id: string` A unique identifier for the version.
  - `object: 'version'` Fixed value identifying this object as a version.
  - `status: 'pending' | 'completed' | 'failed'` The current status of the version generation process.
  - `demoUrl?: string` Optional URL for previewing the generated output.
  - `screenshotUrl?: string` An authenticated URL to retrieve a screenshot of this version. Fetching this URL requires the same Authorization: Bearer header as all other API calls — it cannot be used directly as an `<img>` `src`. To display it in a browser, proxy the request server-side and forward the Authorization header. Append `?ignoreCache=1` to bypass the one-week screenshot cache.
  - `createdAt: string` The date and time when the version was created, in ISO 8601 format.
  - `updatedAt?: string` The date and time when the version was last updated, in ISO 8601 format.
  - `files: object[]` A list of files that were generated or included in this version.
    - `item: object` Detailed representation of a file, including its content and lock status.
      - `object: 'file'` Fixed value identifying this object as a file.
      - `name: string` The name of the file, including its extension.
      - `content: string` The full contents of the file as a raw string.
      - `locked: boolean` Whether the file is locked to prevent AI from overwriting it during new version generation.
- `url: string` **Deprecated.** The canonical URL to access this chat.
- `messages: object[]` All messages exchanged in the chat, including user and assistant entries.
  - `item: object` Summary of a single message within a chat, including role, content, type, timestamp, and API URL.
    - `id: string` A unique identifier for the message.
    - `object: 'message'` Fixed value identifying this object as a message.
    - `content: string` The main text content of the message.
    - `experimental_content?: any[] | any[][]` The parsed content of the message as an array structure containing AST nodes. This is an experimental field that may change.
      - `item: any[] | any[]`
    - `createdAt: string` The ISO timestamp representing when the message was created.
    - `updatedAt?: string` The ISO timestamp representing when the message was last updated.
    - `type: 'message' | 'forked-block' | 'forked-chat' | 'open-in-v0' | 'refinement' | 'added-environment-variables' | 'added-integration' | 'deleted-file' | 'moved-file' | 'renamed-file' | 'edited-file' | 'replace-src' | 'reverted-block' | 'fix-with-v0' | 'auto-fix-with-v0' | 'sync-git' | 'pull-changes' | 'fix-cve' | 'answered-questions'` Indicates the format or category of the message, such as plain text or code.
    - `role: 'user' | 'assistant'` Specifies whether the message was sent by the user or the assistant.
    - `finishReason?: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown'` The reason why the message generation finished.
    - `apiUrl: string` API URL to access this message via the API.
    - `authorId: string | null` The ID of the user who sent the message.
    - `parentId?: string | null` The ID of the parent message.
    - `attachments?: object[]`
      - `item: object`
        - `url: string` The URL where the attachment file can be accessed.
        - `name?: string` The original filename of the attachment.
        - `contentType?: string` The MIME type of the attachment file (e.g., image/png, application/pdf).
        - `size: number` The size of the attachment file in bytes.
        - `content?: string` The base64-encoded content of the attachment file, if available.
        - `type?: 'screenshot' | 'figma' | 'zip'` Optional v0-specific attachment type for enhanced processing.
- `files?: object[]` Optional array of files associated with the chat context.
  - `item: object`
    - `lang: string` Programming language used in the file (e.g., JavaScript, Python).
    - `meta: object` A key-value map of metadata associated with the file (e.g., path, type).
    - `source: string` The origin or identifier of the file source (e.g., path or upload label).
- `demo?: string` **Deprecated.** Deprecated demo URL used for previewing the chat result.
- `text: string` The main user prompt or instruction that started the chat.
- `modelConfiguration?: object` The configuration used to generate responses in this chat.
  - `modelId?: 'v0-auto' | 'v0-mini' | 'v0-pro' | 'v0-max' | 'v0-max-fast' | string` Model to use for the generation. `v0-auto` is deprecated and falls back to `v0-pro`.
  - `imageGenerations?: boolean` Enables image generations to generate up to 5 images per version.
  - `thinking?: boolean` Enables thinking to generate a response in multiple steps.
- `permissions: object`
  - `write: boolean` If true, the user has write access to the chat.
- `metadata: Record<string, string>` Arbitrary key-value data associated with this chat.

---

For a semantic overview of all documentation, see [/docs/sitemap.md](/docs/sitemap.md)

For an index of all available documentation, see [/docs/llms.txt](/docs/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/docs/agents.md](/docs/agents.md)