Registering LLM providers in code view

Register LLM provider resources in IBM API Studio by editing YAML files in code view.

You can use code view to:
  • Review resources generated from form view.
  • Create or modify LLM provider definitions manually.

When you create an LLM provider in the form view, IBM API Studio automatically generates the LLM API, policy, product, and quota KIND files required to process and manage LLM requests.

The generated resources for LLM provider are as follows:

Table 1. Generated resources
kind Description
LLM provider core resources
kind: LLMProvider Defines the provider configuration, supported operations, authentication, and cache settings.
kind: MCPTools Defines the tools that clients can invoke through the MCP server.
LLM policy resources
kind: FreeFlowPolicySequence Defines the main request processing flow in the Build assembly.
kind: OperationSwitch Routes requests to the appropriate invoke policy based on the provider operation.
Invoke policy resources
kind: InvokeWatsonxModels

kind: InvokeWatsonxTokenize

kind: InvokeWatsonxTextGen

Invokes Watsonx.ai LLM provider operations.
kind: InvokeOpenAiModels

kind: InvokeOpenAiModelsId

kind: InvokeOpenAiEmbeddings

kind: InvokeOpenAiChatCompletions

Invokes OpenAI and OpenAI-compatible LLM provider operations.
kind: InvokeAzureOpenAiModels

kind: InvokeAzureOpenAiModelsId

kind: InvokeAzureOpenAiEmbeddings

kind: InvokeAzureOpenAiChatCompletions

Invokes Azure OpenAI LLM provider operations.
kind: InvokeGeminiModels

kind: InvokeGeminiModelsId

kind: InvokeGeminiGenerateContent

kind: InvokeGeminiEmbedContent

kind: InvokeGeminiCountTokens

kind: InvokeGeminiBatchEmbedContents

Invokes Gemini LLM provider operations.
Authentication and authorization policies

kind: ExtractIdentity

kind: Authenticate

kind: Authorize

Process identity, authentication, and access control.
kind: Telemetry Captures monitoring and analytics data.
kind: Throw Handles LLM API error responses.
kind: If Evaluates a condition and runs logic only when the condition is met.
kind: Set Sets or updates context variables used later in the flow.
LLM product and plan resources
kind: Product Defines a product that contains LLM provider APIs and associated policies.
kind: Plan Defines pricing, terms, and access control mechanisms.
kind: Quota Defines the maximum number of requests allowed within a defined time window.
Open API resources
API Defines the generated LLM API resource for provider operations.
OpenAPI specification Defines the generated LLM API operations and endpoints.

Create or modify an LLM provider kind file

The kind field specifies the type of asset that is defined. When you set the kind field to LLMProvider, it indicates that the file represents an LLMProvider configuration. An LLM provider defines how LLM providers (such as Watson.ai, OpenAI) are securely connected and invoked. It includes provider metadata, supported operations, authentication, caching behavior, and product association.

To check the generated LLM provider specifications in the Code view,
  1. In IBM API Studio, go to the Explorer.
  2. Expand LLM providers and select the registered LLM provider.
  3. Switch to the Code view.
  4. In the project files, open the LLM_provider.yaml file.
LLM provider configuration example
kind: LLMProvider
apiVersion: api.ibm.com/v1
metadata:
  name: watsonx-conn-sample
  namespace: DPNano_Product_LLM_Provider
  version: "1.0"
  tags: []
  labels:
    gatewayTypes:
      - nano
  domain: ai-platform
spec:
  provider:
    type: watsonx
    operations:
      - InvokeWatsonxModels
      - InvokeWatsonxTextGen
      - InvokeWatsonxTokenize
    apiKeySecret: watsonx-api-key
    tlsClientProfile: tls-client-profile-default:1.0.0
    inputMessage: request
    cachePolicy:
      cache:
        expire:
          static:
            seconds: 60
        scope:
          narrowScope: {}
        ignoreControlDirectives: true
    projectId: placeholder-project-id
    region: us-south
    opVersion: "2024-03-14"
  product:
    $ref: DPNano_Product_LLM_Provider:product-watsonx-conn-sample-p2k4a:1.0
Note: The LLMProvider kind file values take precedence over individual policy kind file values. Therefore, you must modify only the LLMProvider kind file.
Table 2. LLM provider field descriptions
Category Field Description
  kind Defines the type of asset. The value LLMProvider indicates that the file represents an LLM provider configuration.
metadata.

Identifies and organizes the LLM provider with essential tags and identifiers.

name Identifies the LLM provider. The name must be unique within the namespace.
namespace Identifies the project that contains the LLM provider.
version Specifies the LLM provider version for tracking changes.
tags Assigns keywords to the MCP server for categorizing and filtering LLM providers.
labels gatewayTypes specifies supported nanogateway environment.
domain Specifies the functional domain: ai-platform.
spec.

Defines the structure and behavior of the LLM provider.

title MCP server name visible to users and AI agents when browsing MCP assets.
description Describes the purpose and capabilities of the MCP server.
protocolVersion Specifies the supported MCP version.
type Specifies the LLM provider type (for example, watsonx).
operations Lists supported LLM provider operations that can be invoked (for example, text generation, tokenization, or model listing).
apiKeySecret References the secret that stores the API key used for authentication.
tlsClientProfile References the TLS client profile used for secure communication with the provider.
inputMessage Specifies the request payload field that contains the input prompt or message.
cachePolicy Defines caching behavior for responses from the provider.
projectId Specifies the project identifier associated with the LLM provider (for example, Watsonx project ID).
region Specifies the service region (for example, us-south).
opVersion Specifies the version of the LLM provider API operations.
cachePolicy Defines caching rules applied to LLM responses.

cache.expire.static.seconds - Defines how long cached responses are retained (in seconds).

cache.scope - Defines the scope of caching (for example, narrowScope).

cache.ignoreControlDirectives - Specifies whether cache control headers from upstream responses are ignored.

product References the product that exposes the LLM provider. The format is namespace:product_name:version.