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

# Set or update API key for a provider

> Stores or replaces the API key for a single provider (anthropic, openai, google) on the organization's credentials. SUPERADMIN-only and tenant-scoped — callers cannot set keys for organizations they do not belong to. For backward compatibility, the legacy anthropicApiKey field is mirrored when provider=anthropic.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/ai-models/organization/{organizationId}/api-key
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/ai-models/organization/{organizationId}/api-key:
    post:
      tags:
        - AI Models
      summary: Set or update API key for a provider
      description: >-
        Stores or replaces the API key for a single provider (anthropic, openai,
        google) on the organization's credentials. SUPERADMIN-only and
        tenant-scoped — callers cannot set keys for organizations they do not
        belong to. For backward compatibility, the legacy anthropicApiKey field
        is mirrored when provider=anthropic.
      operationId: set_provider_api_key
      parameters:
        - in: path
          name: organizationId
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetProviderApiKeyRequest'
      responses:
        '200':
          description: API key updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetProviderApiKeyResponse'
        '400':
          description: Invalid provider or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiModelsErrorResponse'
        '403':
          description: Only superadmins can configure AI provider credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiModelsErrorResponse'
        '500':
          description: Failed to set API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiModelsErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    SetProviderApiKeyRequest:
      type: object
      properties:
        provider:
          type: string
          enum:
            - anthropic
            - openai
            - google
          description: >-
            Provider whose key is being set, identified by its
            `vercelUniqueName`.
        apiKey:
          type: string
          description: >-
            Provider API key; stored encrypted and never returned in GET
            responses.
        isEnabled:
          type: boolean
          description: >-
            Whether the provider should be active immediately after the key is
            stored. Defaults to `true` when omitted.
      required:
        - provider
        - apiKey
      additionalProperties: true
      example:
        provider: anthropic
        apiKey: sk-ant-api03-AbCdEf1234567890XyZ
        isEnabled: true
    SetProviderApiKeyResponse:
      type: object
      description: Returned after a provider API key is set or updated.
      properties:
        success:
          type: boolean
          enum:
            - true
        message:
          type: string
        data:
          type: object
          properties:
            provider:
              type: string
              enum:
                - anthropic
                - openai
                - google
            isEnabled:
              type: boolean
            hasApiKey:
              type: boolean
              enum:
                - true
          required:
            - provider
            - isEnabled
            - hasApiKey
          additionalProperties: true
      required:
        - success
        - message
        - data
      additionalProperties: true
      example:
        success: true
        message: API key for anthropic updated successfully
        data:
          provider: anthropic
          isEnabled: true
          hasApiKey: true
    AiModelsErrorResponse:
      type: object
      description: >-
        Error envelope returned by AI Models endpoints. `error` may be present
        on contract-validation failures.
      properties:
        success:
          type: boolean
          enum:
            - false
        message:
          type: string
        error:
          description: >-
            Optional error detail (string or structured object on validation
            failures).
      required:
        - success
      additionalProperties: true
      example:
        success: false
        message: Organization credentials not found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````