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

# 修改 Key 预算

> 修改预算控制；修改 budget 不补充当前剩余额度，补充时显式设置 remaining。清除预算须设 resetPeriod=none、remaining=null，周期预算必须大于零。



## OpenAPI

````yaml /openapi.cn.json patch /v1/manage/keys/{id}/budget
openapi: 3.1.0
info:
  title: OmniRelay API
  version: 1.0.0
  description: 面向已核验真实文本模型的兼容 OpenAI 网关。访问按工作空间开通，使用自己的模型列表查询能力与客户价格。
servers:
  - url: https://api.omnirelay.ai
security:
  - bearerAuth: []
tags:
  - name: 服务
  - name: 模型
  - name: 对话
  - name: 管理 API
  - name: 响应
  - name: 向量
  - name: 图片
  - name: 视频
paths:
  /v1/manage/keys/{id}/budget:
    patch:
      tags:
        - 管理 API
      summary: 修改 Key 预算
      description: >-
        修改预算控制；修改 budget 不补充当前剩余额度，补充时显式设置 remaining。清除预算须设
        resetPeriod=none、remaining=null，周期预算必须大于零。
      operationId: managementUpdateKeyBudget
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[A-Za-z0-9-]{1,80}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ManagementBudgetUpdate'
            example:
              budget: 50000000
              remaining: 50000000
              resetPeriod: monthly
      responses:
        '200':
          description: 请求成功。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagementOk'
              example:
                ok: true
        '400':
          description: JSON、输入、标签、模型规则、到期时间或预算规则无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: unauthorized 或 management_key_required。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: insufficient_scope 或 forbidden。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: not_found：路径不存在或 Key 不属于调用者。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: key_changed：发生并发修改，读取当前状态后再决定是否重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: payload_too_large：HTTP 请求体超过 16000 字符。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: rate_limited：每个管理密钥每分钟 120 次，还可能受所有者额外限流约束。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - managementAuth: []
components:
  schemas:
    ManagementBudgetUpdate:
      type: object
      properties:
        budget:
          type: integer
          nullable: true
          minimum: 0
          maximum: 1000000000000
        remaining:
          type: integer
          nullable: true
          minimum: 0
          maximum: 1000000000000
        resetPeriod:
          type: string
          enum:
            - none
            - daily
            - weekly
            - monthly
      additionalProperties: false
      minProperties: 1
    ManagementOk:
      type: object
      properties:
        ok:
          type: boolean
      required:
        - ok
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - type
          properties:
            code:
              type: string
              example: model_unavailable
            message:
              type: string
              example: The model does not exist or is disabled.
              description: 用于日志和 SDK 异常的简短英文说明；措辞可能调整，请按 code 判断。
            type:
              type: string
              example: not_found_error
              description: >-
                按 HTTP
                状态划分的错误类别：invalid_request_error、authentication_error、insufficient_quota、permission_error、not_found_error、conflict_error、rate_limit_error、service_unavailable
                或 api_error。
            param:
              type: string
              maxLength: 200
              description: 可识别时返回被拒绝的请求字段路径，不包含参数值；Responses 使用原生字段名。
        request_id:
          type: string
          description: 在对话补全、Responses 和 Embeddings 出错时返回。
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 在 OmniRelay 控制台创建的 API Key。所有者确认身份后可在控制台再次查看。
    managementAuth:
      type: http
      scheme: bearer
      description: 在控制台创建的管理密钥；read 可读取，write 还可修改 API Key。不接受推理 API Key。

````

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