---
name: llm-gateway-setup
guards:
  api_key:
    type: inline
bindings:
  north_tcp_server:
    type: tcp
    kind: server
    options:
      host: 0.0.0.0
      port:
        - 7161
        - 7162
    routes:
      - when:
          - port: 7161
        exit: north_http_server_openai
      - when:
          - port: 7162
        exit: north_http_server_anthropic
  #region llm_servers
  north_http_server_openai:
    type: http
    kind: server
    exit: north_llm_server_openai
  north_llm_server_openai:
    type: llm
    kind: server
    options:
      dialect: openai
      authorization:
        api_key:
          credentials: "Bearer {credentials}"
    exit: north_llm_proxy
  north_http_server_anthropic:
    type: http
    kind: server
    exit: north_llm_server_anthropic
  north_llm_server_anthropic:
    type: llm
    kind: server
    options:
      dialect: anthropic
      authorization:
        api_key:
          credentials: "{credentials}"
    exit: north_llm_proxy
  #endregion llm_servers
  #region llm_proxy
  north_llm_proxy:
    type: llm
    kind: proxy
    routes:
      - when:
          - model:
              - gpt-*
        exit: south_llm_client_openai
      - when:
          - model:
              - claude-*
        exit: south_llm_client_anthropic
  #endregion llm_proxy
  #region llm_clients
  south_llm_client_openai:
    type: llm
    kind: client
    options:
      dialect: openai
      server: https://api.openai.com
      authorization:
        api_key:
          credentials: "Bearer {credentials}"
    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}"
    exit: sys:http_client
  #endregion llm_clients
