> ## Documentation Index
> Fetch the complete documentation index at: https://vlyai-1c28d863.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigger agent run

> Asks an AI coding agent to work on a project. Returns an AgentRun record with a streaming URL.

Triggers an agent run from outside vly's UI. Useful for automating common tasks (regenerate weekly report, run a maintenance prompt nightly).

<Note>
  Agent runs cost [credits](/features/billing/credits). Track usage via [Get usage](/api-reference/billing/usage).
</Note>

The `stream_url` returned is a Server-Sent Events endpoint streaming agent output as it generates.


## OpenAPI

````yaml POST /v1/agents/run
openapi: 3.1.0
info:
  title: vly.ai API
  version: 0.1.0
  description: >-
    REST API for the vly.ai AI app builder. v0, illustrative — endpoints, paths,
    and shapes may change before general availability. See the API Reference
    introduction for status.
  contact:
    name: vly.ai support
    email: support@vly.ai
    url: https://docs.vly.ai/api-reference/introduction
  license:
    name: vly.ai Terms
    url: https://vly.ai/terms
servers:
  - url: https://api.vly.ai
    description: Production
  - url: https://api.staging.vly.ai
    description: Staging
security:
  - bearerAuth: []
tags:
  - name: Projects
    description: Create, list, update, and delete vly projects.
  - name: Deployments
    description: Trigger and inspect deployments.
  - name: Agents
    description: Trigger an AI agent run on a project.
  - name: Files
    description: Upload assets to a project.
  - name: Billing
    description: Inspect plan usage and credits.
  - name: Webhooks
    description: Send and verify webhook events.
paths:
  /v1/agents/run:
    post:
      tags:
        - Agents
      summary: Trigger an agent run
      description: >-
        Asks one of the AI coding agents to work on a project. Returns an
        agent-run record with a streaming URL for live updates.
      operationId: runAgent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - projectId
                - prompt
              properties:
                projectId:
                  type: string
                prompt:
                  type: string
                  example: >-
                    Add a settings page where users can change their email and
                    password.
                agent:
                  type: string
                  enum:
                    - claude-code
                    - openai-codex
                    - gemini-cli
                  default: claude-code
                mode:
                  type: string
                  enum:
                    - agent
                    - plan
                    - code
                  default: agent
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentRun'
components:
  schemas:
    AgentRun:
      type: object
      properties:
        id:
          type: string
          example: run_01JFA8N3Z1B6Y2K7Q3X4M5R8
        project_id:
          type: string
        agent:
          type: string
          enum:
            - claude-code
            - openai-codex
            - gemini-cli
        mode:
          type: string
          enum:
            - agent
            - plan
            - code
        status:
          type: string
          enum:
            - queued
            - running
            - completed
            - failed
            - cancelled
        stream_url:
          type: string
          format: uri
        started_at:
          type: string
          format: date-time
        completed_at:
          type: string
          format: date-time
          nullable: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: vly_live_...
      description: Workspace-scoped API key. Generate from Workspace settings → API keys.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.