> ## 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.

# Suggest Agent System Prompt

> Generate a starter ``customInstructions`` block for the wizard.

Same two credential shapes as ``/agents/validate-llm``:

- **Inline** - raw ``apiKey`` (+ optional ``baseUrl``) supplied directly.
- **Saved connection** - ``savedConnectionId`` references a stored
  ``llmConnection``; BE loads decrypted ``apiKey`` / ``baseUrl`` /
  ``provider`` server-side so the browser never holds the plaintext.

Composes a meta-system-prompt + a structured user message describing
the agent (type, name, description, topics, fields, tools, output
schema, optional existing draft) and calls the user's own LLM. The
runtime ``build_system_prompt`` already emits the per-agentType base
template + schema field listing + tool signatures at deploy time, so
the LLM is constrained to produce only the user-facing instructions
slot - the meta-prompt enforces that explicitly. Nothing is persisted.

Per-tenant rate limit: dedicated ``BUCKET_PROMPT_SUGGEST`` bucket
(30/min/tenant) separate from ``validate-llm``, so heavy "Generate"
usage (humans iterating on prompt drafts) doesn't eat into the
credential-check budget. Provider failures (timeouts, 4xx, schema
errors) surface as 400 with the provider's error message so the FE's
existing error-extraction works unchanged.



## OpenAPI

````yaml /openapi/openapi.json post /agents/system-prompt-suggestion
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/system-prompt-suggestion:
    post:
      tags:
        - Agents
      summary: Suggest Agent System Prompt
      description: >-
        Generate a starter ``customInstructions`` block for the wizard.


        Same two credential shapes as ``/agents/validate-llm``:


        - **Inline** - raw ``apiKey`` (+ optional ``baseUrl``) supplied
        directly.

        - **Saved connection** - ``savedConnectionId`` references a stored
          ``llmConnection``; BE loads decrypted ``apiKey`` / ``baseUrl`` /
          ``provider`` server-side so the browser never holds the plaintext.

        Composes a meta-system-prompt + a structured user message describing

        the agent (type, name, description, topics, fields, tools, output

        schema, optional existing draft) and calls the user's own LLM. The

        runtime ``build_system_prompt`` already emits the per-agentType base

        template + schema field listing + tool signatures at deploy time, so

        the LLM is constrained to produce only the user-facing instructions

        slot - the meta-prompt enforces that explicitly. Nothing is persisted.


        Per-tenant rate limit: dedicated ``BUCKET_PROMPT_SUGGEST`` bucket

        (30/min/tenant) separate from ``validate-llm``, so heavy "Generate"

        usage (humans iterating on prompt drafts) doesn't eat into the

        credential-check budget. Provider failures (timeouts, 4xx, schema

        errors) surface as 400 with the provider's error message so the FE's

        existing error-extraction works unchanged.
      operationId: suggestAgentSystemPrompt
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SystemPromptSuggestionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SystemPromptSuggestionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - FronteggHTTPAuthentication: []
components:
  schemas:
    SystemPromptSuggestionRequest:
      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``.
        agentType:
          type: string
          maxLength: 50
          minLength: 1
          title: Agenttype
          description: Agent type (e.g. react, workflow)
        agentName:
          anyOf:
            - type: string
              maxLength: 100
            - type: 'null'
          title: Agentname
        description:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Description
        inputTopics:
          items:
            type: string
          type: array
          maxItems: 20
          title: Inputtopics
        selectedFields:
          items:
            type: string
          type: array
          maxItems: 50
          title: Selectedfields
        tools:
          items:
            $ref: '#/components/schemas/ToolContext'
          type: array
          maxItems: 50
          title: Tools
          description: >-
            Tool name + description list. Replaces the older toolNames-only
            shape.
        outputSchema:
          items:
            $ref: '#/components/schemas/OutputSchemaField'
          type: array
          maxItems: 50
          title: Outputschema
        filterSQL:
          anyOf:
            - type: string
              maxLength: 4000
            - type: 'null'
          title: Filtersql
          description: >-
            Active record-filter (matches AgentInputConfig.filterSQL). Anchors
            the LLM's prompt to the actual shape of records reaching the agent.
        existingCustomInstructions:
          anyOf:
            - type: string
              maxLength: 8000
            - type: 'null'
          title: Existingcustominstructions
          description: Existing draft to refine. Matches the FE textarea cap.
        generationHint:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Generationhint
          description: >-
            Optional one-line steer the user types into the wizard's 'Hint for
            AI' input. The meta-prompt already gets the agent's metadata, so
            this should carry use-case intent (tone, edge-case priority, what to
            emphasize) rather than restate the data shape.
      additionalProperties: false
      type: object
      required:
        - provider
        - agentType
      title: SystemPromptSuggestionRequest
      description: >-
        Request body for ``POST /agents/system-prompt-suggestion``.


        Mirrors ``ValidateLlmRequest`` for the credential half (inline apiKey or

        savedConnectionId, with the same XOR rule) and adds the agent-context

        fields the meta-prompt needs to draft a starter ``customInstructions``

        block. The runtime ``build_system_prompt`` already injects the
        per-agentType

        base template, schema field listing, and tool signatures - so the LLM is

        asked to produce *only* the user-facing instructions slot, never the

        boilerplate wrapper. See ``app.services.agent_prompt_suggester`` for the

        meta-prompt that enforces that.
    SystemPromptSuggestionResponse:
      properties:
        generatedPrompt:
          type: string
          title: Generatedprompt
        tokensIn:
          type: integer
          title: Tokensin
        tokensOut:
          type: integer
          title: Tokensout
        model:
          type: string
          title: Model
        provider:
          type: string
          title: Provider
      additionalProperties: false
      type: object
      required:
        - generatedPrompt
        - tokensIn
        - tokensOut
        - model
        - provider
      title: SystemPromptSuggestionResponse
      description: |-
        Response body for ``POST /agents/system-prompt-suggestion``.

        Token counts come straight from the provider's ``usage`` block (zeroed
        when the provider didn't return one). ``model`` / ``provider`` echo back
        the resolved values so the FE can display "generated with anthropic /
        claude-sonnet-4-5" alongside the suggestion.
    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.
    ToolContext:
      properties:
        name:
          type: string
          maxLength: 200
          minLength: 1
          title: Name
          description: Tool name as referenced in the agent
        description:
          type: string
          maxLength: 1000
          title: Description
          description: What the tool does, free-form
          default: ''
      additionalProperties: false
      type: object
      required:
        - name
      title: ToolContext
      description: >-
        One tool entry in the suggestion payload.


        Carries name + description so the LLM can reason about *when to call
        which

        tool*. Earlier shape passed names only, which gave the LLM no grounding
        for

        tool-use advice ("call lookup_user when..." with no idea what
        lookup_user

        actually does). Description is optional - tools without one render as

        "(no description)" so the meta-prompt still sees the name.
    OutputSchemaField:
      properties:
        name:
          type: string
          maxLength: 100
          minLength: 1
          title: Name
          description: Output field name
        type:
          type: string
          maxLength: 50
          minLength: 1
          title: Type
          description: Output field type as the wizard renders it
      additionalProperties: false
      type: object
      required:
        - name
        - type
      title: OutputSchemaField
      description: >-
        One row of the output schema as the wizard's prompt-suggestion form sees
        it.


        Loosely typed - the suggestion endpoint only needs name/type prose for
        the

        meta-prompt, so we don't reuse ``AgentOutputSchemaTypeEnum`` here. That
        keeps

        the suggestion path tolerant of future schema-type additions without
        forcing

        a model bump on the read-only suggestion surface.
    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

````