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

# Load the router config as an editable graph

> Read the router YAML from the shared volume and return it as a graph.

When no config file exists yet, a starter graph is returned with
``exists=false`` so the Builder canvas is never blank. The viewer role gets
secrets masked; only ``nx1_airouter_admin`` sees keys/passwords.



## OpenAPI

````yaml get /api/airouter/config
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/airouter/config:
    get:
      tags:
        - AI Router
      summary: Load the router config as an editable graph
      description: >-
        Read the router YAML from the shared volume and return it as a graph.


        When no config file exists yet, a starter graph is returned with

        ``exists=false`` so the Builder canvas is never blank. The viewer role
        gets

        secrets masked; only ``nx1_airouter_admin`` sees keys/passwords.
      operationId: get_router_config_api_airouter_config_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RouterConfigResponse'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    RouterConfigResponse:
      properties:
        graph:
          $ref: '#/components/schemas/RouterGraph-Output'
        raw_yaml:
          type: string
          title: Raw Yaml
          description: The YAML as written on disk.
        config_path:
          type: string
          title: Config Path
        exists:
          type: boolean
          title: Exists
          description: False when no config file exists yet (starter graph).
      type: object
      required:
        - graph
        - raw_yaml
        - config_path
        - exists
      title: RouterConfigResponse
      description: Result of loading the router config from the shared volume.
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
    RouterGraph-Output:
      properties:
        nodes:
          items:
            $ref: '#/components/schemas/GraphNode-Output'
          type: array
          maxItems: 500
          title: Nodes
        edges:
          items:
            $ref: '#/components/schemas/GraphEdge'
          type: array
          maxItems: 2000
          title: Edges
        role_bindings:
          items:
            $ref: '#/components/schemas/RoleBinding'
          type: array
          title: Role Bindings
        vllm_endpoints:
          items:
            $ref: '#/components/schemas/EndpointData'
          type: array
          maxItems: 200
          title: Vllm Endpoints
        keyword_rules:
          items:
            additionalProperties: true
            type: object
          type: array
          maxItems: 500
          title: Keyword Rules
        jailbreak:
          items:
            additionalProperties: true
            type: object
          type: array
          maxItems: 200
          title: Jailbreak
        pii:
          items:
            additionalProperties: true
            type: object
          type: array
          maxItems: 200
          title: Pii
        default_model:
          anyOf:
            - type: string
            - type: 'null'
          title: Default Model
        default_reasoning_effort:
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
          title: Default Reasoning Effort
          description: low|medium|high applied when a model omits it.
        strategy:
          anyOf:
            - type: string
            - type: 'null'
          title: Strategy
          description: e.g. 'priority'.
        force_routing:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Force Routing
        clear_route_cache:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Clear Route Cache
        router_replay:
          $ref: '#/components/schemas/RouterReplaySettings'
        tools:
          $ref: '#/components/schemas/RouterToolSettings'
        semantic_cache:
          $ref: '#/components/schemas/SemanticCacheSettings'
        extras:
          additionalProperties: true
          type: object
          title: Extras
      type: object
      title: RouterGraph
      description: |-
        The full editable router as a node/edge graph.

        The list bounds cap the work a single save can trigger (serialisation +
        O(nodes×edges) validation + disk write) — a guard against an oversized
        payload exhausting CPU/disk.
    GraphNode-Output:
      properties:
        id:
          type: string
          maxLength: 200
          title: Id
        kind:
          type: string
          enum:
            - request
            - role_gate
            - content_role
            - model
            - default_route
          title: Kind
        label:
          type: string
          maxLength: 200
          title: Label
        position:
          $ref: '#/components/schemas/GraphPosition'
        role_gate:
          anyOf:
            - $ref: '#/components/schemas/RoleGateData'
            - type: 'null'
        content_role:
          anyOf:
            - $ref: '#/components/schemas/ContentRoleData-Output'
            - type: 'null'
        model:
          anyOf:
            - $ref: '#/components/schemas/ModelNodeData'
            - type: 'null'
      type: object
      required:
        - id
        - kind
        - label
      title: GraphNode
      description: A canvas node. Only the sub-object matching ``kind`` is populated.
    GraphEdge:
      properties:
        id:
          type: string
          title: Id
        source:
          type: string
          title: Source
          description: Source node id.
        target:
          type: string
          title: Target
          description: Target node id.
      type: object
      required:
        - id
        - source
        - target
      title: GraphEdge
    RoleBinding:
      properties:
        name:
          type: string
          title: Name
        role:
          type: string
          title: Role
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        subjects:
          items:
            $ref: '#/components/schemas/RoleSubject'
          type: array
          title: Subjects
      type: object
      required:
        - name
        - role
      title: RoleBinding
      description: Maps an authz router role to the subjects (groups) that hold it.
    EndpointData:
      properties:
        name:
          type: string
          maxLength: 200
          title: Name
          description: Referenced by models.
        type:
          type: string
          title: Type
          description: anthropic | openai | vllm ...
          default: openai
        address:
          type: string
          title: Address
          description: Host or base URL.
          default: ''
        port:
          anyOf:
            - type: integer
            - type: 'null'
          title: Port
        protocol:
          anyOf:
            - type: string
            - type: 'null'
          title: Protocol
          description: http | https.
        api_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Api Key
          description: Endpoint credential (entered in the UI).
        provider_profile:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider Profile
          description: >-
            Provider profile the router calls instead of address and port. Omit
            to keep it; null or '' removes it.
        base_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Base Url
          description: >-
            Upstream URL, e.g.
            https://bedrock-mantle.eu-west-1.api.aws/anthropic. Saved to a
            provider profile named after the endpoint. Omit to keep it; null or
            '' removes it.
        extra_headers:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Extra Headers
          description: >-
            Headers sent on every request to this endpoint. Omit to keep them;
            {} clears them.
        default_max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Default Max Tokens
          description: >-
            max_tokens the router fills in when a caller omits it, for providers
            that require it (Anthropic). Stored on the provider profile. Omit to
            keep it; 0 removes it.
        prompt_caching:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Prompt Caching
          description: >-
            Mark the stable prefix (tools + system prompt) so a repeated prefix
            is billed as a cache read. Worth it for tool-calling agents; traffic
            that never repeats a prefix pays a surcharge. Stored on the provider
            profile. Omit to keep it. Anthropic only.
        stream_upstream:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream Upstream
          description: >-
            Call the provider with stream=true whatever the caller asked for.
            Lets a model's full max_tokens be used — Anthropic refuses a large
            one on a non-streamed request — and keeps bytes flowing so a long
            reply does not meet an idle timeout. Stored on the provider profile.
            Omit to keep it. Anthropic only.
        token_exchange:
          anyOf:
            - type: string
            - type: 'null'
          title: Token Exchange
          description: >-
            Name of an authz.token_exchange profile. Set, the router swaps the
            caller's own token for one this backend accepts and sends that
            instead of api_key. Omit to keep it; '' removes it.
        token_exchange_audience:
          anyOf:
            - type: string
            - type: 'null'
          title: Token Exchange Audience
          description: >-
            Overrides the profile's audience, for backends that share an
            identity provider but are separate audiences to it. Omit to keep it;
            '' removes it.
        weight:
          anyOf:
            - type: integer
            - type: 'null'
          title: Weight
          description: Load-balancing weight across endpoints.
        models:
          items:
            type: string
          type: array
          title: Models
          description: Model ids this endpoint serves.
        raw:
          additionalProperties: true
          type: object
          title: Raw
          description: Original vllm_endpoints entry.
      type: object
      required:
        - name
      title: EndpointData
      description: >-
        A backend LLM endpoint (a ``vllm_endpoints`` entry).


        Endpoints are global to the config — models reference them by ``name``
        via

        ``preferred_endpoints``. ``raw`` preserves the whole original entry so

        unmodeled fields (and secrets) survive a round-trip.
    RouterReplaySettings:
      properties:
        store_backend:
          type: string
          title: Store Backend
          default: memory
        ttl_seconds:
          type: integer
          title: Ttl Seconds
          default: 2592000
        async_writes:
          type: boolean
          title: Async Writes
          default: true
      type: object
      title: RouterReplaySettings
      description: Global router-replay defaults. Replay is on by default.
    RouterToolSettings:
      properties:
        enabled:
          type: boolean
          title: Enabled
          description: >-
            Build the tool-selection machinery. It selects nothing on its own; a
            decision's plugin still has to ask. Turn it off to disable the
            subsystem without editing decisions.
          default: true
        embedding:
          $ref: '#/components/schemas/RouterEmbeddingSettings'
          description: What to embed with when ranking tools.
      type: object
      title: RouterToolSettings
      description: |-
        The deployment's tool infrastructure: what ranks tools, and whether the
        subsystem is built at all.

        Not whether any route narrows its tools or runs them — those are a
        decision's Tool Selection and Tool Execution plugins. Narrowing a turn's
        tools or executing them changes what a route is for, so a global default
        would apply that choice to routes nobody made it for.

        Where tools are read from and where they run are also absent on purpose:
        the router derives both from its own deployment identity, so the service
        that advertises a tool and the one that runs it cannot drift apart.
    SemanticCacheSettings:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: false
        backend_type:
          type: string
          title: Backend Type
          default: memory
        similarity_threshold:
          type: number
          title: Similarity Threshold
          default: 0.8
        ttl_seconds:
          type: integer
          title: Ttl Seconds
          default: 3600
        max_entries:
          type: integer
          title: Max Entries
          default: 1000
      type: object
      title: SemanticCacheSettings
      description: Global semantic-cache defaults (top-level ``semantic_cache`` in YAML).
    GraphPosition:
      properties:
        x:
          type: number
          title: X
          default: 0
        'y':
          type: number
          title: 'Y'
          default: 0
      type: object
      title: GraphPosition
      description: Canvas coordinates. Persisted only in the layout sidecar.
    RoleGateData:
      properties:
        router_role:
          type: string
          title: Router Role
          description: authz router role name.
        priority:
          type: integer
          title: Priority
          description: Decision priority; higher wins when multiple match.
          default: 100
      type: object
      required:
        - router_role
      title: RoleGateData
      description: >-
        Identity gate — the first routing decision, on an authz router role.


        ``router_role`` is the role from ``role_bindings`` (which maps a
        Keycloak

        Group to that role). The gate serialises to ``{type: authz, name:
        <role>}``.
    ContentRoleData-Output:
      properties:
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        operator:
          type: string
          enum:
            - AND
            - OR
          title: Operator
          description: How conditions combine.
          default: AND
        conditions:
          items:
            $ref: '#/components/schemas/RuleCondition-Output'
          type: array
          title: Conditions
        plugins:
          items:
            $ref: '#/components/schemas/PluginInstance'
          type: array
          title: Plugins
        priority:
          type: integer
          title: Priority
          default: 50
        selection_algorithm:
          anyOf:
            - type: string
            - type: 'null'
          title: Selection Algorithm
          description: 'Multi-model picker: confidence|latency_aware|... .'
        model_refs:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Model Refs
      type: object
      title: ContentRoleData
      description: A content branch under an identity gate — a semantic-router Decision.
    ModelNodeData:
      properties:
        model:
          type: string
          title: Model
          description: Model id, e.g. 'claude-opus-4-8'.
        api_format:
          anyOf:
            - type: string
            - type: 'null'
          title: Api Format
          description: anthropic | openai | vllm ...
        preferred_endpoints:
          items:
            type: string
          type: array
          title: Preferred Endpoints
        capabilities:
          items:
            type: string
          type: array
          title: Capabilities
        modality:
          anyOf:
            - type: string
              enum:
                - ar
                - diffusion
                - omni
                - embedding
            - type: 'null'
          title: Modality
          description: >-
            'embedding' for an embeddings model, which only serves
            /v1/embeddings. Null means a chat model. Omit to keep the saved
            value.
        quality_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Quality Score
        pricing:
          anyOf:
            - $ref: '#/components/schemas/ModelPricingData'
            - type: 'null'
          description: >-
            Per-million-token rates. Sent, it is authoritative; omitted, the
            saved pricing is kept. Feeds both the router and the Metrics tab.
        external_model_ids:
          additionalProperties:
            type: string
          type: object
          title: External Model Ids
          description: >-
            The model id each endpoint type expects, if it differs, e.g.
            {'anthropic': 'anthropic.claude-sonnet-5'} for Bedrock. Omit to keep
            the saved ids; {} clears them.
        access_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Access Key
          description: Per-model API key (entered in the UI).
        reasoning_family:
          anyOf:
            - type: string
            - type: 'null'
          title: Reasoning Family
        reasoning_effort:
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
          title: Reasoning Effort
          description: low|medium|high (provider dependent).
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
          description: Max output tokens for this model (per request).
        is_default:
          type: boolean
          title: Is Default
          description: True if wired to the Default route.
          default: false
        raw:
          additionalProperties: true
          type: object
          title: Raw
          description: Original model_config entry (passthrough).
      type: object
      required:
        - model
      title: ModelNodeData
      description: >-
        An LLM endpoint node — a full ``model_config`` entry.


        ``raw`` preserves the entire original entry so fields the UI does not
        yet

        surface (and secrets) survive a round-trip; typed fields overlay onto
        it.
    RoleSubject:
      properties:
        kind:
          type: string
          title: Kind
          description: Subject kind, e.g. Group.
          default: Group
        name:
          type: string
          title: Name
      type: object
      required:
        - name
      title: RoleSubject
      description: A subject bound to a router role (e.g. a Keycloak Group).
    RouterEmbeddingSettings:
      properties:
        endpoint:
          anyOf:
            - type: string
            - type: 'null'
          title: Endpoint
          description: >-
            OpenAI-compatible base URL, e.g. http://nx1-llm-envoy:8080/v1. Unset
            uses the model baked into the router's image.
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: Embedding model to ask that endpoint for.
        timeout_seconds:
          type: integer
          maximum: 300
          minimum: 1
          title: Timeout Seconds
          description: How long one embedding call may take; a turn waits on it.
          default: 20
      type: object
      title: RouterEmbeddingSettings
      description: >-
        What the router embeds with when it ranks tools.


        An endpoint is the better of the two options. The model becomes a URL
        and

        a name rather than weights baked into the router's image, so changing it
        is

        a config edit — and since the router reloads its config without
        restarting

        but loads an in-process model only at startup, a change here takes
        effect

        where a change to the baked model would not. It also embeds a whole

        catalogue in one call instead of a hundred-odd descriptions one at a
        time

        on CPU, and pointing it at the endpoint the rest of the platform embeds

        with ranks tools in the same vector space as everything else.


        Leave ``endpoint`` unset and the router uses the model baked into its

        image, so nothing here is required.
    RuleCondition-Output:
      properties:
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
          description: Signal family for a leaf condition.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Named signal/value this condition matches.
        params:
          additionalProperties: true
          type: object
          title: Params
          description: Signal-specific parameters (threshold, keywords, ...).
        operator:
          anyOf:
            - type: string
              enum:
                - AND
                - OR
            - type: 'null'
          title: Operator
          description: Set on a nested group of conditions.
        conditions:
          items:
            $ref: '#/components/schemas/RuleCondition-Output'
          type: array
          title: Conditions
          description: Children of a nested group.
      type: object
      title: RuleCondition
      description: >-
        One node of a content role's match rule — a leaf or a nested group.


        Leaf: ``type`` is the signal family (``domain``, ``keyword``,
        ``embedding``,

        ``complexity``, ``pii``, ``jailbreak``, ``authz``, ...) and ``params``
        holds

        signal-specific knobs. Group: ``operator`` (AND/OR) + ``conditions``
        nest

        further conditions, so rules like ``AND[authz, OR[jailbreak, pii]]``
        survive.
    PluginInstance:
      properties:
        type:
          type: string
          title: Type
          description: Plugin type key, e.g. 'router_replay'.
        configuration:
          additionalProperties: true
          type: object
          title: Configuration
          description: Property values for this plugin instance.
      type: object
      required:
        - type
      title: PluginInstance
      description: |-
        A plugin attached to a role, with its configured properties.

        A bare string is accepted as shorthand for a plugin with no
        configuration, so ``"router_replay"`` and ``{"type": "router_replay"}``
        mean the same thing.

        The shorthand exists because reading the router reports a decision's
        plugins as plain type names (``airouter_assistant._describe_decision``),
        so anything that reads the config and proposes a change back — a person
        or the assistant — naturally writes them the way it saw them. Refusing
        that shape asked callers to notice an asymmetry we had no reason to
        impose; the plugin type is still checked against the catalogue either
        way, so nothing is loosened but the spelling.
    ModelPricingData:
      properties:
        currency:
          anyOf:
            - type: string
            - type: 'null'
          title: Currency
          description: ISO code, e.g. 'USD'. Defaults to USD.
        prompt_per_1m:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Prompt Per 1M
        completion_per_1m:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Completion Per 1M
        cache_read_per_1m:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Cache Read Per 1M
        cache_write_per_1m:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Cache Write Per 1M
      type: object
      title: ModelPricingData
      description: >-
        What a model costs, per million tokens.


        These are the router's own ``pricing`` keys, so a value set here is the

        same one the router prices a request with -- there is no second list to

        keep in step. ai-api copies them into the metrics table the Metrics tab

        joins for spend.


        Rates are per million tokens of the named kind. Cache rates are
        optional:

        a provider's cached input is a fraction of ordinary input, and the
        router

        falls back to its own ratio when they are unset.
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.