Scenario: Policy-Based Model Routing

Route requests to different AI models, providers, or credentials based on workload or request characteristics, without changing application code. The gateway resolves the correct connector and credential at runtime according to your policy.

How it works

Model routing is configured via the policy DSL using select_connector, select_credential, and mutate effect fields. Rules match on request context (workload ID, model, headers, etc.) and override the default routing for matching requests.

Policy rules are written in YAML and loaded via:

  • Free Gateway: YAML file on disk, reloaded with SIGHUP or POST /v1/admin/policies/reload; use PUT /v1/admin/policies to upsert rules over the API
  • CP-connected: org overlay YAML edited in the console (Policies → Advanced tab); pushed to all nodes by the control plane

Example: route a workload to a cheaper model

Your research workload sends requests to Anthropic but you want to pin it to Haiku instead of the default model:

schema: mvgc.policy_rules.v1
layer: credentials
rules:
  - id: route.research.haiku
    priority: 100
    when:
      all:
        - field: context.workload_id
          equals: wl-research
    effect:
      decision: allow
      select_connector:
        connector_id: anthropic
      select_credential:
        credential_id: cred-anthropic
      mutate:
        action.target_path: /v1/messages
        action.params.model: claude-haiku-4-5

Note: action.params.model override applies to explicit mode (/v1/gateway/actions). In transparent proxy mode the raw request body is forwarded as-is; set the model in the request body instead.

Example: route to a different provider entirely

Send a summarization workload to OpenAI while everything else goes to Anthropic:

schema: mvgc.policy_rules.v1
layer: credentials
rules:
  - id: route.summarizer.openai
    priority: 100
    when:
      all:
        - field: context.workload_id
          equals: wl-summarizer
    effect:
      decision: allow
      select_connector:
        connector_id: openai
      select_credential:
        credential_id: cred-openai
      mutate:
        action.target_path: /v1/chat/completions

Example: block access to unapproved models

Deny any request that specifies a model not on your approved list:

schema: mvgc.policy_rules.v1
layer: targets
rules:
  - id: deny.unapproved-models
    priority: 200
    when:
      all:
        - field: context.action.params.model
          not_in:
            - gpt-4o-mini
            - gpt-4o
            - claude-haiku-4-5
    effect:
      decision: deny
      reason: "Model not on approved list"

Console vs. YAML

Model routing rules (connector selection, credential selection, model mutation) are YAML-only; there is no form-based rule builder in the console. For CP-connected deployments, edit the org overlay in Policies → Advanced tab and save; the control plane distributes the updated bundle to all nodes within seconds.

Next steps