Skip to content

Add Morph Model Router as a complexity classifier for routing decisions #68

Description

@bhaktatejas922

NadirClaw routes simple prompts to cheap/local models and complex ones to premium. The hard part is deciding "simple vs complex" reliably. Morph's Model Router does exactly that: ~50ms, returns difficulty (easy/medium/hard/needs_info) plus domain and ambiguity, trained on millions of coding prompts.

Instead of a length/keyword heuristic, NadirClaw could call /router/classify (or /router/multimodel with a cost_efficient policy) for the routing signal:

const { model } = await (await fetch("https://api.morphllm.com/v1/router/multimodel", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.MORPH_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ input: prompt, allowed_providers: ["anthropic"], policy: "cost_efficient" }),
})).json();

Could sit behind a config flag as an optional routing strategy alongside the existing rules.

Docs: https://docs.morphllm.com/sdk/components/router

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions