Skip to content

OpenRouter reasoningEffort injection blocks x-ai/grok-4.20-multi-agent #41

Description

@KHAEntertainment

Problem

All calls to x-ai/grok-4.20-multi-agent via OpenRouter fail with:

Model grok-4.20-multi-agent-0309 does not support parameter reasoningEffort.

Root Cause

OpenRouter's proxy infrastructure injects reasoningEffort (underscore format) at the infrastructure layer for all calls to x-ai/grok-4.20-multi-agent. This injection happens regardless of what the client sends — it is NOT triggered by extra_body or any client-side parameter.

xAI's Grok model only accepts reasoning.effort (dot notation, nested object). OpenRouter's injection uses the wrong format.

What Was Tested

Client-side approaches (all failed)

Approach Method Result
No reasoning param max_tokens, temperature only ❌ OpenRouter injects reasoningEffort anyway
reasoning: { effort: "low" } httpx raw HTTP POST ❌ OpenRouter still injects reasoningEffort
reasoningEffort: "medium" httpx raw HTTP POST ❌ OpenRouter double-injects
extra_body: { reasoningEffort: "low" } httpx raw HTTP POST ❌ Still fails
urllib.request (no httpx) raw HTTP ❌ Same result
OpenAI SDK extra_body={} SDK ❌ Same result

OpenRouter's own documentation at https://openrouter.ai/models/x-ai/grok-4.20-multi-agent claims:

  • supports_reasoning_effort: true
  • supported_reasoning_efforts: ["low", "medium", "high", "xhigh"]

But the actual API returns the reasoningEffort error.

Positive findings

  • xAI direct (api.x.ai/v1/responses) accepts reasoning: { effort: "low" } natively — works correctly with xAI API key
  • OpenRouter key valid — tested with anthropic/claude-3.5-haiku, returns 200
  • grok-4 (non-multi-agent) works on OpenRouter without any reasoning parameter

Investigation Date

2026-04-12

Files Changed

The codebase was updated to use httpx for raw HTTP control (rather than OpenAI SDK) in preparation for sending reasoning.effort directly. This change is correct but insufficient — the injection happens at OpenRouter's proxy layer.

Changed files:

  • src/bridge/grok_bridge.py — httpx for OpenRouter, OpenAI SDK responses API for xAI direct
  • platforms/claude/src/bridge/grok_bridge.py — mirror
  • skills/grok-refactor/bridge/grok_bridge.py — mirror
  • .mcp.json files — absolute venv Python path

Proposed Solutions

  1. OpenRouter fix: Report to OpenRouter that reasoningEffort injection is broken for x-ai/grok-4.20-multi-agent. They need to either stop injecting or support reasoning.effort (dot notation) in their injection layer.

  2. Alternative model: Use x-ai/grok-4 (non-multi-agent) on OpenRouter — this works but lacks the multi-agent swarm capability.

  3. xAI direct: Use xAI API key directly at api.x.ai/v1/responses — works but requires an xAI API key (not an OpenRouter key).

  4. Proxy stripping (untested): A middleware/proxy that strips reasoningEffort from OpenRouter's response before it reaches the client would not help — the error comes from xAI's rejection of OpenRouter's injected parameter, which happens server-side at xAI.

Reproduction Script

import httpx, json, os

key = os.environ["OPENROUTER_API_KEY"]
client = httpx.Client(
    base_url="https://openrouter.ai/api/v1",
    headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"},
    timeout=30,
)

body = {
    "model": "x-ai/grok-4.20-multi-agent",
    "messages": [{"role": "system", "content": "You are Grok 4.20."},
                 {"role": "user", "content": "Say hi in one word."}],
    "max_tokens": 16384,
    "temperature": 0.3,
    # No reasoning param — but OpenRouter injects reasoningEffort anyway
}
resp = client.post("/chat/completions", json=body)
# Status 400: Model grok-4.20-multi-agent-0309 does not support parameter reasoningEffort.

Environment

  • Python 3.14 (venv at .venv/)
  • httpx 0.28.1
  • openai 1.x
  • OpenRouter API key: sk-or-v1-1... (73 chars, OpenRouter format)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions