openapi: 3.1.0
info:
  title: AI Optimizer for Z - Providers Info API
  description: |
    API for managing remote LLM provider instances in AI Optimizer for Z.
    Use this API to register, retrieve, and delete provider configurations
    for LLM services such as watsonx.ai, OpenAI, Amazon Bedrock, and others.
    
    **Important Security Requirements**:
    - All provider URLs must use HTTPS with port 443 (default HTTPS port) due to firewall configuration requirements.
    - The HTTPS endpoint must present a certificate issued by a commonly trusted public CA.
  version: "3.1.2"
  contact:
    name: IBM AI Optimizer for Z
    url: https://www.ibm.com/products/ai-optimizer-for-z

servers:
  - url: https://{LPAR_URL}/aioui/api/proxy
    description: AI Optimizer for Z LPAR
    variables:
      LPAR_URL:
        default: localhost
        description: The LPAR URL or IP address

security:
  - CookieAuth: []

paths:
  /?key=providersInfo:
    post:
      summary: Register a new provider instance
      description: |
        Register a new remote LLM provider instance. The provider type determines
        which configuration fields are required in the `data` section.
        
        Supported provider types:
        - `watsonxai` - IBM watsonx.ai
        - `openai` - OpenAI
        - `anthropic` - Anthropic Claude
        - `bedrock` - Amazon Bedrock
        - `azure-openai` - Azure OpenAI
        - `cohere` - Cohere
        - `gemini` - Google Gemini
        - `groq` - Groq
        - `mistral` - Mistral AI
        - `xai` - xAI
        - `ollama` - Ollama
        - `nim` - NVIDIA NIM
        - `cerebras` - Cerebras
        - `adobe-firefly` - Adobe Firefly
        - `wxai-router` - watsonx.ai Router
      operationId: createProvider
      tags:
        - Providers
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - type
                - data
              properties:
                name:
                  type: string
                  description: |
                    The provider instance name. Can only contain alphanumeric characters,
                    single spaces (no consecutive spaces), underscores (_), hyphens (-),
                    parentheses (), and square brackets []. No leading or trailing spaces.
                  example: watsonx-provider-instance
                type:
                  type: string
                  description: The provider type
                  enum:
                    - watsonxai
                    - openai
                    - anthropic
                    - bedrock
                    - azure-openai
                    - cohere
                    - gemini
                    - groq
                    - mistral
                    - xai
                    - ollama
                    - nim
                    - cerebras
                    - adobe-firefly
                    - wxai-router
                  example: watsonxai
                data:
                  type: object
                  description: |
                    Provider-specific configuration data. The structure varies based on
                    the provider type. See the schemas section for detailed configurations
                    for each provider type.
                  oneOf:
                    - $ref: '#/components/schemas/watsonxai.Config'
                    - $ref: '#/components/schemas/openai.Config'
                    - $ref: '#/components/schemas/anthropic.Config'
                    - $ref: '#/components/schemas/bedrock.Config'
                    - $ref: '#/components/schemas/azure-openai.Config'
                    - $ref: '#/components/schemas/cohere.Config'
                    - $ref: '#/components/schemas/gemini.Config'
                    - $ref: '#/components/schemas/groq.Config'
                    - $ref: '#/components/schemas/mistral.Config'
                    - $ref: '#/components/schemas/xai.Config'
                    - $ref: '#/components/schemas/ollama.Config'
                    - $ref: '#/components/schemas/nim.Config'
                    - $ref: '#/components/schemas/cerebras.Config'
                    - $ref: '#/components/schemas/adobe-firefly.Config'
                    - $ref: '#/components/schemas/wxai-router.Config'
            examples:
              watsonxai:
                summary: watsonx.ai provider
                value:
                  name: watsonx-provider-instance
                  type: watsonxai
                  data:
                    apikey: <API_KEY>
                    base_url: https://us-south.ml.cloud.ibm.com
                    project_id: <PROJECT_ID>
              openai:
                summary: OpenAI provider
                value:
                  name: openai-provider-instance
                  type: openai
                  data:
                    apikey: sk-...
                    base_url: https://api.openai.com/v1
              anthropic:
                summary: Anthropic provider
                value:
                  name: anthropic-provider-instance
                  type: anthropic
                  data:
                    apikey: sk-ant-api03-...
      responses:
        '200':
          description: Provider successfully created
          content:
            application/json:
              schema:
                type: object
                properties:
                  uuid:
                    type: string
                    description: The unique identifier for the created provider
                    example: 550e8400-e29b-41d4-a716-446655440000
                  name:
                    type: string
                    example: watsonx-provider-instance
                  type:
                    type: string
                    example: watsonxai
        '400':
          description: Bad request - Invalid provider configuration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid or missing authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflict - Provider with this name already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

    get:
      summary: List all provider instances
      description: Retrieve a list of all registered provider instances
      operationId: listProviders
      tags:
        - Providers
      responses:
        '200':
          description: List of providers
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProviderInfo'
        '401':
          description: Unauthorized - Invalid or missing authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

    delete:
      summary: Delete a provider instance
      description: |
        Delete a registered provider instance by name. A provider cannot be deleted
        if one or more models are still associated with it. Delete the associated
        models first, then delete the provider.
      operationId: deleteProvider
      tags:
        - Providers
      parameters:
        - name: name
          in: query
          required: true
          schema:
            type: string
          description: The name of the provider instance to delete
          example: watsonx-provider-instance
      responses:
        '200':
          description: Provider successfully deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Provider deleted successfully
        '400':
          description: Bad request - Provider has associated models
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid or missing authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Provider not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

components:
  securitySchemes:
    CookieAuth:
      type: apiKey
      in: cookie
      name: auth_token
      description: Authentication token obtained from the zACI system API

  schemas:
    # Provider Info Response
    ProviderInfo:
      type: object
      properties:
        uuid:
          type: string
          description: Unique identifier for the provider
          example: 550e8400-e29b-41d4-a716-446655440000
        name:
          type: string
          description: Provider instance name
          example: watsonx-provider-instance
        type:
          type: string
          description: Provider type
          example: watsonxai
        created_at:
          type: string
          format: date-time
          description: Timestamp when the provider was created
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the provider was last updated

    # Error Response
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Error message
              example: Invalid provider configuration
            code:
              type: string
              description: Error code
              example: INVALID_CONFIG

    # Provider-specific configurations
    watsonxai.Config:
      type: object
      description: Configuration for IBM watsonx.ai provider
      required:
        - apikey
        - base_url
      properties:
        apikey:
          type: string
          description: The required authentication key for accessing WatsonX.ai services.
          example: AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe
        base_url:
          type: string
          description: |
            Overrides the URL to use to access the IBM WatsonX.ai services.
            Must use HTTPS with port 443 (default HTTPS port) due to firewall rules.
          example: https://us-south.ml.cloud.ibm.com
        api_version:
          type: string
          description: Overrides the WatsonX.ai API version to use.
          default: "2023-07-07"
          example: "2023-07-07"
        auth_url:
          type: string
          description: Overrides the URL to use for IBM Cloud IAM authentication.
          default: https://iam.cloud.ibm.com/identity/token
          example: https://iam.cloud.ibm.com/identity/token
        project_id:
          type: string
          description: The IBM WatsonX.ai project ID (required if space_id is not provided).
          example: 09b2r701-4592-4386-85cf-326c6b3c94c7
        space_id:
          type: string
          description: The IBM WatsonX.ai space ID (required if project_id is not provided).
          example: q9b2d701-4592-4386-85cf-326c6b3c94c7

    openai.Config:
      type: object
      description: Configuration details for an OpenAI provider.
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: The required authentication key for accessing the OpenAI API.
          example: sk-proj-2_IN3221...IWZkA
        base_url:
          type: string
          description: |
            Override the URL used to access the OpenAI provider services. This URL can point to any OpenAI-compatible model provider service.
            Must use HTTPS with port 443 (default HTTPS port) due to firewall rules.
          default: https://api.openai.com/v1
          example: https://api.openai.com/v1

    anthropic.Config:
      type: object
      description: Configuration for Anthropic Claude provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: The required authentication key for accessing the Anthropic API.
          example: sk-ant-api03-R2D...igAA

    bedrock.Config:
      type: object
      description: Configuration for Amazon Bedrock provider
      required:
        - access_key_id
        - region
        - secret_access_key
      properties:
        access_key_id:
          type: string
          description: The AWS access key ID required to authenticate with the Bedrock API.
          example: acde070d-8c4c-4f0d-9d8a-162843c10333
        region:
          type: string
          description: The AWS region where the Bedrock API is hosted.
          example: us-east-1
        secret_access_key:
          type: string
          description: The AWS secret access key required to authenticate with the Bedrock API.
          example: AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe
        base_url:
          type: string
          description: |
            Overrides the default AWS Bedrock Runtime API endpoint with the provided URL.
            Must use HTTPS with port 443 (default HTTPS port) due to firewall rules.
          example: https://bedrock-runtime.us-east-1.amazonaws.com
        session_token:
          type: string
          description: Optional session token for temporary credentials
          example: AQoDYXdzEJr...<omitted>...HVkDR45Kg==

    azure-openai.Config:
      type: object
      description: Configuration for Azure OpenAI provider
      required:
        - api_version
        - apikey
        - resource_name
      properties:
        api_version:
          type: string
          description: Version of the Azure OpenAI API to use.
          default: "2024-10-21"
          example: "2024-10-21"
        apikey:
          type: string
          description: The required authentication key for accessing Azure OpenAI services.
          example: AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe
        resource_name:
          type: string
          description: The Azure OpenAI resource to connect to.
          example: my-resource-name
        account_name:
          type: string
          description: The Azure account name; required to use /v1/provider/{provider_uuid}/models.
          example: my-azure-account
        resource_group_name:
          type: string
          description: The Azure resource group name; required to use /v1/provider/{provider_id}/models.
          example: my-resource-group
        subscription_id:
          type: string
          description: The Azure subscription ID; required to use /v1/provider/{provider_id}/models.
          example: acde070d-8c4c-4f0d-9d8a-162843c10333

    cohere.Config:
      type: object
      description: Configuration for Cohere provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: Required authentication key for accessing the Cohere API
          example: your-cohere-api-key

    gemini.Config:
      type: object
      description: Configuration for Google Gemini provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: The required Google AI Studio API key for accessing the Gemini API.
          example: AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe

    groq.Config:
      type: object
      description: Configuration for Groq provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: Required authentication key for accessing the Groq API
          example: gsk_...

    mistral.Config:
      type: object
      description: Configuration for Mistral AI provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: Required authentication key for accessing the Mistral API
          example: your-mistral-api-key

    xai.Config:
      type: object
      description: Configuration for xAI provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: Required authentication key for accessing the xAI API
          example: xai-...

    ollama.Config:
      type: object
      description: Configuration for Ollama provider
      required:
        - host
      properties:
        host:
          type: string
          description: |
            Ollama host URL.
            Must use HTTPS with port 443 (default HTTPS port) due to firewall rules.
          example: https://ollama.example.com
        keep_alive:
          type: integer
          description: Duration to keep models loaded in memory
          example: 300
        clean_on_close:
          type: boolean
          description: Whether to clean up resources when closing
          example: false

    nim.Config:
      type: object
      description: Configuration for NVIDIA NIM provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: The required authentication key for accessing the Nvidia NIM API.
          example: AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe

    cerebras.Config:
      type: object
      description: Configuration for Cerebras provider
      required:
        - apikey
      properties:
        apikey:
          type: string
          description: The required authentication key for accessing the Cerebras API.
          example: AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe

    adobe-firefly.Config:
      type: object
      description: Configuration for Adobe Firefly provider
      required:
        - client_id
        - client_secret
      properties:
        client_id:
          type: string
          description: Client ID for the Adobe Firefly API
          example: your-client-id
        client_secret:
          type: string
          description: Client secret for the Adobe Firefly API
          example: your-client-secret

    wxai-router.Config:
      type: object
      description: |
        Configuration for watsonx.ai Router.
        This provider type is used for routing requests through watsonx.ai.
        No additional configuration fields are required.

tags:
  - name: Providers
    description: Operations for managing remote LLM provider instances
