Vercel Chats API

AI-powered app generation via chat sessions

OpenAPI Specification

vercel-chats-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Vercel AI Gateway Chat Chats API
  description: The Vercel AI Gateway provides a unified API to access hundreds of AI models from multiple providers (Anthropic, OpenAI, Google, Meta, Mistral, and more) through a single endpoint. Features include one API key for hundreds of models, spend monitoring, automatic retries and fallbacks, provider routing by cost/latency/throughput, embeddings support, and zero markup on token pricing. Compatible with the AI SDK, OpenAI SDK, and Anthropic SDK.
  version: 1.0.0
  contact:
    name: Vercel Support
    url: https://vercel.com/help
  termsOfService: https://vercel.com/legal/terms
servers:
- url: https://ai-gateway.vercel.sh
  description: Vercel AI Gateway
security:
- BearerAuth: []
tags:
- name: Chats
  description: AI-powered app generation via chat sessions
paths:
  /v1/chat:
    post:
      operationId: createChat
      summary: Create Chat
      description: Start a new v0 chat session to generate a web application from a natural language prompt. Returns generated code, a preview URL, and project details.
      tags:
      - Chats
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatRequest'
      responses:
        '200':
          description: Chat response with generated code and preview
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
  /v1/chat/{chatId}:
    post:
      operationId: continueChat
      summary: Continue Chat
      description: Continue an existing v0 chat session with a follow-up message to iterate on the generated application.
      tags:
      - Chats
      parameters:
      - name: chatId
        in: path
        required: true
        description: Existing chat session ID
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContinueChatRequest'
      responses:
        '200':
          description: Updated chat response with revised code
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    get:
      operationId: getChat
      summary: Get Chat
      description: Returns details and generated code for an existing v0 chat session.
      tags:
      - Chats
      parameters:
      - name: chatId
        in: path
        required: true
        description: Chat session ID
        schema:
          type: string
      responses:
        '200':
          description: Chat details and generated code
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  responses:
    PaymentRequired:
      description: Premium or Team plan required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Chat session not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimitExceeded:
      description: API rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    GeneratedFile:
      type: object
      properties:
        path:
          type: string
          description: File path within the project (e.g., 'app/page.tsx')
        content:
          type: string
          description: File content (source code)
        language:
          type: string
          description: Programming language or file type
    ContinueChatRequest:
      type: object
      required:
      - message
      properties:
        message:
          type: string
          description: Follow-up instruction or refinement request
          example: Add dark mode support and mobile responsive layout
    CreateChatRequest:
      type: object
      required:
      - message
      properties:
        message:
          type: string
          description: Natural language prompt describing the app to generate
          example: Build a todo app with Next.js and Tailwind CSS with local storage persistence
        system:
          type: string
          description: Optional system instructions to guide code generation
        modelConfiguration:
          type: object
          description: Model configuration options
          properties:
            model:
              type: string
              description: AI model to use for generation
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
    ChatResponse:
      type: object
      properties:
        id:
          type: string
          description: Chat session unique identifier
        url:
          type: string
          format: uri
          description: URL to the v0 chat in the browser
        previewUrl:
          type: string
          format: uri
          description: URL to the rendered preview of the generated app
        files:
          type: array
          items:
            $ref: '#/components/schemas/GeneratedFile'
          description: Generated code files
        title:
          type: string
          description: Auto-generated title for the chat
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Vercel AI Gateway API key (AI_GATEWAY_API_KEY)