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

# 创建实例



## OpenAPI

````yaml gpus/v2-spec/create-gpu-instance.json POST /gpus/v2/instances
openapi: 3.0.0
info:
  title: PPIO GPU API v2
  version: 2.0.0
servers:
  - url: https://api.ppio.com
security: []
paths:
  /gpus/v2/instances:
    post:
      summary: 创建实例
      parameters:
        - name: Content-Type
          in: header
          required: true
          schema:
            type: string
          description: 枚举值:application/json。
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
          description: Bearer 身份验证格式,例如:Bearer `{{API 密钥}}`。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - product_id
                - image
                - billing
                - resource
              properties:
                name:
                  type: string
                  description: 实例名称。字符串,长度限制:1-255 字符。
                  example: example-instance
                product_id:
                  type: string
                  description: 产品 ID。
                  example: product-id
                image:
                  type: string
                  description: 镜像地址。字符串,长度限制:1-500 字符。
                  example: registry.example.com/namespace/image:tag
                billing:
                  type: object
                  description: 计费配置。
                  required:
                    - mode
                  properties:
                    mode:
                      type: string
                      enum:
                        - postpaid
                        - prepaid
                        - spot
                      description: 计费模式。可选值:`postpaid`、`prepaid`、`spot`。
                      example: prepaid
                    prepaid:
                      type: object
                      description: 包年包月配置,`mode=prepaid` 时使用。
                      required:
                        - months
                      properties:
                        months:
                          type: integer
                          description: 购买月数。整数,取值 > 0。`mode=prepaid` 时是必填。
                          example: 1
                        auto_renew:
                          type: object
                          description: 自动续费配置。
                          properties:
                            enabled:
                              type: boolean
                              description: 是否开启自动续费。
                              example: true
                            months:
                              type: integer
                              description: 自动续费月数。整数,取值 >= 0。
                              example: 1
                resource:
                  type: object
                  description: 资源配置。
                  required:
                    - rootfs_size_gb
                    - gpu_num
                  properties:
                    rootfs_size_gb:
                      type: integer
                      description: 系统盘大小。整数,取值 > 1。单位为 GB。
                      example: 20
                    gpu_num:
                      type: integer
                      description: GPU 数量。整数,取值 > 0。
                      example: 1
                    min_cuda_version:
                      type: string
                      description: 最低 CUDA 版本要求。字符串,长度限制:0-255 字符。
                      example: ''
                type:
                  type: string
                  enum:
                    - gpu
                    - cpu
                  description: 实例类型。可选值:`gpu`、`cpu`。默认值:`gpu`。
                registry_auth_id:
                  type: string
                  description: 已保存的镜像认证 ID。字符串,长度限制:0-255 字符。
                  example: registry-auth-id
                entrypoint:
                  type: string
                  description: 容器 entrypoint。
                  example: ''
                command:
                  type: string
                  description: 容器启动命令。
                  example: ''
                envs:
                  type: array
                  description: 环境变量列表。
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        description: 环境变量名。字符串,长度限制:0-511 字符。
                        example: ENV_NAME
                      value:
                        type: string
                        description: 环境变量值。字符串,长度限制:0-4095 字符。
                        example: ENV_VALUE
                ports:
                  type: array
                  description: 暴露端口列表。
                  items:
                    type: object
                    required:
                      - port
                      - protocol
                    properties:
                      port:
                        type: integer
                        description: 端口号。整数,取值范围:[1, 65535]。
                        example: 8080
                      protocol:
                        type: string
                        enum:
                          - tcp
                          - http
                        description: 端口协议。可选值:`tcp`、`http`。
                        example: tcp
                network:
                  type: object
                  description: VPC 网络配置。
                  properties:
                    id:
                      type: string
                      description: Network VPC ID。字符串,长度限制:0-255 字符。
                      example: vpc-550e8400-e29b-41d4-a716-446655440000
                    ip:
                      type: string
                      description: VPC 给实例分配的 IP。
                      example: 10.2.1.1
                volumes:
                  type: array
                  description: 数据盘/网络存储挂载列表。
                  items:
                    type: object
                    required:
                      - type
                    properties:
                      type:
                        type: string
                        enum:
                          - local
                          - network
                        description: 存储类型。可选值:`local`、`network`。
                        example: network
                      id:
                        type: string
                        description: 存储 ID,通常用于 `network` 类型。字符串,长度限制:0-255 字符。
                        example: network-storage-id
                      mount_point:
                        type: string
                        description: 挂载路径。字符串,长度限制:0-4095 字符。
                        example: /data
                candidate_regions:
                  type: array
                  items:
                    type: string
                  description: 候选调度区域列表。最终只会调度到其中一个区域。
                  example:
                    - region-id
                tools:
                  type: object
                  description: 实例工具配置。当前仅支持 Jupyter。
                  properties:
                    jupyter:
                      type: object
                      description: Jupyter 工具配置。
                      properties:
                        enabled:
                          type: boolean
                          description: 是否启用 Jupyter。
                          example: true
                        port:
                          type: integer
                          description: Jupyter 端口。整数,取值范围:[1, 65535]。
                          example: 8888
                        protocol:
                          type: string
                          description: Jupyter 协议。
                          example: http
                auto_migrate:
                  type: object
                  description: 自动迁移配置。
                  properties:
                    enabled:
                      type: boolean
                      description: 是否开启自动迁移。
                      example: false
                    include_system_disk:
                      type: boolean
                      description: 自动迁移时是否包含系统盘。
                      example: false
      responses:
        '200':
          description: 创建成功
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: 创建成功后的实例 ID
                    example: ca338f12f3

````