Skip to content

[AI-Assisted] feat(config): add OpenRouter provider routing support#3971

Closed
mahoek wants to merge 5 commits into
openclaw:mainfrom
mahoek:openrouter-routing
Closed

[AI-Assisted] feat(config): add OpenRouter provider routing support#3971
mahoek wants to merge 5 commits into
openclaw:mainfrom
mahoek:openrouter-routing

Conversation

@mahoek

@mahoek mahoek commented Jan 29, 2026

Copy link
Copy Markdown

What

Adds support for OpenRouter's provider routing feature to Moltbot's model configuration. This allows users to control which upstream providers OpenRouter routes requests to.

Why

OpenRouter provides a unified API that routes requests to many providers behind a single endpoint. Some users want to:

  • Route specific models exclusively through certain providers (e.g., only use Anthropic for claude-sonnet-4-5)
  • Define fallback provider order (e.g., try Anthropic first, then Amazon)
    The openRouterRouting field was already supported by the underlying @mariozechner/pi-ai library (v0.50.3+) but was not exposed through Moltbot's config schema.

Changes

  • src/config/types.agent-defaults.ts: Added ModelCompatEntryConfig and OpenRouterRoutingConfig types, added compat field to AgentModelEntryConfig
  • src/config/zod-schema.core.ts: Added openRouterRouting validation to ModelCompatSchema with only and order options
  • src/config/zod-schema.agent-defaults.ts: Added full compat field validation to model entry schema
  • src/agents/models-config.openrouter-routing.test.ts: Unit tests for config validation
  • src/config/zod-schema.openrouter-routing.test.ts: Integration tests for loading from moltbot.json

Example Usage

{
  "agents": {
    "defaults": {
      "model": { "primary": "openrouter/anthropic/claude-sonnet-4-5" },
      "models": {
        "openrouter/anthropic/claude-sonnet-4-5": {
          "alias": "claude",
          "compat": {
            "openRouterRouting": {
              "only": ["anthropic", "amazon-bedrock"]
            }
          }
        },
        "openrouter/z-ai/glm-4.7-flash": {
          "alias": "glm",
          "compat": {
            "openRouterRouting": {
              "order": ["together", "parasail"]
            }
          }
        }
      }
    }
  }
}

Testing

  • ✅ Added unit tests validating config schema accepts openRouterRouting with both only and order fields
  • ✅ Added integration tests verifying config loads correctly from moltbot.json
  • ✅ All OpenRouter routing tests pass (3 unit tests + 2 integration tests)
  • ✅ Verified pi-ai library v0.50.3 already supports openRouterRouting in OpenAICompletionsCompat
  • ⛔ Not tested in real instance

AI-Assisted

Yes

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling labels Jan 29, 2026
@mahoek mahoek changed the title Config: add OpenRouter provider routing support [AI-Assisted] feat(config): add OpenRouter provider routing support Jan 29, 2026
@mahoek

mahoek commented Jan 31, 2026

Copy link
Copy Markdown
Author

This needs some work before it will be ready, hope to have some time soon

@clawdinator

clawdinator Bot commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

CLAWDINATOR FIELD REPORT // PR Closure

I am CLAWDINATOR — cybernetic crustacean, maintainer triage bot for OpenClaw. I was sent from the future to keep this repo shipping clean code.

Context: OpenClaw serves ~1M users. With 800+ open PRs and ~25 new PRs every hour, we're prioritizing high-impact fixes that benefit the most users. Massive features, unsolicited provider integrations, and AI-generated PRs are being closed.

If this change is critical, open a GitHub issue first to discuss scope and priority with maintainers. For smaller fixes, head to #pr-thunderdome-dangerzone on Discord.

TERMINATED.

🤖 This is an automated message from CLAWDINATOR, the OpenClaw maintainer bot.

@clawdinator clawdinator Bot closed this Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant