> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runpod.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a serverless endpoint

> Creates a serverless endpoint. Specify `gpu` for compute (CPU
serverless endpoints are read-only). Container settings can be spread
from a template response — see `CreateEndpointRequest` for the full
body.

Returns `201` with the created endpoint. The endpoint can accept jobs
immediately, but starts with no active workers unless `workers.min`
is greater than 0. Workers are provisioned on demand and autoscaled
between `workers.min` and `workers.max` according to the `scaling`
policy, so the first request to an idle endpoint may incur cold-start
latency while a worker pulls its image and boots.




## OpenAPI

````yaml post /v2/serverless
openapi: 3.1.0
info:
  title: Runpod REST API
  version: 2.0.0
  description: Runpod public REST API — v2
servers:
  - url: https://api.runpod.io
    description: Runpod API v2 production server
security:
  - bearerAuth: []
tags:
  - name: Pods
    description: GPU and CPU pod lifecycle, configuration, actions, and log streaming.
  - name: Serverless
    description: >-
      Serverless endpoint lifecycle, worker visibility, releases, and worker log
      streaming.
  - name: Templates
    description: Reusable pod and endpoint configuration templates.
  - name: Network Volumes
    description: Persistent network storage volumes for workloads.
  - name: Registries
    description: Container registry credentials used to pull private images.
  - name: Catalog
    description: Available GPU, CPU, and data center catalog metadata.
  - name: Billing
    description: Billing history and usage cost records across resource types.
