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

# Validate Llm Connection

> Validate an LLM provider API key and model availability.

Two callable shapes:

- **Inline** - raw ``apiKey`` + optional ``baseUrl`` supplied directly.
  Used when the user is pasting a fresh key in the form.
- **Saved connection** - ``savedConnectionId`` references a stored
  ``llmConnection``; BE loads the decrypted ``apiKey`` + ``baseUrl`` +
  ``provider`` server-side so the browser never holds the plaintext.

Calls the provider's free list-models endpoint to check key validity
and model existence. The "apiKey required unless ollama or saved" rule
is enforced by the request model's ``@model_validator``.
Per-tenant rate limit: 30 req/min/bucket -> 429 with ``Retry-After``.



## OpenAPI

````yaml /openapi/openapi.json post /agents/validate-llm
openapi: 3.1.0
info:
  title: Streamkap REST API
  description: >-
    The Streamkap REST API allows you to programmatically manage your CDC
    pipelines, sources, destinations, transforms, and more.


    Authenticate using a bearer token obtained from the [Access
    Token](/api-reference/auth/access-token) endpoint with your API client
    credentials.
  contact:
    name: Streamkap Support
    url: https://streamkap.com/
    email: support@streamkap.com
  license:
    name: Proprietary
  version: 2.0.0
servers:
  - url: https://api.streamkap.com
    description: Production
security: []
tags:
  - name: Agents
    description: Create, deploy, and manage Flink-based AI agents.
  - name: Agents Observability
    description: >-
      Read-only views over the MCP audit log: agent rollup, sessions, spans,
      histograms, external-agent verify.
  - name: Alerts
    description: Manage alert subscribers, preferences, and notification credentials.
  - name: Authentication
    description: Obtain and refresh access tokens, manage client credentials and roles.
  - name: Billing
    description: Retrieve usage metrics, summaries, and export billing data.
  - name: Consumer Groups
    description: List, inspect, and reset Kafka consumer group offsets.
  - name: Dashboard
    description: Retrieve organisation-level statistics and overview data.
  - name: Destinations
    description: Create, configure, and manage data destinations and their lifecycle.
  - name: Kafka Access
    description: Manage Kafka users and their access permissions.
  - name: Logs
    description: Query and summarise system logs.
  - name: Pipelines
    description: Create, configure, and manage CDC pipelines and their lifecycle.
  - name: Project Keys
    description: Manage project keys that bundle API credentials and optional Kafka access.
  - name: Schema Registry
    description: Browse schema subjects, versions, and retrieve schema definitions.
  - name: Services
    description: View and switch service metadata.
  - name: Sources
    description: >-
      Create, configure, and manage data sources, snapshots, and their
      lifecycle.
  - name: Tags
    description: Create, update, and manage resource tags for organisation.
  - name: Topics
    description: Browse topic details, statistics, configurations, metrics, and messages.
  - name: Transforms
    description: >-
      Create, deploy, and manage data transforms, unit tests, and implementation
      details.
paths:
  /agents/validate-llm:
    post:
      tags:
        - Agents
      summary: Validate Llm Connection
      description: |-
        Validate an LLM provider API key and model availability.

        Two callable shapes:

        - **Inline** - raw ``apiKey`` + optional ``baseUrl`` supplied directly.
          Used when the user is pasting a fresh key in the form.
        - **Saved connection** - ``savedConnectionId`` references a stored
          ``llmConnection``; BE loads the decrypted ``apiKey`` + ``baseUrl`` +
          ``provider`` server-side so the browser never holds the plaintext.

        Calls the provider's free list-models endpoint to check key validity
        and model existence. The "apiKey required unless ollama or saved" rule
        is enforced by the request model's ``@model_validator``.
        Per-tenant rate limit: 30 req/min/bucket -> 429 with ``Retry-After``.
      operationId: validateLlmConnection
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidateLlmRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Validatellmconnection
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - FronteggHTTPAuthentication: []
components:
  schemas:
    ValidateLlmRequest:
      properties:
        provider:
          $ref: '#/components/schemas/AgentLlmProviderEnum'
        model:
          type: string
          maxLength: 200
          title: Model
          default: ''
        apiKey:
          type: string
          maxLength: 512
          title: Apikey
          description: Raw key - never stored
          default: ''
        baseUrl:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
          title: Baseurl
        savedConnectionId:
          anyOf:
            - type: string
              maxLength: 100
            - type: 'null'
          title: Savedconnectionid
          description: >-
            If set, BE resolves provider/apiKey/baseUrl from the tenant's saved
            llmConnection by id and ignores the inline ``apiKey`` / ``baseUrl``.
      additionalProperties: false
      type: object
      required:
        - provider
      title: ValidateLlmRequest
      description: |-
        Request body for POST /agents/validate-llm.

        Two callable shapes:

        1. **Inline** - ``apiKey`` (+ optional ``baseUrl``) supplied directly.
           Used when the user is pasting a fresh key in the form.
        2. **Saved connection** - ``savedConnectionId`` references a row in
           ``agent_connections.llmConnections``. The BE loads the decrypted
           ``apiKey`` / ``baseUrl`` server-side so the browser never has to
           hold (or re-send) a stored plaintext to test it. Mirrors the MCP
           ``savedConnectionId`` discovery path.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentLlmProviderEnum:
      type: string
      enum:
        - anthropic
        - openai
        - openai-responses
        - ollama
        - azure
        - azure-openai
        - bedrock
        - qwen
        - openai-compatible
      title: AgentLlmProviderEnum
      description: >-
        Unified LLM provider enum.


        A single ``AgentLlmConnection`` row carries one provider and a set of

        capabilities (chat / embedding). ``PROVIDER_CAPABILITIES`` below pins

        which capabilities each provider can serve — picked by the FE
        Connections

        drawer and re-validated server-side on every write.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    FronteggHTTPAuthentication:
      type: http
      scheme: bearer

````