Initialize Chat

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 /chats/init
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)
POST /chats/init
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; }"
      }
    ]
  }'

Parameters

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 enum

Controls the visibility of the chat. Defines whether the chat is private, shared with a team, or publicly accessible.

Possible values:

  • public
  • private
  • team-edit
  • team
  • unlisted

projectId string

Associates the chat with a specific project. Useful for organizing and grouping chats in a workspace.


type string

Specifies the initialization method. For this endpoint, it defines the source of content being used to initialize the chat.


files any[]

An array of inline file objects used to initialize the chat. Each object must contain a file name and its content.

Array items: string


repo object

Specifies a repository source for initialization. Should include relevant details like repository URL, branch, and authentication if needed.

url string Required


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 Required


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 Required


Response

Response Body

id string Required

A unique identifier for the chat.


object string Required

Fixed value identifying this object as a chat.


shareable boolean Required

Indicates whether the chat can be shared via public link.


privacy enum Required

Defines the visibility of the chat—private, team-only, or public.

Possible values:

  • public
  • private
  • team
  • team-edit
  • unlisted

name string

An optional name assigned to the chat by the user.


title string

Deprecated title field preserved for backward compatibility.


createdAt string Required

The ISO timestamp representing when the chat was created.


updatedAt string

The ISO timestamp of the last update to the chat.


favorite boolean Required

Indicates whether the chat is marked as a favorite.


authorId string Required

The ID of the user who created the chat.


projectId string

Optional ID of the v0 project associated with this chat.


webUrl string Required

Web URL to view this chat in the browser.


apiUrl string Required

API URL to access this chat via the API.


latestVersion object

Full details of the most recent generated version, if available.

id string Required

A unique identifier for the version.


object string Required

Fixed value identifying this object as a version.


status enum Required

The current status of the version generation process.

Possible values:

  • pending
  • completed
  • failed

demoUrl string

Optional URL for previewing the generated output.


createdAt string Required

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 any[] Required

A list of files that were generated or included in this version.

Array items: string


url string Required

The canonical URL to access this chat.


messages any[] Required

All messages exchanged in the chat, including user and assistant entries.

Array items: string


files object[]

Optional array of files associated with the chat context.

Array items:

lang string Required

Programming language used in the file (e.g., JavaScript, Python).


meta object Required

A key-value map of metadata associated with the file (e.g., path, type).


source string Required

The origin or identifier of the file source (e.g., path or upload label).


demo string

Deprecated demo URL used for previewing the chat result.


text string Required

The main user prompt or instruction that started the chat.