> ## Documentation Index
> Fetch the complete documentation index at: https://vastai-80aa3a82-examples-openclaw-openai-serverless.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# route

> Calls on the serverless engine to retrieve a GPU instance address within your endpoint for processing a request.
The engine will return either a ready worker URL or status information if no workers are available.

CLI Usage: `vastai route <endpoint> <cost>`



## OpenAPI

````yaml /api-reference/openapi.yaml post /route/
openapi: 3.1.0
info:
  title: Vast.ai API
  description: >-
    Vast.ai REST API for managing GPU cloud instances, machine operations, and
    AI/ML workflows.


    ## AI Agent Quick-Start


    Install the CLI skill for your agent (Claude Code, Cursor, Windsurf, etc.):
      npx skills add vast-ai/vast-cli

    CLI reference:
    https://raw.githubusercontent.com/vast-ai/vast-cli/master/vastai/SKILL.md

    SDK reference:
    https://raw.githubusercontent.com/vast-ai/vast-cli/master/vastai_sdk/SKILL.md


    ## Auth

    All endpoints require `Authorization: Bearer $VAST_API_KEY`.

    Get your key at: https://cloud.vast.ai/manage-keys/


    ## Key Quirks

    - `gpu_ram` in CLI = GB; in REST API = MB (CLI auto-converts)

    - SSH keys must be registered BEFORE creating an instance (VM: no recovery;
    Docker: can add post-create)

    - `onstart` field is limited to 4048 characters -- gzip+base64 for longer
    scripts

    - `POST /api/v0/asks/{id}/` (create instance) returns `new_contract` as the
    instance ID, not `id`

    - Poll trap: if `actual_status` becomes `exited`, `unknown`, or `offline` it
    will never reach `running` -- destroy and retry
  version: 1.0.0
  contact:
    name: Vast.ai Support
    url: https://discord.gg/vast
servers:
  - url: https://console.vast.ai
    description: Production server
security:
  - BearerAuth: []
paths:
  /route/:
    post:
      tags:
        - Serverless
      summary: route
      description: >-
        Calls on the serverless engine to retrieve a GPU instance address within
        your endpoint for processing a request.

        The engine will return either a ready worker URL or status information
        if no workers are available.


        CLI Usage: `vastai route <endpoint> <cost>`
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - endpoint
                - cost
              properties:
                endpoint:
                  type: string
                  description: Name of the endpoint
                  example: vLLM-Qwen3-8B
                cost:
                  type: number
                  format: float
                  description: The estimated compute resources for the request
                  default: 100
                  example: 242
                  minimum: 0
      responses:
        '200':
          description: Success response - either worker assignment or status
          content:
            application/json:
              schema:
                oneOf:
                  - title: Worker Available
                    type: object
                    properties:
                      endpoint:
                        type: string
                        description: Same as the input parameter
                        example: vLLM-Qwen3-8B
                      url:
                        type: string
                        description: >-
                          The address of the worker instance to send the request
                          to
                        example: http://192.168.1.10:8000
                      cost:
                        type: number
                        description: Same as the input parameter
                        example: 242
                      reqnum:
                        type: integer
                        description: Request number corresponding to this worker instance
                        example: 12345
                      signature:
                        type: string
                        description: Cryptographic signature authenticating the response
                        example: >-
                          a1b2c3d4e5f60708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20
                      __request_id:
                        type: string
                        description: >-
                          Unique identifier generated by the server for this
                          request
                        example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                  - title: No Worker Available
                    type: object
                    properties:
                      endpoint:
                        type: string
                        description: Same as the input parameter
                        example: vLLM-Qwen3-8B
                      status:
                        type: string
                        description: Breakdown of workers in your endpoint group by status
                        example: Stopped
                      __request_id:
                        type: string
                        description: >-
                          Unique identifier generated by the server for this
                          request
                        example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
        '400':
          description: Bad Request - invalid parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid endpoint or missing required parameters
        '401':
          description: Unauthorized - authentication failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Authentication failed
      security:
        - BearerAuth: []
      servers:
        - url: https://run.vast.ai
          description: Production server
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key must be provided in the Authorization header

````