notdiamond 2.0.0-rc1 → 2.0.0-rc10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/README.md +299 -97
- package/client.d.mts +19 -33
- package/client.d.mts.map +1 -1
- package/client.d.ts +19 -33
- package/client.d.ts.map +1 -1
- package/client.js +19 -35
- package/client.js.map +1 -1
- package/client.mjs +19 -35
- package/client.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/internal/utils/env.d.mts.map +1 -1
- package/internal/utils/env.d.ts.map +1 -1
- package/internal/utils/env.js +4 -2
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +4 -2
- package/internal/utils/env.mjs.map +1 -1
- package/package.json +10 -11
- package/resources/custom-router.d.mts +145 -0
- package/resources/custom-router.d.mts.map +1 -0
- package/resources/custom-router.d.ts +145 -0
- package/resources/custom-router.d.ts.map +1 -0
- package/resources/custom-router.js +83 -0
- package/resources/custom-router.js.map +1 -0
- package/resources/custom-router.mjs +79 -0
- package/resources/custom-router.mjs.map +1 -0
- package/resources/index.d.mts +6 -6
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -6
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +6 -6
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -3
- package/resources/index.mjs.map +1 -1
- package/resources/model-router.d.mts +196 -0
- package/resources/model-router.d.mts.map +1 -0
- package/resources/model-router.d.ts +196 -0
- package/resources/model-router.d.ts.map +1 -0
- package/resources/model-router.js +70 -0
- package/resources/model-router.js.map +1 -0
- package/resources/model-router.mjs +66 -0
- package/resources/model-router.mjs.map +1 -0
- package/resources/models.d.mts +50 -25
- package/resources/models.d.mts.map +1 -1
- package/resources/models.d.ts +50 -25
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +5 -0
- package/resources/models.js.map +1 -1
- package/resources/models.mjs +5 -0
- package/resources/models.mjs.map +1 -1
- package/resources/preferences.d.mts +34 -48
- package/resources/preferences.d.mts.map +1 -1
- package/resources/preferences.d.ts +34 -48
- package/resources/preferences.d.ts.map +1 -1
- package/resources/preferences.js +14 -36
- package/resources/preferences.js.map +1 -1
- package/resources/preferences.mjs +14 -36
- package/resources/preferences.mjs.map +1 -1
- package/resources/prompt-adaptation.d.mts +339 -234
- package/resources/prompt-adaptation.d.mts.map +1 -1
- package/resources/prompt-adaptation.d.ts +339 -234
- package/resources/prompt-adaptation.d.ts.map +1 -1
- package/resources/prompt-adaptation.js +30 -53
- package/resources/prompt-adaptation.js.map +1 -1
- package/resources/prompt-adaptation.mjs +30 -53
- package/resources/prompt-adaptation.mjs.map +1 -1
- package/resources/report/index.d.mts +3 -0
- package/resources/report/index.d.mts.map +1 -0
- package/resources/report/index.d.ts +3 -0
- package/resources/report/index.d.ts.map +1 -0
- package/resources/report/index.js +9 -0
- package/resources/report/index.js.map +1 -0
- package/resources/report/index.mjs +4 -0
- package/resources/report/index.mjs.map +1 -0
- package/resources/report/metrics.d.mts +87 -0
- package/resources/report/metrics.d.mts.map +1 -0
- package/resources/report/metrics.d.ts +87 -0
- package/resources/report/metrics.d.ts.map +1 -0
- package/resources/report/metrics.js +57 -0
- package/resources/report/metrics.js.map +1 -0
- package/resources/report/metrics.mjs +53 -0
- package/resources/report/metrics.mjs.map +1 -0
- package/resources/report/report.d.mts +10 -0
- package/resources/report/report.d.mts.map +1 -0
- package/resources/report/report.d.ts +10 -0
- package/resources/report/report.d.ts.map +1 -0
- package/resources/report/report.js +17 -0
- package/resources/report/report.js.map +1 -0
- package/resources/report/report.mjs +12 -0
- package/resources/report/report.mjs.map +1 -0
- package/resources/report.d.mts +1 -244
- package/resources/report.d.mts.map +1 -1
- package/resources/report.d.ts +1 -244
- package/resources/report.d.ts.map +1 -1
- package/resources/report.js +2 -82
- package/resources/report.js.map +1 -1
- package/resources/report.mjs +1 -80
- package/resources/report.mjs.map +1 -1
- package/src/client.ts +65 -116
- package/src/internal/utils/env.ts +4 -2
- package/src/resources/custom-router.ts +168 -0
- package/src/resources/index.ts +23 -34
- package/src/resources/model-router.ts +224 -0
- package/src/resources/models.ts +55 -32
- package/src/resources/preferences.ts +40 -77
- package/src/resources/prompt-adaptation.ts +361 -291
- package/src/resources/report/index.ts +4 -0
- package/src/resources/report/metrics.ts +99 -0
- package/src/resources/report/report.ts +19 -0
- package/src/resources/report.ts +1 -298
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/admin.d.mts +0 -4
- package/resources/admin.d.mts.map +0 -1
- package/resources/admin.d.ts +0 -4
- package/resources/admin.d.ts.map +0 -1
- package/resources/admin.js +0 -9
- package/resources/admin.js.map +0 -1
- package/resources/admin.mjs +0 -5
- package/resources/admin.mjs.map +0 -1
- package/resources/routing.d.mts +0 -391
- package/resources/routing.d.mts.map +0 -1
- package/resources/routing.d.ts +0 -391
- package/resources/routing.d.ts.map +0 -1
- package/resources/routing.js +0 -163
- package/resources/routing.js.map +0 -1
- package/resources/routing.mjs +0 -159
- package/resources/routing.mjs.map +0 -1
- package/src/resources/admin.ts +0 -5
- package/src/resources/routing.ts +0 -476
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../core/resource.mjs";
|
|
3
|
+
import { multipartFormRequestOptions } from "../internal/uploads.mjs";
|
|
4
|
+
export class CustomRouter extends APIResource {
|
|
5
|
+
/**
|
|
6
|
+
* Train a custom router on your evaluation data to optimize routing for your
|
|
7
|
+
* specific use case.
|
|
8
|
+
*
|
|
9
|
+
* This endpoint allows you to train a domain-specific router that learns which
|
|
10
|
+
* models perform best for different types of queries in your application. The
|
|
11
|
+
* router analyzes your evaluation dataset, clusters similar queries, and learns
|
|
12
|
+
* model performance patterns.
|
|
13
|
+
*
|
|
14
|
+
* **Training Process:**
|
|
15
|
+
*
|
|
16
|
+
* 1. Upload a CSV file with your evaluation data
|
|
17
|
+
* 2. Specify which models to route between
|
|
18
|
+
* 3. Define the evaluation metric (score column)
|
|
19
|
+
* 4. The system trains asynchronously and returns a preference_id
|
|
20
|
+
* 5. Use the preference_id in model_select() calls once training completes
|
|
21
|
+
*
|
|
22
|
+
* **Dataset Requirements:**
|
|
23
|
+
*
|
|
24
|
+
* - Format: CSV file
|
|
25
|
+
* - Minimum samples: 25 (more is better for accuracy)
|
|
26
|
+
* - Required columns:
|
|
27
|
+
* - Prompt column (specified in prompt_column parameter)
|
|
28
|
+
* - For each model: `{provider}/{model}/score` and `{provider}/{model}/response`
|
|
29
|
+
*
|
|
30
|
+
* **Example CSV structure:**
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
* prompt,openai/gpt-4o/score,openai/gpt-4o/response,anthropic/claude-sonnet-4-5-20250929/score,anthropic/claude-sonnet-4-5-20250929/response
|
|
34
|
+
* "Explain quantum computing",0.95,"Quantum computing uses...",0.87,"Quantum computers leverage..."
|
|
35
|
+
* "Write a Python function",0.82,"def my_function()...",0.91,"Here's a Python function..."
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* **Model Selection:**
|
|
39
|
+
*
|
|
40
|
+
* - Specify standard models: `{"provider": "openai", "model": "gpt-4o"}`
|
|
41
|
+
* - Or custom models with pricing:
|
|
42
|
+
* `{"provider": "custom", "model": "my-model", "is_custom": true, "input_price": 10.0, "output_price": 30.0, "context_length": 8192, "latency": 1.5}`
|
|
43
|
+
*
|
|
44
|
+
* **Training Time:**
|
|
45
|
+
*
|
|
46
|
+
* - Training is asynchronous and typically takes 5-15 minutes
|
|
47
|
+
* - Larger datasets or more models take longer
|
|
48
|
+
* - You'll receive a preference_id immediately
|
|
49
|
+
* - Check training status by attempting to use the preference_id in model_select()
|
|
50
|
+
*
|
|
51
|
+
* **Best Practices:**
|
|
52
|
+
*
|
|
53
|
+
* 1. Use diverse, representative examples from your production workload
|
|
54
|
+
* 2. Include at least 50-100 samples for best results
|
|
55
|
+
* 3. Ensure consistent evaluation metrics across all models
|
|
56
|
+
* 4. Use the same models you plan to route between in production
|
|
57
|
+
*
|
|
58
|
+
* **Related Documentation:** See
|
|
59
|
+
* https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
|
|
60
|
+
* guide.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const response =
|
|
65
|
+
* await client.customRouter.trainCustomRouter({
|
|
66
|
+
* dataset_file: fs.createReadStream('path/to/file'),
|
|
67
|
+
* language: 'english',
|
|
68
|
+
* llm_providers:
|
|
69
|
+
* '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model": "claude-sonnet-4-5-20250929"}]',
|
|
70
|
+
* maximize: true,
|
|
71
|
+
* prompt_column: 'prompt',
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
trainCustomRouter(body, options) {
|
|
76
|
+
return this._client.post('/v2/pzn/trainCustomRouter', multipartFormRequestOptions({ body, ...options }, this._client));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=custom-router.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-router.mjs","sourceRoot":"","sources":["../src/resources/custom-router.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAIf,EAAE,2BAA2B,EAAE;AAEtC,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqEG;IACH,iBAAiB,CACf,IAAyC,EACzC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,2BAA2B,EAC3B,2BAA2B,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAChE,CAAC;IACJ,CAAC;CACF"}
|
package/resources/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { CustomRouter, type CustomRouterTrainCustomRouterResponse, type CustomRouterTrainCustomRouterParams, } from "./custom-router.mjs";
|
|
2
|
+
export { ModelRouter, type ModelRouterSelectModelResponse, type ModelRouterSelectModelParams, } from "./model-router.mjs";
|
|
3
|
+
export { Models, type Model, type ModelListResponse, type ModelListParams } from "./models.mjs";
|
|
4
|
+
export { Preferences, type PreferenceCreateResponse, type PreferenceUpdateResponse, type PreferenceDeleteResponse, type PreferenceCreateParams, type PreferenceUpdateParams, } from "./preferences.mjs";
|
|
5
|
+
export { PromptAdaptation, type GoldenRecord, type JobStatus, type RequestProvider, type PromptAdaptationCreateResponse, type PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostsResponse, type PromptAdaptationCreateParams, } from "./prompt-adaptation.mjs";
|
|
6
|
+
export { Report } from "./report/report.mjs";
|
|
7
7
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EACL,YAAY,EACZ,KAAK,qCAAqC,EAC1C,KAAK,mCAAmC,GACzC;OACM,EACL,WAAW,EACX,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,GAClC;OACM,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE;OACpE,EACL,WAAW,EACX,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC5B;OACM,EACL,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,8BAA8B,EACnC,KAAK,uCAAuC,EAC5C,KAAK,sCAAsC,EAC3C,KAAK,gCAAgC,EACrC,KAAK,4BAA4B,GAClC;OACM,EAAE,MAAM,EAAE"}
|
package/resources/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { CustomRouter, type CustomRouterTrainCustomRouterResponse, type CustomRouterTrainCustomRouterParams, } from "./custom-router.js";
|
|
2
|
+
export { ModelRouter, type ModelRouterSelectModelResponse, type ModelRouterSelectModelParams, } from "./model-router.js";
|
|
3
|
+
export { Models, type Model, type ModelListResponse, type ModelListParams } from "./models.js";
|
|
4
|
+
export { Preferences, type PreferenceCreateResponse, type PreferenceUpdateResponse, type PreferenceDeleteResponse, type PreferenceCreateParams, type PreferenceUpdateParams, } from "./preferences.js";
|
|
5
|
+
export { PromptAdaptation, type GoldenRecord, type JobStatus, type RequestProvider, type PromptAdaptationCreateResponse, type PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostsResponse, type PromptAdaptationCreateParams, } from "./prompt-adaptation.js";
|
|
6
|
+
export { Report } from "./report/report.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/resources/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EACL,YAAY,EACZ,KAAK,qCAAqC,EAC1C,KAAK,mCAAmC,GACzC;OACM,EACL,WAAW,EACX,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,GAClC;OACM,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE;OACpE,EACL,WAAW,EACX,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC5B;OACM,EACL,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,8BAA8B,EACnC,KAAK,uCAAuC,EAC5C,KAAK,sCAAsC,EAC3C,KAAK,gCAAgC,EACrC,KAAK,4BAA4B,GAClC;OACM,EAAE,MAAM,EAAE"}
|
package/resources/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
var
|
|
6
|
-
Object.defineProperty(exports, "
|
|
4
|
+
exports.Report = exports.PromptAdaptation = exports.Preferences = exports.Models = exports.ModelRouter = exports.CustomRouter = void 0;
|
|
5
|
+
var custom_router_1 = require("./custom-router.js");
|
|
6
|
+
Object.defineProperty(exports, "CustomRouter", { enumerable: true, get: function () { return custom_router_1.CustomRouter; } });
|
|
7
|
+
var model_router_1 = require("./model-router.js");
|
|
8
|
+
Object.defineProperty(exports, "ModelRouter", { enumerable: true, get: function () { return model_router_1.ModelRouter; } });
|
|
7
9
|
var models_1 = require("./models.js");
|
|
8
10
|
Object.defineProperty(exports, "Models", { enumerable: true, get: function () { return models_1.Models; } });
|
|
9
11
|
var preferences_1 = require("./preferences.js");
|
|
10
12
|
Object.defineProperty(exports, "Preferences", { enumerable: true, get: function () { return preferences_1.Preferences; } });
|
|
11
13
|
var prompt_adaptation_1 = require("./prompt-adaptation.js");
|
|
12
14
|
Object.defineProperty(exports, "PromptAdaptation", { enumerable: true, get: function () { return prompt_adaptation_1.PromptAdaptation; } });
|
|
13
|
-
var report_1 = require("./report.js");
|
|
15
|
+
var report_1 = require("./report/report.js");
|
|
14
16
|
Object.defineProperty(exports, "Report", { enumerable: true, get: function () { return report_1.Report; } });
|
|
15
|
-
var routing_1 = require("./routing.js");
|
|
16
|
-
Object.defineProperty(exports, "Routing", { enumerable: true, get: function () { return routing_1.Routing; } });
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/resources/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,oDAIyB;AAHvB,6GAAA,YAAY,OAAA;AAId,kDAIwB;AAHtB,2GAAA,WAAW,OAAA;AAIb,sCAA4F;AAAnF,gGAAA,MAAM,OAAA;AACf,gDAOuB;AANrB,0GAAA,WAAW,OAAA;AAOb,4DAU6B;AAT3B,qHAAA,gBAAgB,OAAA;AAUlB,6CAAyC;AAAhC,gGAAA,MAAM,OAAA"}
|
package/resources/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
export {
|
|
2
|
+
export { CustomRouter, } from "./custom-router.mjs";
|
|
3
|
+
export { ModelRouter, } from "./model-router.mjs";
|
|
3
4
|
export { Models } from "./models.mjs";
|
|
4
5
|
export { Preferences, } from "./preferences.mjs";
|
|
5
6
|
export { PromptAdaptation, } from "./prompt-adaptation.mjs";
|
|
6
|
-
export { Report
|
|
7
|
-
export { Routing, } from "./routing.mjs";
|
|
7
|
+
export { Report } from "./report/report.mjs";
|
|
8
8
|
//# sourceMappingURL=index.mjs.map
|
package/resources/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EACL,YAAY,GAGb;OACM,EACL,WAAW,GAGZ;OACM,EAAE,MAAM,EAA4D;OACpE,EACL,WAAW,GAMZ;OACM,EACL,gBAAgB,GASjB;OACM,EAAE,MAAM,EAAE"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { APIResource } from "../core/resource.mjs";
|
|
2
|
+
import * as PromptAdaptationAPI from "./prompt-adaptation.mjs";
|
|
3
|
+
import { APIPromise } from "../core/api-promise.mjs";
|
|
4
|
+
import { RequestOptions } from "../internal/request-options.mjs";
|
|
5
|
+
export declare class ModelRouter extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Select the optimal LLM to handle your query based on Not Diamond's routing
|
|
8
|
+
* algorithm.
|
|
9
|
+
*
|
|
10
|
+
* This endpoint analyzes your messages and returns the best-suited model from your
|
|
11
|
+
* specified providers. The router considers factors like query complexity, model
|
|
12
|
+
* capabilities, cost, and latency based on your preferences.
|
|
13
|
+
*
|
|
14
|
+
* **Key Features:**
|
|
15
|
+
*
|
|
16
|
+
* - Intelligent routing across multiple LLM providers
|
|
17
|
+
* - Support for custom routers trained on your evaluation data
|
|
18
|
+
* - Optional cost/latency optimization
|
|
19
|
+
* - Function calling support for compatible models
|
|
20
|
+
* - Privacy-preserving content hashing
|
|
21
|
+
*
|
|
22
|
+
* **Usage:**
|
|
23
|
+
*
|
|
24
|
+
* 1. Pass your messages in OpenAI format (array of objects with 'role' and
|
|
25
|
+
* 'content')
|
|
26
|
+
* 2. Specify which LLM providers you want to route between
|
|
27
|
+
* 3. Optionally provide a preference_id for personalized routing
|
|
28
|
+
* 4. Receive a recommended model and session_id
|
|
29
|
+
* 5. Use the session_id to submit feedback and improve routing
|
|
30
|
+
*
|
|
31
|
+
* **Related Endpoints:**
|
|
32
|
+
*
|
|
33
|
+
* - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for
|
|
34
|
+
* personalized routing
|
|
35
|
+
* - `POST /v2/report/metrics/feedback` - Submit feedback on routing decisions
|
|
36
|
+
* - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation
|
|
37
|
+
* data
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const response = await client.modelRouter.selectModel({
|
|
42
|
+
* llm_providers: [
|
|
43
|
+
* { provider: 'openai', model: 'gpt-4o' },
|
|
44
|
+
* {
|
|
45
|
+
* provider: 'anthropic',
|
|
46
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
47
|
+
* },
|
|
48
|
+
* { provider: 'google', model: 'gemini-2.5-flash' },
|
|
49
|
+
* ],
|
|
50
|
+
* messages: [
|
|
51
|
+
* {
|
|
52
|
+
* role: 'system',
|
|
53
|
+
* content: 'You are a helpful assistant.',
|
|
54
|
+
* },
|
|
55
|
+
* {
|
|
56
|
+
* role: 'user',
|
|
57
|
+
* content: 'Explain quantum computing in simple terms',
|
|
58
|
+
* },
|
|
59
|
+
* ],
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
selectModel(params: ModelRouterSelectModelParams, options?: RequestOptions): APIPromise<ModelRouterSelectModelResponse>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Response from model selection endpoint.
|
|
67
|
+
*/
|
|
68
|
+
export interface ModelRouterSelectModelResponse {
|
|
69
|
+
/**
|
|
70
|
+
* List containing the selected provider
|
|
71
|
+
*/
|
|
72
|
+
providers: Array<ModelRouterSelectModelResponse.Provider>;
|
|
73
|
+
/**
|
|
74
|
+
* Unique session ID for this routing decision
|
|
75
|
+
*/
|
|
76
|
+
session_id: string;
|
|
77
|
+
}
|
|
78
|
+
export declare namespace ModelRouterSelectModelResponse {
|
|
79
|
+
/**
|
|
80
|
+
* Selected LLM provider information from model selection endpoints.
|
|
81
|
+
*
|
|
82
|
+
* Part of ModelSelectResponse. Contains the provider and model that Not Diamond's
|
|
83
|
+
* routing algorithm selected as optimal for your query. Use these values to make
|
|
84
|
+
* your LLM API call to the recommended model.
|
|
85
|
+
*/
|
|
86
|
+
interface Provider {
|
|
87
|
+
/**
|
|
88
|
+
* Model identifier for the selected model (e.g., 'gpt-4o',
|
|
89
|
+
* 'claude-3-opus-20240229')
|
|
90
|
+
*/
|
|
91
|
+
model: string;
|
|
92
|
+
/**
|
|
93
|
+
* Provider name for the selected model (e.g., 'openai', 'anthropic', 'google')
|
|
94
|
+
*/
|
|
95
|
+
provider: string;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export interface ModelRouterSelectModelParams {
|
|
99
|
+
/**
|
|
100
|
+
* Body param: List of LLM providers to route between. Specify at least one
|
|
101
|
+
* provider in format {provider, model}
|
|
102
|
+
*/
|
|
103
|
+
llm_providers: Array<PromptAdaptationAPI.RequestProvider | ModelRouterSelectModelParams.OpenRouterProvider>;
|
|
104
|
+
/**
|
|
105
|
+
* Body param: Array of message objects in OpenAI format (with 'role' and 'content'
|
|
106
|
+
* keys)
|
|
107
|
+
*/
|
|
108
|
+
messages: Array<{
|
|
109
|
+
[key: string]: string | Array<unknown>;
|
|
110
|
+
}> | string;
|
|
111
|
+
/**
|
|
112
|
+
* Query param: Optional format type. Use 'openrouter' to accept and return
|
|
113
|
+
* OpenRouter-format model identifiers
|
|
114
|
+
*/
|
|
115
|
+
type?: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Body param: Whether to hash message content for privacy
|
|
118
|
+
*/
|
|
119
|
+
hash_content?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Body param: Maximum number of models to consider for routing. If not specified,
|
|
122
|
+
* considers all provided models
|
|
123
|
+
*/
|
|
124
|
+
max_model_depth?: number | null;
|
|
125
|
+
/**
|
|
126
|
+
* Body param: Optimization metric for model selection
|
|
127
|
+
*/
|
|
128
|
+
metric?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Body param: Preference ID for personalized routing. Create one via POST
|
|
131
|
+
* /v2/preferences/userPreferenceCreate
|
|
132
|
+
*/
|
|
133
|
+
preference_id?: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* Body param: Previous session ID to link related requests
|
|
136
|
+
*/
|
|
137
|
+
previous_session?: string | null;
|
|
138
|
+
/**
|
|
139
|
+
* Body param: OpenAI-format function calling tools
|
|
140
|
+
*/
|
|
141
|
+
tools?: Array<{
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
}> | null;
|
|
144
|
+
/**
|
|
145
|
+
* Body param: Optimization tradeoff strategy. Use 'cost' to prioritize cost
|
|
146
|
+
* savings or 'latency' to prioritize speed
|
|
147
|
+
*/
|
|
148
|
+
tradeoff?: string | null;
|
|
149
|
+
}
|
|
150
|
+
export declare namespace ModelRouterSelectModelParams {
|
|
151
|
+
/**
|
|
152
|
+
* Model for specifying an LLM provider using OpenRouter format.
|
|
153
|
+
*
|
|
154
|
+
* Used in model routing requests when you want to specify providers using the
|
|
155
|
+
* OpenRouter naming convention (combined 'provider/model' format). This is an
|
|
156
|
+
* alternative to the standard RequestProvider which uses separate provider and
|
|
157
|
+
* model fields.
|
|
158
|
+
*
|
|
159
|
+
* **When to use:**
|
|
160
|
+
*
|
|
161
|
+
* - When working with OpenRouter-compatible systems
|
|
162
|
+
* - When you prefer the unified 'provider/model' format
|
|
163
|
+
* - For models accessed via OpenRouter proxy
|
|
164
|
+
*/
|
|
165
|
+
interface OpenRouterProvider {
|
|
166
|
+
/**
|
|
167
|
+
* OpenRouter model identifier in 'provider/model' format (e.g., 'openai/gpt-4o',
|
|
168
|
+
* 'anthropic/claude-sonnet-4-5-20250929')
|
|
169
|
+
*/
|
|
170
|
+
model: string;
|
|
171
|
+
/**
|
|
172
|
+
* Maximum context length for the model (required for custom models)
|
|
173
|
+
*/
|
|
174
|
+
context_length?: number | null;
|
|
175
|
+
/**
|
|
176
|
+
* Input token price per million tokens in USD (required for custom models)
|
|
177
|
+
*/
|
|
178
|
+
input_price?: number | null;
|
|
179
|
+
/**
|
|
180
|
+
* Whether this is a custom model not in Not Diamond's supported model list
|
|
181
|
+
*/
|
|
182
|
+
is_custom?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Average latency in seconds (required for custom models)
|
|
185
|
+
*/
|
|
186
|
+
latency?: number | null;
|
|
187
|
+
/**
|
|
188
|
+
* Output token price per million tokens in USD (required for custom models)
|
|
189
|
+
*/
|
|
190
|
+
output_price?: number | null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
export declare namespace ModelRouter {
|
|
194
|
+
export { type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=model-router.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-router.d.mts","sourceRoot":"","sources":["../src/resources/model-router.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,mBAAmB;OACxB,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,WAAW,CACT,MAAM,EAAE,4BAA4B,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,8BAA8B,CAAC;CAI9C;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAE1D;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,yBAAiB,8BAA8B,CAAC;IAC9C;;;;;;OAMG;IACH,UAAiB,QAAQ;QACvB;;;WAGG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;KAClB;CACF;AAED,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,eAAe,GAAG,4BAA4B,CAAC,kBAAkB,CAAC,CAAC;IAE5G;;;OAGG;IACH,QAAQ,EAAE,KAAK,CAAC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC,GAAG,MAAM,CAAC;IAErE;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,yBAAiB,4BAA4B,CAAC;IAC5C;;;;;;;;;;;;;OAaG;IACH,UAAiB,kBAAkB;QACjC;;;WAGG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE/B;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE5B;;WAEG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QAEpB;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAExB;;WAEG;QACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC9B;CACF;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,OAAO,EACL,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,4BAA4B,IAAI,4BAA4B,GAClE,CAAC;CACH"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { APIResource } from "../core/resource.js";
|
|
2
|
+
import * as PromptAdaptationAPI from "./prompt-adaptation.js";
|
|
3
|
+
import { APIPromise } from "../core/api-promise.js";
|
|
4
|
+
import { RequestOptions } from "../internal/request-options.js";
|
|
5
|
+
export declare class ModelRouter extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Select the optimal LLM to handle your query based on Not Diamond's routing
|
|
8
|
+
* algorithm.
|
|
9
|
+
*
|
|
10
|
+
* This endpoint analyzes your messages and returns the best-suited model from your
|
|
11
|
+
* specified providers. The router considers factors like query complexity, model
|
|
12
|
+
* capabilities, cost, and latency based on your preferences.
|
|
13
|
+
*
|
|
14
|
+
* **Key Features:**
|
|
15
|
+
*
|
|
16
|
+
* - Intelligent routing across multiple LLM providers
|
|
17
|
+
* - Support for custom routers trained on your evaluation data
|
|
18
|
+
* - Optional cost/latency optimization
|
|
19
|
+
* - Function calling support for compatible models
|
|
20
|
+
* - Privacy-preserving content hashing
|
|
21
|
+
*
|
|
22
|
+
* **Usage:**
|
|
23
|
+
*
|
|
24
|
+
* 1. Pass your messages in OpenAI format (array of objects with 'role' and
|
|
25
|
+
* 'content')
|
|
26
|
+
* 2. Specify which LLM providers you want to route between
|
|
27
|
+
* 3. Optionally provide a preference_id for personalized routing
|
|
28
|
+
* 4. Receive a recommended model and session_id
|
|
29
|
+
* 5. Use the session_id to submit feedback and improve routing
|
|
30
|
+
*
|
|
31
|
+
* **Related Endpoints:**
|
|
32
|
+
*
|
|
33
|
+
* - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for
|
|
34
|
+
* personalized routing
|
|
35
|
+
* - `POST /v2/report/metrics/feedback` - Submit feedback on routing decisions
|
|
36
|
+
* - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation
|
|
37
|
+
* data
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const response = await client.modelRouter.selectModel({
|
|
42
|
+
* llm_providers: [
|
|
43
|
+
* { provider: 'openai', model: 'gpt-4o' },
|
|
44
|
+
* {
|
|
45
|
+
* provider: 'anthropic',
|
|
46
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
47
|
+
* },
|
|
48
|
+
* { provider: 'google', model: 'gemini-2.5-flash' },
|
|
49
|
+
* ],
|
|
50
|
+
* messages: [
|
|
51
|
+
* {
|
|
52
|
+
* role: 'system',
|
|
53
|
+
* content: 'You are a helpful assistant.',
|
|
54
|
+
* },
|
|
55
|
+
* {
|
|
56
|
+
* role: 'user',
|
|
57
|
+
* content: 'Explain quantum computing in simple terms',
|
|
58
|
+
* },
|
|
59
|
+
* ],
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
selectModel(params: ModelRouterSelectModelParams, options?: RequestOptions): APIPromise<ModelRouterSelectModelResponse>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Response from model selection endpoint.
|
|
67
|
+
*/
|
|
68
|
+
export interface ModelRouterSelectModelResponse {
|
|
69
|
+
/**
|
|
70
|
+
* List containing the selected provider
|
|
71
|
+
*/
|
|
72
|
+
providers: Array<ModelRouterSelectModelResponse.Provider>;
|
|
73
|
+
/**
|
|
74
|
+
* Unique session ID for this routing decision
|
|
75
|
+
*/
|
|
76
|
+
session_id: string;
|
|
77
|
+
}
|
|
78
|
+
export declare namespace ModelRouterSelectModelResponse {
|
|
79
|
+
/**
|
|
80
|
+
* Selected LLM provider information from model selection endpoints.
|
|
81
|
+
*
|
|
82
|
+
* Part of ModelSelectResponse. Contains the provider and model that Not Diamond's
|
|
83
|
+
* routing algorithm selected as optimal for your query. Use these values to make
|
|
84
|
+
* your LLM API call to the recommended model.
|
|
85
|
+
*/
|
|
86
|
+
interface Provider {
|
|
87
|
+
/**
|
|
88
|
+
* Model identifier for the selected model (e.g., 'gpt-4o',
|
|
89
|
+
* 'claude-3-opus-20240229')
|
|
90
|
+
*/
|
|
91
|
+
model: string;
|
|
92
|
+
/**
|
|
93
|
+
* Provider name for the selected model (e.g., 'openai', 'anthropic', 'google')
|
|
94
|
+
*/
|
|
95
|
+
provider: string;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export interface ModelRouterSelectModelParams {
|
|
99
|
+
/**
|
|
100
|
+
* Body param: List of LLM providers to route between. Specify at least one
|
|
101
|
+
* provider in format {provider, model}
|
|
102
|
+
*/
|
|
103
|
+
llm_providers: Array<PromptAdaptationAPI.RequestProvider | ModelRouterSelectModelParams.OpenRouterProvider>;
|
|
104
|
+
/**
|
|
105
|
+
* Body param: Array of message objects in OpenAI format (with 'role' and 'content'
|
|
106
|
+
* keys)
|
|
107
|
+
*/
|
|
108
|
+
messages: Array<{
|
|
109
|
+
[key: string]: string | Array<unknown>;
|
|
110
|
+
}> | string;
|
|
111
|
+
/**
|
|
112
|
+
* Query param: Optional format type. Use 'openrouter' to accept and return
|
|
113
|
+
* OpenRouter-format model identifiers
|
|
114
|
+
*/
|
|
115
|
+
type?: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Body param: Whether to hash message content for privacy
|
|
118
|
+
*/
|
|
119
|
+
hash_content?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Body param: Maximum number of models to consider for routing. If not specified,
|
|
122
|
+
* considers all provided models
|
|
123
|
+
*/
|
|
124
|
+
max_model_depth?: number | null;
|
|
125
|
+
/**
|
|
126
|
+
* Body param: Optimization metric for model selection
|
|
127
|
+
*/
|
|
128
|
+
metric?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Body param: Preference ID for personalized routing. Create one via POST
|
|
131
|
+
* /v2/preferences/userPreferenceCreate
|
|
132
|
+
*/
|
|
133
|
+
preference_id?: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* Body param: Previous session ID to link related requests
|
|
136
|
+
*/
|
|
137
|
+
previous_session?: string | null;
|
|
138
|
+
/**
|
|
139
|
+
* Body param: OpenAI-format function calling tools
|
|
140
|
+
*/
|
|
141
|
+
tools?: Array<{
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
}> | null;
|
|
144
|
+
/**
|
|
145
|
+
* Body param: Optimization tradeoff strategy. Use 'cost' to prioritize cost
|
|
146
|
+
* savings or 'latency' to prioritize speed
|
|
147
|
+
*/
|
|
148
|
+
tradeoff?: string | null;
|
|
149
|
+
}
|
|
150
|
+
export declare namespace ModelRouterSelectModelParams {
|
|
151
|
+
/**
|
|
152
|
+
* Model for specifying an LLM provider using OpenRouter format.
|
|
153
|
+
*
|
|
154
|
+
* Used in model routing requests when you want to specify providers using the
|
|
155
|
+
* OpenRouter naming convention (combined 'provider/model' format). This is an
|
|
156
|
+
* alternative to the standard RequestProvider which uses separate provider and
|
|
157
|
+
* model fields.
|
|
158
|
+
*
|
|
159
|
+
* **When to use:**
|
|
160
|
+
*
|
|
161
|
+
* - When working with OpenRouter-compatible systems
|
|
162
|
+
* - When you prefer the unified 'provider/model' format
|
|
163
|
+
* - For models accessed via OpenRouter proxy
|
|
164
|
+
*/
|
|
165
|
+
interface OpenRouterProvider {
|
|
166
|
+
/**
|
|
167
|
+
* OpenRouter model identifier in 'provider/model' format (e.g., 'openai/gpt-4o',
|
|
168
|
+
* 'anthropic/claude-sonnet-4-5-20250929')
|
|
169
|
+
*/
|
|
170
|
+
model: string;
|
|
171
|
+
/**
|
|
172
|
+
* Maximum context length for the model (required for custom models)
|
|
173
|
+
*/
|
|
174
|
+
context_length?: number | null;
|
|
175
|
+
/**
|
|
176
|
+
* Input token price per million tokens in USD (required for custom models)
|
|
177
|
+
*/
|
|
178
|
+
input_price?: number | null;
|
|
179
|
+
/**
|
|
180
|
+
* Whether this is a custom model not in Not Diamond's supported model list
|
|
181
|
+
*/
|
|
182
|
+
is_custom?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Average latency in seconds (required for custom models)
|
|
185
|
+
*/
|
|
186
|
+
latency?: number | null;
|
|
187
|
+
/**
|
|
188
|
+
* Output token price per million tokens in USD (required for custom models)
|
|
189
|
+
*/
|
|
190
|
+
output_price?: number | null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
export declare namespace ModelRouter {
|
|
194
|
+
export { type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=model-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-router.d.ts","sourceRoot":"","sources":["../src/resources/model-router.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,mBAAmB;OACxB,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,WAAW,CACT,MAAM,EAAE,4BAA4B,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,8BAA8B,CAAC;CAI9C;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAE1D;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,yBAAiB,8BAA8B,CAAC;IAC9C;;;;;;OAMG;IACH,UAAiB,QAAQ;QACvB;;;WAGG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;KAClB;CACF;AAED,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,eAAe,GAAG,4BAA4B,CAAC,kBAAkB,CAAC,CAAC;IAE5G;;;OAGG;IACH,QAAQ,EAAE,KAAK,CAAC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC,GAAG,MAAM,CAAC;IAErE;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,yBAAiB,4BAA4B,CAAC;IAC5C;;;;;;;;;;;;;OAaG;IACH,UAAiB,kBAAkB;QACjC;;;WAGG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE/B;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE5B;;WAEG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QAEpB;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAExB;;WAEG;QACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC9B;CACF;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,OAAO,EACL,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,4BAA4B,IAAI,4BAA4B,GAClE,CAAC;CACH"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ModelRouter = void 0;
|
|
5
|
+
const resource_1 = require("../core/resource.js");
|
|
6
|
+
class ModelRouter extends resource_1.APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Select the optimal LLM to handle your query based on Not Diamond's routing
|
|
9
|
+
* algorithm.
|
|
10
|
+
*
|
|
11
|
+
* This endpoint analyzes your messages and returns the best-suited model from your
|
|
12
|
+
* specified providers. The router considers factors like query complexity, model
|
|
13
|
+
* capabilities, cost, and latency based on your preferences.
|
|
14
|
+
*
|
|
15
|
+
* **Key Features:**
|
|
16
|
+
*
|
|
17
|
+
* - Intelligent routing across multiple LLM providers
|
|
18
|
+
* - Support for custom routers trained on your evaluation data
|
|
19
|
+
* - Optional cost/latency optimization
|
|
20
|
+
* - Function calling support for compatible models
|
|
21
|
+
* - Privacy-preserving content hashing
|
|
22
|
+
*
|
|
23
|
+
* **Usage:**
|
|
24
|
+
*
|
|
25
|
+
* 1. Pass your messages in OpenAI format (array of objects with 'role' and
|
|
26
|
+
* 'content')
|
|
27
|
+
* 2. Specify which LLM providers you want to route between
|
|
28
|
+
* 3. Optionally provide a preference_id for personalized routing
|
|
29
|
+
* 4. Receive a recommended model and session_id
|
|
30
|
+
* 5. Use the session_id to submit feedback and improve routing
|
|
31
|
+
*
|
|
32
|
+
* **Related Endpoints:**
|
|
33
|
+
*
|
|
34
|
+
* - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for
|
|
35
|
+
* personalized routing
|
|
36
|
+
* - `POST /v2/report/metrics/feedback` - Submit feedback on routing decisions
|
|
37
|
+
* - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation
|
|
38
|
+
* data
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const response = await client.modelRouter.selectModel({
|
|
43
|
+
* llm_providers: [
|
|
44
|
+
* { provider: 'openai', model: 'gpt-4o' },
|
|
45
|
+
* {
|
|
46
|
+
* provider: 'anthropic',
|
|
47
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
48
|
+
* },
|
|
49
|
+
* { provider: 'google', model: 'gemini-2.5-flash' },
|
|
50
|
+
* ],
|
|
51
|
+
* messages: [
|
|
52
|
+
* {
|
|
53
|
+
* role: 'system',
|
|
54
|
+
* content: 'You are a helpful assistant.',
|
|
55
|
+
* },
|
|
56
|
+
* {
|
|
57
|
+
* role: 'user',
|
|
58
|
+
* content: 'Explain quantum computing in simple terms',
|
|
59
|
+
* },
|
|
60
|
+
* ],
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
selectModel(params, options) {
|
|
65
|
+
const { type, ...body } = params;
|
|
66
|
+
return this._client.post('/v2/modelRouter/modelSelect', { query: { type }, body, ...options });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ModelRouter = ModelRouter;
|
|
70
|
+
//# sourceMappingURL=model-router.js.map
|