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

# Add a model API key

> Adds a model provider API key. Superlog checks the key with the provider before saving it. Every automation that uses this provider then runs on your key. Connect a ChatGPT subscription in the app.



## OpenAPI

````yaml /api-reference/openapi.json post /model-credentials
openapi: 3.1.0
info:
  description: >-
    Manage a Superlog workspace's automations, runs, tag mode, model access, and
    secrets, read its telemetry, build dashboards and alerts over it, run
    synthetic checks, and export them to Terraform. Every request acts as the
    member who created the API key.
  title: Superlog management API
  version: 1.0.0
servers:
  - url: https://superlog.sh/api/v1
security:
  - bearerAuth: []
tags:
  - description: Connected integrations and the IDs automations and tag mode use.
    name: Integrations
  - description: The workspace and its members.
    name: Workspace
  - description: Keys that authenticate the management API and MCP server.
    name: API keys
  - description: Create and change automations.
    name: Automations
  - description: Start, follow, and cancel automation runs.
    name: Runs
  - description: What Superlog can use and change when someone mentions it in Slack.
    name: Tag mode
  - description: Model API keys, subscriptions, and available models.
    name: Models
  - description: Credentials agents can use without seeing them.
    name: Secrets
  - description: Read the workspace's logs, traces, and metrics.
    name: Telemetry
  - description: >-
      Exceptions in the workspace's telemetry, grouped into issues by
      fingerprint.
    name: Errors
  - description: Create and change dashboards over the workspace's telemetry.
    name: Dashboards
  - description: Threshold alerts on the workspace's telemetry that post to Slack.
    name: Alerts
  - description: HTTP checks that request a URL on a schedule and post failures to Slack.
    name: Synthetics
  - description: Configuration for the superloglabs/superlog Terraform provider.
    name: Terraform
paths:
  /model-credentials:
    post:
      tags:
        - Models
      summary: Add a model API key
      description: >-
        Adds a model provider API key. Superlog checks the key with the provider
        before saving it. Every automation that uses this provider then runs on
        your key. Connect a ChatGPT subscription in the app.
      operationId: create_model_credential
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                apiKey:
                  type: string
                  minLength: 1
                  maxLength: 4096
                  description: The provider API key.
                label:
                  type: string
                  minLength: 1
                  maxLength: 120
                  description: A name for the key, unique within the workspace.
                provider:
                  type: string
                  enum:
                    - openai
                    - anthropic
                    - google
                    - xai
                    - mistral
                    - deepseek
              required:
                - apiKey
                - label
                - provider
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                type: object
                properties:
                  modelCredential:
                    type: object
                    properties:
                      authType:
                        type: string
                        enum:
                          - api_key
                          - chatgpt_subscription
                      createdAt:
                        type: string
                        format: date-time
                        description: When the credential was added.
                      id:
                        type: string
                        format: uuid
                        description: Model credential ID.
                      label:
                        type: string
                      lastFour:
                        type: string
                        description: The last four characters of the API key.
                      lastValidatedAt:
                        anyOf:
                          - type: string
                            format: date-time
                            description: When the credential was last tested.
                          - type: 'null'
                      provider:
                        type: string
                        enum:
                          - openai
                          - anthropic
                          - google
                          - xai
                          - mistral
                          - deepseek
                      status:
                        type: string
                        enum:
                          - active
                          - invalid
                      updatedAt:
                        type: string
                        format: date-time
                        description: When the credential was last changed.
                    required:
                      - authType
                      - createdAt
                      - id
                      - label
                      - lastFour
                      - lastValidatedAt
                      - provider
                      - status
                      - updatedAt
                    additionalProperties: false
                required:
                  - modelCredential
                additionalProperties: false
          description: Created
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The request is invalid. `issues` lists each invalid field.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The API key is missing, revoked, or its creator left the workspace.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            The resource does not exist in this workspace, or the feature it
            belongs to is not enabled.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            The request conflicts with the current state, such as a name already
            in use.
      security:
        - bearerAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        code:
          description: A stable machine-readable error code, when there is one.
          type: string
        error:
          type: string
          description: What went wrong.
        issues:
          description: Validation problems, one per invalid field.
          type: array
          items:
            type: object
            properties:
              message:
                type: string
              path:
                type: array
                items:
                  anyOf:
                    - type: string
                    - type: number
            required:
              - message
              - path
            additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      description: A workspace API key, created in Superlog under Settings → API keys.
      scheme: bearer
      type: http

````

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