import { MorphAPIClient } from '../core/client.js'; import { APIResource } from '../core/resource.js'; import { Provider, RouterConfig, RouterInput, RouterResult, RawRouterResult, ClassifyInput, ClassifyResult } from './types.js'; import '../tools/utils/resilience.js'; /** * Core implementation for intelligent model routing. * * Routers are thin resources over the shared `MorphAPIClient` transport: they * POST to `/v1/router/` and map the response. Auth, retries, timeouts, * and the SDK-version header all live in the transport. */ declare abstract class BaseRouter extends APIResource { protected provider: Provider; protected timeout: number; constructor(provider: Provider, clientOrConfig?: MorphAPIClient | RouterConfig); /** Throw the historical "API key is required" message when no key is resolvable. */ protected requireApiKey(): void; /** POST to the router and surface failures as `Router API error (): ...`. */ protected route(provider: string, input: RouterInput): Promise; /** * Select the optimal model for a given input and mode */ selectModel(input: RouterInput): Promise; } /** * OpenAI model router for GPT-5 series * * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.openai`). In edge * runtimes where `MorphClient` is unavailable, pass a shared transport: * `new OpenAIRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility. */ declare class OpenAIRouter extends BaseRouter { constructor(clientOrConfig?: MorphAPIClient | RouterConfig); /** * Select optimal GPT-5 model * * @param input - User input and mode * @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high) */ selectModel(input: RouterInput): Promise; } /** * Anthropic model router for Claude 4.5 series * * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.anthropic`). In edge * runtimes where `MorphClient` is unavailable, pass a shared transport: * `new AnthropicRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility. */ declare class AnthropicRouter extends BaseRouter { constructor(clientOrConfig?: MorphAPIClient | RouterConfig); /** * Select optimal Claude model * * @param input - User input and mode * @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet) */ selectModel(input: RouterInput): Promise; } /** * Google Gemini model router * * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.gemini`). In edge * runtimes where `MorphClient` is unavailable, pass a shared transport: * `new GeminiRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility. */ declare class GeminiRouter extends BaseRouter { constructor(clientOrConfig?: MorphAPIClient | RouterConfig); /** * Select optimal Gemini model * * @param input - User input and mode * @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro) */ selectModel(input: RouterInput): Promise; } /** * Raw difficulty classification router (no provider-specific mapping) * * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.raw`). In edge * runtimes where `MorphClient` is unavailable, pass a shared transport: * `new RawRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility. */ declare class RawRouter extends BaseRouter { constructor(clientOrConfig?: MorphAPIClient | RouterConfig); /** * Get raw difficulty classification * * @param input - User input and mode * @returns Raw difficulty (easy | medium | hard | needs_info) */ classify(input: RouterInput): Promise; } /** * Classifier for `/v1/router/classify`. * * Returns the raw difficulty/ambiguity/domain signals without mapping them to a * model. The caller owns the policy — this is what `@morphllm/morphrouter` uses * so the routing matrix configured in the dashboard stays the source of truth. */ declare class RouterClassifier extends APIResource { private timeout; constructor(clientOrConfig?: MorphAPIClient | RouterConfig); /** Classify an input across the requested axes (all three by default). */ classify(input: ClassifyInput): Promise; } export { AnthropicRouter, GeminiRouter, OpenAIRouter, RawRouter, RouterClassifier };