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

# Update Model Gateway credentials

> Stores one or both OpenRouter credentials as encrypted reserved secrets in a self-hosted deployment. Credentials are independent and may be updated separately.



## OpenAPI

````yaml https://raw.githubusercontent.com/InsForge/InsForge/main/openapi/ai.yaml put /api/ai/config
openapi: 3.0.3
info:
  title: Insforge AI API
  version: 1.0.0
  description: >-
    Model Gateway helper APIs for OpenRouter key provisioning, model discovery,
    and deprecated compatibility proxy routes
servers: []
security: []
paths:
  /api/ai/config:
    put:
      tags:
        - Admin
      summary: Update Model Gateway credentials
      description: >-
        Stores one or both OpenRouter credentials as encrypted reserved secrets
        in a self-hosted deployment. Credentials are independent and may be
        updated separately.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateModelGatewayConfig'
      responses:
        '200':
          description: Updated masked Model Gateway credential status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModelGatewayConfig'
        '400':
          description: Invalid payload or configuration is managed by InsForge Cloud
        '401':
          description: Unauthorized
        '500':
          description: Failed to update encrypted credentials
      security:
        - bearerAuth: []
components:
  schemas:
    UpdateModelGatewayConfig:
      type: object
      minProperties: 1
      properties:
        apiKey:
          type: string
          minLength: 1
          maxLength: 512
          pattern: .*\S.*
          description: OpenRouter API key used for model requests.
        managementKey:
          type: string
          minLength: 1
          maxLength: 512
          pattern: .*\S.*
          description: OpenRouter management API key used only for activity analytics.
    ModelGatewayConfig:
      type: object
      required:
        - apiKey
        - managementKey
      properties:
        apiKey:
          $ref: '#/components/schemas/ModelGatewayCredentialStatus'
        managementKey:
          $ref: '#/components/schemas/ModelGatewayCredentialStatus'
    ModelGatewayCredentialStatus:
      type: object
      required:
        - configured
        - maskedKey
      properties:
        configured:
          type: boolean
          description: >-
            Whether the credential resolves from encrypted settings or the
            supported API-key environment fallback.
        maskedKey:
          type: string
          nullable: true
          description: Masked credential for display, or null when it is not configured.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````