---
name: llm-model-fallback
telemetry:
  metrics:
    - llm.interactions
  exporters:
    prometheus_exporter:
      type: prometheus
      options:
        endpoints:
          - scheme: http
            port: 7190
            path: /metrics
guards:
  api_key:
    type: inline
bindings:
  north_tcp_server:
    type: tcp
    kind: server
    options:
      host: 0.0.0.0
      port: 7162
    exit: north_http_server
  north_http_server:
    type: http
    kind: server
    exit: north_llm_server
  north_llm_server:
    type: llm
    kind: server
    options:
      dialect: anthropic
      authorization:
        api_key:
          credentials: "{credentials}"
    exit: north_llm_proxy
  #region llm_proxy
  north_llm_proxy:
    type: llm
    kind: proxy
    routes:
      - when:
          - model:
              - claude-primary
        exit: south_llm_client_primary
        with:
          fallback:
            - claude-haiku-4-5
      - when:
          - model:
              - claude-*
        exit: south_llm_client_anthropic
  #endregion llm_proxy
  #region llm_clients
  south_llm_client_primary:
    type: llm
    kind: client
    options:
      dialect: anthropic
      server: http://localhost:4999
      authorization:
        api_key:
          credentials: "{credentials}"
    telemetry:
      metrics:
        - llm.*
    exit: sys:http_client
  south_llm_client_anthropic:
    type: llm
    kind: client
    options:
      dialect: anthropic
      server: https://api.anthropic.com
      authorization:
        api_key:
          credentials: "{credentials}"
    telemetry:
      metrics:
        - llm.*
    exit: sys:http_client
  #endregion llm_clients
