UNPKG

notdiamond

Version:

The official TypeScript library for the Notdiamond API

68 lines 2.5 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.ModelRouter = void 0; const resource_1 = require("../core/resource.js"); class ModelRouter extends resource_1.APIResource { /** * Select the optimal LLM to handle your query based on Not Diamond's routing * algorithm. * * This endpoint analyzes your messages and returns the best-suited model from your * specified models. The router considers factors like query complexity, model * capabilities, cost, and latency based on your preferences. * * **Key Features:** * * - Intelligent routing across multiple LLM providers * - Support for custom routers trained on your evaluation data * - Optional cost/latency optimization * - Function calling support for compatible models * * **Usage:** * * 1. Pass your messages in OpenAI format (array of objects with 'role' and * 'content') * 2. Specify which LLM providers you want to route between * 3. Optionally provide a preference_id to use a custom router that you've trained * 4. Receive a recommended model and session_id * 5. Use the session_id to submit feedback and improve routing * * **Related Endpoints:** * * - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for * personalized routing * - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation * data * * @example * ```ts * const response = await client.modelRouter.selectModel({ * llm_providers: [ * { provider: 'openai', model: 'gpt-4o' }, * { * provider: 'anthropic', * model: 'claude-sonnet-4-5-20250929', * }, * { provider: 'google', model: 'gemini-2.5-flash' }, * ], * messages: [ * { * role: 'system', * content: 'You are a helpful assistant.', * }, * { * role: 'user', * content: 'Explain quantum computing in simple terms', * }, * ], * }); * ``` */ selectModel(params, options) { const { type, ...body } = params; return this._client.post('/v2/modelRouter/modelSelect', { query: { type }, body, ...options }); } } exports.ModelRouter = ModelRouter; //# sourceMappingURL=model-router.js.map