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

> Update the AI Gateway configuration for the authenticated account. Omitted fields preserve their existing stored value.

# Update AI Gateway configuration



## OpenAPI

````yaml openapi/ai-gateway.yaml PATCH /gateway-config
openapi: 3.0.3
info:
  title: AI Gateway APIs
  version: 0.1.0
  description: |
    Control-plane HTTP APIs served by the ai-gateway-control service.
servers:
  - url: https://api.ngrok.ai
security:
  - bearerAuth: []
tags:
  - name: AI Gateway Access Key Configurations
    description: Manage reusable access key configurations (scope and routing rules).
  - name: AI Gateway Access Keys
    description: Manage ngrok-managed access keys associated with AI Gateway endpoints.
  - name: AI Gateway Configuration
    description: >-
      Manage per-account AI Gateway configuration (timeouts, token caps,
      metadata).
  - name: AI Gateway API Keys
    description: Manage customer-facing AI Gateway API Keys.
  - name: AI Gateway Credits
    description: Purchase AI Gateway credits via Stripe Checkout.
  - name: AI Gateway Providers
    description: Manage AI Gateway providers and the models they expose.
  - name: AI Gateway Custom Providers
    description: Manage custom AI Gateway providers and the models they expose.
  - name: AI Gateway Provider Keys
    description: Manage provider keys attached to AI Gateway managed access keys.
  - name: AI Gateway Usage
    description: >-
      Read-only AI Gateway usage events and aggregated usage overview for the
      authenticated account.
paths:
  /gateway-config:
    patch:
      tags:
        - AI Gateway Configuration
      summary: Update AI Gateway configuration
      description: >-
        Update the AI Gateway configuration for the authenticated account.
        Omitted fields preserve their existing stored value.
      operationId: UpdateAIGatewayConfig
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AIGatewayConfigUpdate'
      responses:
        '200':
          description: The updated AI Gateway configuration.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIGatewayConfig'
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    AIGatewayConfigUpdate:
      type: object
      additionalProperties: false
      properties:
        totalTimeout:
          type: string
          description: >-
            Total timeout duration for a request through the AI Gateway (Go
            duration string, e.g. `30s`, `1m`).
        perRequestTimeout:
          type: string
          description: >-
            Per-request timeout duration for individual upstream requests (Go
            duration string, e.g. `30s`, `1m`).
        maxInputTokens:
          type: integer
          format: int64
          nullable: true
          description: |
            Maximum number of input tokens allowed per request.
            PATCH: omit to preserve, send `null` to clear the cap (no
            limit), or send a number to set it. Accounts that have not
            written a value read back the per-account default; once
            cleared with `null`, GET returns `null` until a new value is
            written.
          x-go-type: gatewayconfig.NullableInt64
          x-go-type-import:
            name: gatewayconfig
            path: go.ngrok.com/svc/ai-gateway-control/gatewayconfig
          x-go-type-skip-optional-pointer: true
        maxOutputTokens:
          type: integer
          format: int64
          nullable: true
          description: |
            Maximum number of output tokens allowed per request.
            PATCH: omit to preserve, send `null` to clear the cap (no
            limit), or send a number to set it. Accounts that have not
            written a value read back the per-account default; once
            cleared with `null`, GET returns `null` until a new value is
            written.
          x-go-type: gatewayconfig.NullableInt64
          x-go-type-import:
            name: gatewayconfig
            path: go.ngrok.com/svc/ai-gateway-control/gatewayconfig
          x-go-type-skip-optional-pointer: true
        metadata:
          type: string
          maxLength: 4096
          nullable: true
          description: |
            Arbitrary user-defined metadata for the AI Gateway configuration.
            PATCH: omit to preserve, send `null` to clear, or send a string
            to set it. GET returns `null` when no value is stored.
          x-go-type: gatewayconfig.NullableString
          x-go-type-import:
            name: gatewayconfig
            path: go.ngrok.com/svc/ai-gateway-control/gatewayconfig
          x-go-type-skip-optional-pointer: true
    AIGatewayConfig:
      type: object
      additionalProperties: false
      required:
        - accountId
        - uri
        - totalTimeout
        - perRequestTimeout
      properties:
        accountId:
          type: string
          description: Unique identifier of the account this configuration belongs to.
        uri:
          type: string
          description: URI of this AI Gateway Configuration API resource.
        totalTimeout:
          type: string
          description: >-
            Total timeout duration for a request through the AI Gateway (Go
            duration string, e.g. `30s`, `1m`).
        perRequestTimeout:
          type: string
          description: >-
            Per-request timeout duration for individual upstream requests (Go
            duration string, e.g. `30s`, `1m`).
        maxInputTokens:
          type: integer
          format: int64
          nullable: true
          description: |
            Maximum number of input tokens allowed per request.
            PATCH: omit to preserve, send `null` to clear the cap (no
            limit), or send a number to set it. Accounts that have not
            written a value read back the per-account default; once
            cleared with `null`, GET returns `null` until a new value is
            written.
          x-go-type: gatewayconfig.NullableInt64
          x-go-type-import:
            name: gatewayconfig
            path: go.ngrok.com/svc/ai-gateway-control/gatewayconfig
          x-go-type-skip-optional-pointer: true
        maxOutputTokens:
          type: integer
          format: int64
          nullable: true
          description: |
            Maximum number of output tokens allowed per request.
            PATCH: omit to preserve, send `null` to clear the cap (no
            limit), or send a number to set it. Accounts that have not
            written a value read back the per-account default; once
            cleared with `null`, GET returns `null` until a new value is
            written.
          x-go-type: gatewayconfig.NullableInt64
          x-go-type-import:
            name: gatewayconfig
            path: go.ngrok.com/svc/ai-gateway-control/gatewayconfig
          x-go-type-skip-optional-pointer: true
        metadata:
          type: string
          maxLength: 4096
          nullable: true
          description: |
            Arbitrary user-defined metadata for the AI Gateway configuration.
            PATCH: omit to preserve, send `null` to clear, or send a string
            to set it. GET returns `null` when no value is stored.
          x-go-type: gatewayconfig.NullableString
          x-go-type-import:
            name: gatewayconfig
            path: go.ngrok.com/svc/ai-gateway-control/gatewayconfig
          x-go-type-skip-optional-pointer: true
    Error:
      type: object
      additionalProperties: false
      required:
        - statusCode
        - msg
        - details
      properties:
        errorCode:
          type: string
          description: Stable ngrok error code when available.
        statusCode:
          type: integer
          format: int32
          description: HTTP status code for this error.
        msg:
          type: string
          description: Human-readable error message.
        details:
          type: object
          description: Structured error details.
          additionalProperties:
            type: string
  responses:
    Error:
      description: API error response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````