---
title: Create Chat From Files
description: Creates a new chat from inline UTF-8 or base64-encoded source files.
docs_index: /docs/llms.txt
lastUpdated: 2026-10-23
badge: "POST"
---

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

Creates a new chat from inline UTF-8 or base64-encoded source files.

#### `POST /v2/chats/from-files`

> `chats.createFromFiles` imports the supplied files as an existing application; it does not scaffold a Next.js application or generate missing files. Provide a complete, runnable project, including its package and framework configuration. To generate an application from instructions, use [`chats.create`](/docs/api/v2/reference/chats/create-chat). To provide documents or a few reference files as context, use `attachments` with `chats.create` or `chats.createAsync`.

File `content` defaults to UTF-8 text. For arbitrary binary bytes, set `encoding: 'base64'` and provide standard padded base64; filename extensions do not select the encoding. Invalid base64 returns `422` before the chat is created.

## Usage

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

const result = await v0.chats.createFromFiles({
  files: [
    {
      name: 'package.json',
      content: JSON.stringify({
        scripts: { dev: 'next dev', build: 'next build' },
        dependencies: {
          next: 'latest',
          react: 'latest',
          'react-dom': 'latest',
        },
      }),
    },
    {
      name: 'app/layout.jsx',
      content:
        'export default function Layout({ children }) { return <html lang="en"><body>{children}</body></html> }',
    },
    {
      name: 'app/page.jsx',
      content: 'export default function Page() { return <h1>Hello</h1> }',
    },
    {
      name: 'public/logo.png',
      content:
        'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAF/gL+X2NDWQAAAABJRU5ErkJggg==',
      encoding: 'base64',
    },
  ],
  title: 'Imported project',
})

console.log(result)
```

```bash
curl -X POST "https://api.v0.dev/v2/chats/from-files"   -H "Authorization: Bearer $V0_API_KEY"   -H "Content-Type: application/json"   -d '{
    "files": [
      {
        "name": "package.json",
        "content": "{"scripts":{"dev":"next dev","build":"next build"},"dependencies":{"next":"latest","react":"latest","react-dom":"latest"}}"
      },
      {
        "name": "app/layout.jsx",
        "content": "export default function Layout({ children }) { return <html lang="en"><body>{children}</body></html> }"
      },
      {
        "name": "app/page.jsx",
        "content": "export default function Page() { return <h1>Hello</h1> }"
      },
      {
        "name": "public/logo.png",
        "content": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAF/gL+X2NDWQAAAABJRU5ErkJggg==",
        "encoding": "base64"
      }
    ],
    "title": "Imported project"
  }'
```

## API Signature

### Request

#### Request Body

- `files: object[]` Source files used to seed the new chat.
  - **Minimum items:** 1
  - **Maximum items:** 100
  - `item: object`
    - `name: string` Path of the file in the project.
      - **Minimum length:** 1
    - `content: string` File content encoded according to `encoding`.
    - `encoding?: 'utf8' | 'base64'` How `content` is encoded. Defaults to `utf8` when omitted.
- `privacy?: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted'` Visibility setting for the new chat.
- `title?: string` Title for the new chat.
- `metadata?: Record<string, string>` Arbitrary key-value data to attach to the chat.

### Response

- `chat: object`
  - `id: string` Unique chat identifier.
  - `title?: string` Chat title, if generated.
  - `privacy: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted'` Visibility setting of the chat.
  - `createdAt: string` ISO timestamp of when the chat was created.
  - `updatedAt?: string` ISO timestamp of when the chat was last updated.
  - `authorId: string` ID of the user who created the chat.
  - `vercelProjectId?: string` Associated Vercel project ID, if any.
  - `metadata: Record<string, string>` User-defined key-value metadata.
  - `writePermission: boolean` Whether the caller has write access to this chat.
- `usage: object` Model, token usage, and credit cost for the prompt.
  - `model: string | null` Model identifier used for the assistant message, or null when not applicable or unavailable.
  - `tokens: object` Token counts for this message.
    - `input: number` Prompt input value (non-cached).
    - `output: number` Completion output value.
    - `cacheRead: number` Cache-read input value.
    - `cacheWrite: number` Cache-write input value.
    - `total: number` Sum of input, output, cacheRead, and cacheWrite.
  - `creditsCost: object` Credit cost for this message.
    - `input: number` Prompt input value (non-cached).
    - `output: number` Completion output value.
    - `cacheRead: number` Cache-read input value.
    - `cacheWrite: number` Cache-write input value.
    - `total: number` Sum of input, output, cacheRead, and cacheWrite.

---

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)