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

# 创建新的 API KEY

创建一个新的 API KEY。

<Note>
  注意：调用此接口需要通过[系统 KEY](https://geekai.co/user/provision_keys) 进行认证，需要创建后复制进行使用。
</Note>


## OpenAPI

````yaml adminapi.yaml POST /api_keys
openapi: 3.1.0
info:
  title: 极客智坊 API 文档
  description: 极客智坊 API KEY 管理文档 提供 API KEY 的创建、删除、修改、查询功能
  version: 1.0.0
servers:
  - url: https://geekai.co/api
    description: 国内调用入口
  - url: https://geekai.dev/api
    description: 海外调用入口
security:
  - bearerAuth: []
paths:
  /api_keys:
    post:
      tags:
        - API_KEY
      summary: 创建新的 API KEY
      description: 通过 API 创建新的 API KEY
      operationId: createApiKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - group
              properties:
                name:
                  type: string
                  description: 名称，可用于标识 API KEY 的使用场景/用途，便于后续管理/统计费用
                  default: default
                  example: geekai
                group:
                  type: string
                  description: >-
                    代理策略分组，用于区分不同的代理策略，目前支持四个策略：lowcost（低价优先）, balance（均衡）,
                    ha（高可用）, none（不使用代理）
                  enum:
                    - lowcost
                    - balance
                    - ha
                    - none
                  default: balance
                  example: balance
                credit_limit:
                  type: number
                  description: >-
                    信用额度，单位：金币（1金币=0.01元），用于限时 API KEY 的消费上限，超出额度后将无法继续使用，默认为
                    0，表示不限制信用额度
                  default: 0
                  example: 10000
                expired_at:
                  type: string
                  format: date
                  description: 过期时间，过期后将无法继续使用，默认为空，表示没有过期时间
                  default: ''
                  example: '2025-12-31'
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 创建成功后返回的 API KEY 详细信息
                    properties:
                      uuid:
                        type: string
                        description: UUID
                      name:
                        type: string
                        description: 名称
                      value:
                        type: string
                        description: 脱敏后的 API KEY 值
                      raw_value:
                        type: string
                        description: 原始 API KEY 值，调用极客智坊 API 接口请使用该值
                      group:
                        type: object
                        description: 代理策略分组
                        properties:
                          name:
                            type: string
                            description: 策略名称
                          alias:
                            type: string
                            description: 策略别名
                          desc:
                            type: string
                            description: 策略描述
                      credit_limit:
                        type: number
                        description: 信用额度
                      credit_used:
                        type: number
                        description: 已使用额度
                      expired_at:
                        type: string
                        format: date
                        description: 过期时间
                      expired:
                        type: boolean
                        description: 是否已过期
                      status:
                        type: boolean
                        description: 状态，true表示正常，false表示禁用
                      last_used_at:
                        type: string
                        format: date-time
                        description: 上次使用时间
                      created_at:
                        type: string
                        format: date-time
                        description: 创建时间
                  message:
                    type: string
                    description: 成功/失败响应消息
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/StandardError'
components:
  responses:
    ValidationError:
      description: 参数验证错误
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: validation_error
              message:
                type: string
                example: 参数验证失败
              details:
                type: object
                additionalProperties:
                  type: string
                example:
                  field: 错误描述
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 系统KEY

````