paths:
  /v2/serverless:
    post:
      tags:
        - Serverless
      summary: Create a serverless endpoint
      description: |
        Creates a serverless endpoint. Specify `gpu` for compute (CPU
        serverless endpoints are read-only). Container settings can be spread
        from a template response — see `CreateEndpointRequest` for the full
        body.

        Returns `201` with the created endpoint. The endpoint can accept jobs
        immediately, but starts with no active workers unless `workers.min`
        is greater than 0. Workers are provisioned on demand and autoscaled
        between `workers.min` and `workers.max` according to the `scaling`
        policy, so the first request to an idle endpoint may incur cold-start
        latency while a worker pulls its image and boots.
      operationId: createEndpoint
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEndpointRequest'
            examples:
              serverlessEndpoint:
                summary: Serverless endpoint
                value:
                  name: image-generator
                  image: runpod/pytorch:2.8.0-py3.11-cuda12.8.1
                  gpu:
                    pools:
                      - ADA_24
                    count: 1
                  workers:
                    min: 0
                    max: 5
                  scaling:
                    type: QUEUE_DELAY
                    value: 4
                    idleTimeout: 5
                  dataCenterIds:
                    - US-KS-2
                  timeout: 300000
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Endpoint'
              examples:
                endpoint:
                  summary: Successful response
                  value:
                    id: 4m7x2k9q
                    name: image-generator
                    type: QUEUE_BASED
                    requestUrls:
                      run: https://api.runpod.ai/v2/4m7x2k9q/run
                      runSync: https://api.runpod.ai/v2/4m7x2k9q/runsync
                    image: runpod/pytorch:2.8.0-py3.11-cuda12.8.1
                    args: ''
                    disk: 20
                    ports:
                      - 8000/http
                    env:
                      MODEL_NAME: sdxl
                    registry: null
                    gpu:
                      pools:
                        - ADA_24
                      count: 1
                    workers:
                      min: 0
                      max: 5
                    scaling:
                      type: QUEUE_DELAY
                      value: 4
                      idleTimeout: 5
                    dataCenterIds:
                      - US-KS-2
                    networkVolumes:
                      - 2q9m7x4c
                    timeout: 300000
                    flashboot: 'OFF'
                    createdAt: '2026-06-01T12:00:00Z'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '422':
          $ref: '#/components/responses/UnprocessableEntityError'
        '429':
          $ref: '#/components/responses/TooManyRequestsError'
        default:
          description: Error
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateEndpointRequest:
      allOf:
        - $ref: '#/components/schemas/ContainerConfig'
        - type: object
          required:
            - name
            - image
            - gpu
          properties:
            name:
              type: string
              minLength: 1
              examples:
                - my-inference
            gpu:
              allOf:
                - $ref: '#/components/schemas/EndpointGpuConfig'
              unevaluatedProperties: false
            workers:
              type: object
              additionalProperties: false
              properties:
                min:
                  type: integer
                  minimum: 0
                  default: 0
                max:
                  type: integer
                  minimum: 0
                  default: 3
            scaling:
              type: object
              additionalProperties: false
              properties:
                type:
                  $ref: '#/components/schemas/ScalerType'
                value:
                  type: number
                  format: float
                  minimum: 0.5
                  default: 4
                idleTimeout:
                  type: integer
                  minimum: 0
                  default: 5
            dataCenterIds:
              type: array
              items:
                type: string
              description: >-
                Preferred data centers for placement. Omit or pass an empty
                array to let the scheduler choose.
            networkVolumes:
              type: array
              items:
                type: string
            timeout:
              type: integer
              default: 300000
            flashboot:
              allOf:
                - $ref: '#/components/schemas/FlashBoot'
              default: 'OFF'
      unevaluatedProperties: false
    Endpoint:
      allOf:
        - $ref: '#/components/schemas/ContainerConfig'
        - type: object
          required:
            - id
            - name
            - workers
            - scaling
            - dataCenterIds
            - networkVolumes
            - timeout
            - flashboot
            - createdAt
          properties:
            id:
              type: string
              examples:
                - ep_abc123
            name:
              type: string
              examples:
                - my-inference
            type:
              $ref: '#/components/schemas/EndpointType'
            requestUrls:
              $ref: '#/components/schemas/EndpointRequestUrls'
            gpu:
              anyOf:
                - $ref: '#/components/schemas/EndpointGpuConfig'
                - type: 'null'
            cpu:
              description: >-
                Read-only. Present for CPU serverless endpoints; CPU
                create/update is not yet supported.
              anyOf:
                - $ref: '#/components/schemas/CpuConfig'
                - type: 'null'
            workers:
              type: object
              required:
                - min
                - max
              properties:
                min:
                  type: integer
                  minimum: 0
                  examples:
                    - 0
                max:
                  type: integer
                  minimum: 0
                  examples:
                    - 5
            scaling:
              type: object
              required:
                - type
                - value
                - idleTimeout
              properties:
                type:
                  $ref: '#/components/schemas/ScalerType'
                value:
                  type: number
                  format: float
                  minimum: 0.5
                  examples:
                    - 4
                idleTimeout:
                  type: integer
                  minimum: 0
                  description: Seconds before idle workers scale down
                  examples:
                    - 5
            dataCenterIds:
              type: array
              items:
                type: string
              examples:
                - - US-TX-3
            networkVolumes:
              type: array
              items:
                type: string
              examples:
                - - vol_abc
            timeout:
              type: integer
              description: Per-request execution timeout in milliseconds
              examples:
                - 300000
            flashboot:
              $ref: '#/components/schemas/FlashBoot'
            createdAt:
              type: string
              format: date-time
              examples:
                - '2026-03-13T20:00:00Z'
    ErrorResponse:
      type: object
      required:
        - title
        - status
        - detail
      properties:
        title:
          type: string
          description: Short human-readable summary
          examples:
            - Not Found
        status:
          type: integer
          description: HTTP status code
          examples:
            - 404
        detail:
          type: string
          description: Human-readable explanation
          examples:
            - pod not found
        errors:
          type: array
          description: Individual request-validation failures.
          items:
            type: string
          examples:
            - - '$: additional properties ''bogus'' not allowed'
    ContainerConfig:
      type: object
      description: >
        Reusable container configuration shared across templates, pods, and
        serverless endpoints. Adding a field here automatically propagates to
        all three resources.
      properties:
        image:
          type: string
          description: Docker image reference
          examples:
            - runpod/pytorch:2.8.0-py3.11-cuda12.8.1
        args:
          type: string
          description: Arguments passed to the container entrypoint
          examples:
            - ''
        disk:
          type: integer
          minimum: 1
          description: Container disk in GB (ephemeral, wiped on restart)
          examples:
            - 50
        ports:
          type: array
          description: Exposed ports, formatted as port/protocol
          items:
            type: string
          examples:
            - - 8888/http
              - 22/tcp
        env:
          type: object
          additionalProperties:
            type: string
          description: Environment variables as key-value pairs
          examples:
            - JUPYTER_PASSWORD: hunter2
        registry:
          type:
            - string
            - 'null'
          description: Container registry credential ID (for private images)
          examples:
            - null
    EndpointGpuConfig:
      type: object
      required:
        - pools
      properties:
        pools:
          type: array
          minItems: 1
          description: |
            Serverless GPU pool IDs (as returned by `GET /v2/catalog/gpus` in
            `pool`). Workers are placed on whichever listed pool has capacity.
          items:
            type: string
          examples:
            - - ADA_24
        count:
          type: integer
          minimum: 1
          default: 1
          description: GPUs per worker
          examples:
            - 1
    ScalerType:
      type: string
      description: |
        Autoscaling strategy.
        - `QUEUE_DELAY`   — scale on seconds a request waits in queue
        - `REQUEST_COUNT` — scale on in-flight request count
      enum:
        - QUEUE_DELAY
        - REQUEST_COUNT
    FlashBoot:
      type: string
      description: |
        FlashBoot cold-start acceleration mode.
        - `OFF`                — disabled
        - `FLASHBOOT`          — enabled
        - `PRIORITY_FLASHBOOT` — enabled with priority capacity
      enum:
        - 'OFF'
        - FLASHBOOT
        - PRIORITY_FLASHBOOT
    EndpointType:
      type: string
      description: >
        Request-routing semantics for a modern serverless endpoint.

        - `QUEUE_BASED` — submit asynchronous or synchronous jobs through the
        managed queue.

        - `LOAD_BALANCING` — send requests directly to worker-defined HTTP
        paths.
      x-enum-varnames:
        - EndpointTypeQueueBased
        - EndpointTypeLoadBalancing
      enum:
        - QUEUE_BASED
        - LOAD_BALANCING
    EndpointRequestUrls:
      description: |
        Request submission URLs appropriate to the endpoint's top-level `type`.
        Queue-based endpoints provide `run` and `runSync`; load-balancing
        endpoints provide `base` because their paths are worker-defined.
      oneOf:
        - $ref: '#/components/schemas/QueueBasedRequestUrls'
        - $ref: '#/components/schemas/LoadBalancingRequestUrls'
    CpuConfig:
      allOf:
        - $ref: '#/components/schemas/BaseCpuConfig'
        - type: object
          required:
            - memory
          properties:
            memory:
              type: integer
              minimum: 1
              description: Memory allocated to the pod in GB.
              examples:
                - 16
    QueueBasedRequestUrls:
      type: object
      additionalProperties: false
      required:
        - run
        - runSync
      properties:
        run:
          type: string
          format: uri
          description: URL for asynchronously submitting a queued job.
          examples:
            - https://api.runpod.ai/v2/4m7x2k9q/run
        runSync:
          type: string
          format: uri
          description: URL for synchronously submitting a queued job.
          examples:
            - https://api.runpod.ai/v2/4m7x2k9q/runsync
    LoadBalancingRequestUrls:
      type: object
      additionalProperties: false
      required:
        - base
      properties:
        base:
          type: string
          format: uri
          description: Base URL for worker-defined HTTP and WebSocket paths.
          examples:
            - https://4m7x2k9q.api.runpod.ai
    BaseCpuConfig:
      type: object
      required:
        - id
        - vcpuCount
      properties:
        id:
          type: string
          description: CPU flavor identifier, as returned by GET /v2/catalog/cpus.
          examples:
            - cpu5c
          minLength: 1
        vcpuCount:
          type: integer
          minimum: 2
          description: >-
            Number of vCPUs. Must be valid for the selected CPU flavor and must
            be a power of two.
          examples:
            - 4
  responses:
    BadRequestError:
      description: >-
        The request could not be processed because it is malformed or conflicts
        with request rules.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            badRequest:
              summary: Bad request
              value:
                title: Bad Request
                status: 400
                detail: request could not be processed
    UnauthorizedError:
      description: >-
        Authentication failed because the bearer token is missing, malformed,
        expired, or invalid.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingBearerToken:
              summary: Missing bearer token
              value:
                title: Unauthorized
                status: 401
                detail: missing bearer token
    ForbiddenError:
      description: >-
        The bearer token is valid, but it does not grant access to the requested
        resource or action.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            insufficientAccess:
              summary: Insufficient access
              value:
                title: Forbidden
                status: 403
                detail: access denied
    UnprocessableEntityError:
      description: >-
        The request body or parameters were syntactically valid but failed
        validation.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            validationFailed:
              summary: Validation failed
              value:
                title: Unprocessable Entity
                status: 422
                detail: Request validation failed.
    TooManyRequestsError:
      description: >
        The caller exceeded its per-user rate limit. The response identifies the
        window that was exceeded and how long to wait. The `RateLimit` and
        `RateLimit-Policy` headers (per the IETF ratelimit-headers draft) also
        accompany successful responses, so clients can track quota before a 429.
      headers:
        Retry-After:
          description: Seconds to wait before retrying, per the exceeded window.
          schema:
            type: integer
          example: 12
        RateLimit:
          description: >
            Live per-window state as a structured-field list — one member per
            window (`minute`, `hour`, `day`) with remaining count `r` and
            seconds-until-reset `t`.
          schema:
            type: string
          example: '"minute";r=0;t=12, "hour";r=2800;t=1812, "day";r=49500;t=45012'
        RateLimit-Policy:
          description: >
            Static quota policy as a structured-field list — one member per
            window with quota `q` and window length `w` (seconds).
          schema:
            type: string
          example: '"minute";q=60;w=60, "hour";q=3000;w=3600, "day";q=50000;w=86400'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              summary: Rate limit exceeded
              value:
                title: Too Many Requests
                status: 429
                detail: rate limit exceeded for the minute window
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Runpod API Key
      description: >
        Runpod API key authentication. Generate an API key in the Runpod console
        and send it in the `Authorization` header as `Bearer <api_key>`. Keys
        are scoped to the permissions granted when created; requests may return
        `403` when a valid key lacks access to the requested resource or action.

````