notdiamond 2.0.0-rc2 → 2.0.0-rc20

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.
Files changed (147) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/LICENSE +1 -1
  3. package/README.md +261 -168
  4. package/client.d.mts +26 -43
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +26 -43
  7. package/client.d.ts.map +1 -1
  8. package/client.js +49 -68
  9. package/client.js.map +1 -1
  10. package/client.mjs +47 -66
  11. package/client.mjs.map +1 -1
  12. package/core/api-promise.d.mts +2 -2
  13. package/core/api-promise.d.ts +2 -2
  14. package/core/error.d.mts +2 -2
  15. package/core/error.d.ts +2 -2
  16. package/core/error.js +4 -4
  17. package/core/error.mjs +2 -2
  18. package/core/resource.d.mts +3 -3
  19. package/core/resource.d.ts +3 -3
  20. package/index.d.mts +3 -3
  21. package/index.d.ts +3 -3
  22. package/index.js +4 -4
  23. package/index.mjs +3 -3
  24. package/internal/parse.d.mts +2 -2
  25. package/internal/parse.d.ts +2 -2
  26. package/internal/shims.js +1 -1
  27. package/internal/shims.mjs +1 -1
  28. package/internal/uploads.d.mts +4 -4
  29. package/internal/uploads.d.ts +4 -4
  30. package/internal/utils/base64.js +2 -2
  31. package/internal/utils/base64.mjs +3 -3
  32. package/internal/utils/env.d.mts.map +1 -1
  33. package/internal/utils/env.d.ts.map +1 -1
  34. package/internal/utils/env.js +4 -2
  35. package/internal/utils/env.js.map +1 -1
  36. package/internal/utils/env.mjs +4 -2
  37. package/internal/utils/env.mjs.map +1 -1
  38. package/internal/utils/log.d.mts +3 -3
  39. package/internal/utils/log.d.ts +3 -3
  40. package/internal/utils/path.js +1 -1
  41. package/internal/utils/path.mjs +2 -2
  42. package/internal/utils/values.js +5 -5
  43. package/internal/utils/values.mjs +6 -6
  44. package/package.json +11 -12
  45. package/resources/custom-router.d.mts +145 -0
  46. package/resources/custom-router.d.mts.map +1 -0
  47. package/resources/custom-router.d.ts +145 -0
  48. package/resources/custom-router.d.ts.map +1 -0
  49. package/resources/custom-router.js +83 -0
  50. package/resources/custom-router.js.map +1 -0
  51. package/resources/custom-router.mjs +79 -0
  52. package/resources/custom-router.mjs.map +1 -0
  53. package/resources/index.d.mts +5 -6
  54. package/resources/index.d.mts.map +1 -1
  55. package/resources/index.d.ts +5 -6
  56. package/resources/index.d.ts.map +1 -1
  57. package/resources/index.js +5 -7
  58. package/resources/index.js.map +1 -1
  59. package/resources/index.mjs +2 -3
  60. package/resources/index.mjs.map +1 -1
  61. package/resources/model-router.d.mts +194 -0
  62. package/resources/model-router.d.mts.map +1 -0
  63. package/resources/model-router.d.ts +194 -0
  64. package/resources/model-router.d.ts.map +1 -0
  65. package/resources/model-router.js +68 -0
  66. package/resources/model-router.js.map +1 -0
  67. package/resources/model-router.mjs +64 -0
  68. package/resources/model-router.mjs.map +1 -0
  69. package/resources/models.d.mts +50 -25
  70. package/resources/models.d.mts.map +1 -1
  71. package/resources/models.d.ts +50 -25
  72. package/resources/models.d.ts.map +1 -1
  73. package/resources/models.js +5 -0
  74. package/resources/models.js.map +1 -1
  75. package/resources/models.mjs +5 -0
  76. package/resources/models.mjs.map +1 -1
  77. package/resources/preferences.d.mts +37 -54
  78. package/resources/preferences.d.mts.map +1 -1
  79. package/resources/preferences.d.ts +37 -54
  80. package/resources/preferences.d.ts.map +1 -1
  81. package/resources/preferences.js +17 -42
  82. package/resources/preferences.js.map +1 -1
  83. package/resources/preferences.mjs +17 -42
  84. package/resources/preferences.mjs.map +1 -1
  85. package/resources/prompt-adaptation.d.mts +340 -249
  86. package/resources/prompt-adaptation.d.mts.map +1 -1
  87. package/resources/prompt-adaptation.d.ts +340 -249
  88. package/resources/prompt-adaptation.d.ts.map +1 -1
  89. package/resources/prompt-adaptation.js +36 -79
  90. package/resources/prompt-adaptation.js.map +1 -1
  91. package/resources/prompt-adaptation.mjs +36 -79
  92. package/resources/prompt-adaptation.mjs.map +1 -1
  93. package/src/client.ts +72 -128
  94. package/src/core/api-promise.ts +4 -4
  95. package/src/core/error.ts +2 -2
  96. package/src/core/resource.ts +3 -3
  97. package/src/index.ts +3 -3
  98. package/src/internal/parse.ts +2 -2
  99. package/src/internal/shims.ts +1 -1
  100. package/src/internal/uploads.ts +5 -5
  101. package/src/internal/utils/base64.ts +3 -3
  102. package/src/internal/utils/env.ts +4 -2
  103. package/src/internal/utils/log.ts +3 -3
  104. package/src/internal/utils/path.ts +2 -2
  105. package/src/internal/utils/values.ts +6 -6
  106. package/src/resources/custom-router.ts +168 -0
  107. package/src/resources/index.ts +20 -32
  108. package/src/resources/model-router.ts +222 -0
  109. package/src/resources/models.ts +55 -32
  110. package/src/resources/preferences.ts +43 -83
  111. package/src/resources/prompt-adaptation.ts +358 -300
  112. package/src/version.ts +1 -1
  113. package/version.d.mts +1 -1
  114. package/version.d.mts.map +1 -1
  115. package/version.d.ts +1 -1
  116. package/version.d.ts.map +1 -1
  117. package/version.js +1 -1
  118. package/version.js.map +1 -1
  119. package/version.mjs +1 -1
  120. package/version.mjs.map +1 -1
  121. package/resources/admin.d.mts +0 -4
  122. package/resources/admin.d.mts.map +0 -1
  123. package/resources/admin.d.ts +0 -4
  124. package/resources/admin.d.ts.map +0 -1
  125. package/resources/admin.js +0 -9
  126. package/resources/admin.js.map +0 -1
  127. package/resources/admin.mjs +0 -5
  128. package/resources/admin.mjs.map +0 -1
  129. package/resources/report.d.mts +0 -245
  130. package/resources/report.d.mts.map +0 -1
  131. package/resources/report.d.ts +0 -245
  132. package/resources/report.d.ts.map +0 -1
  133. package/resources/report.js +0 -86
  134. package/resources/report.js.map +0 -1
  135. package/resources/report.mjs +0 -82
  136. package/resources/report.mjs.map +0 -1
  137. package/resources/routing.d.mts +0 -391
  138. package/resources/routing.d.mts.map +0 -1
  139. package/resources/routing.d.ts +0 -391
  140. package/resources/routing.d.ts.map +0 -1
  141. package/resources/routing.js +0 -163
  142. package/resources/routing.js.map +0 -1
  143. package/resources/routing.mjs +0 -159
  144. package/resources/routing.mjs.map +0 -1
  145. package/src/resources/admin.ts +0 -5
  146. package/src/resources/report.ts +0 -300
  147. package/src/resources/routing.ts +0 -476
@@ -0,0 +1,83 @@
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.CustomRouter = void 0;
5
+ const resource_1 = require("../core/resource.js");
6
+ const uploads_1 = require("../internal/uploads.js");
7
+ class CustomRouter extends resource_1.APIResource {
8
+ /**
9
+ * Train a custom router on your evaluation data to optimize routing for your
10
+ * specific use case.
11
+ *
12
+ * This endpoint allows you to train a domain-specific router that learns which
13
+ * models perform best for different types of queries in your application. The
14
+ * router analyzes your evaluation dataset, clusters similar queries, and learns
15
+ * model performance patterns.
16
+ *
17
+ * **Training Process:**
18
+ *
19
+ * 1. Upload a CSV file with your evaluation data
20
+ * 2. Specify which models to route between
21
+ * 3. Define the evaluation metric (score column)
22
+ * 4. The system trains asynchronously and returns a preference_id
23
+ * 5. Use the preference_id in model_select() calls once training completes
24
+ *
25
+ * **Dataset Requirements:**
26
+ *
27
+ * - Format: CSV file
28
+ * - Minimum samples: 25 (more is better for accuracy)
29
+ * - Required columns:
30
+ * - Prompt column (specified in prompt_column parameter)
31
+ * - For each model: `{provider}/{model}/score` and `{provider}/{model}/response`
32
+ *
33
+ * **Example CSV structure:**
34
+ *
35
+ * ```
36
+ * prompt,openai/gpt-4o/score,openai/gpt-4o/response,anthropic/claude-sonnet-4-5-20250929/score,anthropic/claude-sonnet-4-5-20250929/response
37
+ * "Explain quantum computing",0.95,"Quantum computing uses...",0.87,"Quantum computers leverage..."
38
+ * "Write a Python function",0.82,"def my_function()...",0.91,"Here's a Python function..."
39
+ * ```
40
+ *
41
+ * **Model Selection:**
42
+ *
43
+ * - Specify standard models: `{"provider": "openai", "model": "gpt-4o"}`
44
+ * - Or custom models with pricing:
45
+ * `{"provider": "custom", "model": "my-model", "is_custom": true, "input_price": 10.0, "output_price": 30.0, "context_length": 8192, "latency": 1.5}`
46
+ *
47
+ * **Training Time:**
48
+ *
49
+ * - Training is asynchronous and typically takes 5-15 minutes
50
+ * - Larger datasets or more models take longer
51
+ * - You'll receive a preference_id immediately
52
+ * - Check training status by attempting to use the preference_id in model_select()
53
+ *
54
+ * **Best Practices:**
55
+ *
56
+ * 1. Use diverse, representative examples from your production workload
57
+ * 2. Include at least 50-100 samples for best results
58
+ * 3. Ensure consistent evaluation metrics across all models
59
+ * 4. Use the same models you plan to route between in production
60
+ *
61
+ * **Related Documentation:** See
62
+ * https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
63
+ * guide.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const response =
68
+ * await client.customRouter.trainCustomRouter({
69
+ * dataset_file: fs.createReadStream('path/to/file'),
70
+ * language: 'english',
71
+ * llm_providers:
72
+ * '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model": "claude-sonnet-4-5-20250929"}]',
73
+ * maximize: true,
74
+ * prompt_column: 'prompt',
75
+ * });
76
+ * ```
77
+ */
78
+ trainCustomRouter(body, options) {
79
+ return this._client.post('/v2/pzn/trainCustomRouter', (0, uploads_1.multipartFormRequestOptions)({ body, ...options }, this._client));
80
+ }
81
+ }
82
+ exports.CustomRouter = CustomRouter;
83
+ //# sourceMappingURL=custom-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-router.js","sourceRoot":"","sources":["../src/resources/custom-router.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,oDAAkE;AAElE,MAAa,YAAa,SAAQ,sBAAW;IAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqEG;IACH,iBAAiB,CACf,IAAyC,EACzC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,2BAA2B,EAC3B,IAAA,qCAA2B,EAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAChE,CAAC;IACJ,CAAC;CACF;AAhFD,oCAgFC"}
@@ -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"}
@@ -1,7 +1,6 @@
1
- export { Admin } from "./admin.mjs";
2
- export { Models, type ModelListResponse, type ModelListParams } from "./models.mjs";
3
- export { Preferences, type PreferenceRetrieveResponse, type PreferenceCreateUserPreferenceResponse, type PreferenceDeleteUserPreferenceResponse, type PreferenceUpdateUserPreferenceResponse, type PreferenceRetrieveParams, type PreferenceCreateUserPreferenceParams, type PreferenceUpdateUserPreferenceParams, } from "./preferences.mjs";
4
- export { PromptAdaptation, type AdaptationRunResults, type JobStatus, type PromptAdaptationAdaptResponse, type PromptAdaptationGetAdaptRunsResponse, type PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationRetrieveCostsResponse, type PromptAdaptationAdaptParams, type PromptAdaptationGetAdaptRunResultsParams, type PromptAdaptationGetAdaptRunsParams, } from "./prompt-adaptation.mjs";
5
- export { Report, type ReportEvaluateHallucinationResponse, type ReportLatencyResponse, type ReportSubmitFeedbackResponse, type ReportEvaluateHallucinationParams, type ReportLatencyParams, type ReportSubmitFeedbackParams, } from "./report.mjs";
6
- export { Routing, type RoutingCreateSurveyResponseResponse, type RoutingSelectModelResponse, type RoutingTrainCustomRouterResponse, type RoutingCreateSurveyResponseParams, type RoutingSelectModelParams, type RoutingTrainCustomRouterParams, } from "./routing.mjs";
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 PromptAdaptationAdaptResponse, type PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostResponse, type PromptAdaptationAdaptParams, } from "./prompt-adaptation.mjs";
7
6
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EAAE,KAAK,EAAE;OACT,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE;OACxD,EACL,WAAW,EACX,KAAK,0BAA0B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,EAC3C,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,oCAAoC,GAC1C;OACM,EACL,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,6BAA6B,EAClC,KAAK,oCAAoC,EACzC,KAAK,sCAAsC,EAC3C,KAAK,qCAAqC,EAC1C,KAAK,2BAA2B,EAChC,KAAK,wCAAwC,EAC7C,KAAK,kCAAkC,GACxC;OACM,EACL,MAAM,EACN,KAAK,mCAAmC,EACxC,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,GAChC;OACM,EACL,OAAO,EACP,KAAK,mCAAmC,EACxC,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACrC,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,GACpC"}
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,6BAA6B,EAClC,KAAK,uCAAuC,EAC5C,KAAK,sCAAsC,EAC3C,KAAK,+BAA+B,EACpC,KAAK,2BAA2B,GACjC"}
@@ -1,7 +1,6 @@
1
- export { Admin } from "./admin.js";
2
- export { Models, type ModelListResponse, type ModelListParams } from "./models.js";
3
- export { Preferences, type PreferenceRetrieveResponse, type PreferenceCreateUserPreferenceResponse, type PreferenceDeleteUserPreferenceResponse, type PreferenceUpdateUserPreferenceResponse, type PreferenceRetrieveParams, type PreferenceCreateUserPreferenceParams, type PreferenceUpdateUserPreferenceParams, } from "./preferences.js";
4
- export { PromptAdaptation, type AdaptationRunResults, type JobStatus, type PromptAdaptationAdaptResponse, type PromptAdaptationGetAdaptRunsResponse, type PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationRetrieveCostsResponse, type PromptAdaptationAdaptParams, type PromptAdaptationGetAdaptRunResultsParams, type PromptAdaptationGetAdaptRunsParams, } from "./prompt-adaptation.js";
5
- export { Report, type ReportEvaluateHallucinationResponse, type ReportLatencyResponse, type ReportSubmitFeedbackResponse, type ReportEvaluateHallucinationParams, type ReportLatencyParams, type ReportSubmitFeedbackParams, } from "./report.js";
6
- export { Routing, type RoutingCreateSurveyResponseResponse, type RoutingSelectModelResponse, type RoutingTrainCustomRouterResponse, type RoutingCreateSurveyResponseParams, type RoutingSelectModelParams, type RoutingTrainCustomRouterParams, } from "./routing.js";
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 PromptAdaptationAdaptResponse, type PromptAdaptationGetAdaptResultsResponse, type PromptAdaptationGetAdaptStatusResponse, type PromptAdaptationGetCostResponse, type PromptAdaptationAdaptParams, } from "./prompt-adaptation.js";
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EAAE,KAAK,EAAE;OACT,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE;OACxD,EACL,WAAW,EACX,KAAK,0BAA0B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,EAC3C,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,oCAAoC,GAC1C;OACM,EACL,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,6BAA6B,EAClC,KAAK,oCAAoC,EACzC,KAAK,sCAAsC,EAC3C,KAAK,qCAAqC,EAC1C,KAAK,2BAA2B,EAChC,KAAK,wCAAwC,EAC7C,KAAK,kCAAkC,GACxC;OACM,EACL,MAAM,EACN,KAAK,mCAAmC,EACxC,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,GAChC;OACM,EACL,OAAO,EACP,KAAK,mCAAmC,EACxC,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACrC,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,GACpC"}
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,6BAA6B,EAClC,KAAK,uCAAuC,EAC5C,KAAK,sCAAsC,EAC3C,KAAK,+BAA+B,EACpC,KAAK,2BAA2B,GACjC"}
@@ -1,17 +1,15 @@
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.Routing = exports.Report = exports.PromptAdaptation = exports.Preferences = exports.Models = exports.Admin = void 0;
5
- var admin_1 = require("./admin.js");
6
- Object.defineProperty(exports, "Admin", { enumerable: true, get: function () { return admin_1.Admin; } });
4
+ 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");
14
- 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
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,oCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,sCAAgF;AAAvE,gGAAA,MAAM,OAAA;AACf,gDASuB;AARrB,0GAAA,WAAW,OAAA;AASb,4DAW6B;AAV3B,qHAAA,gBAAgB,OAAA;AAWlB,sCAQkB;AAPhB,gGAAA,MAAM,OAAA;AAQR,wCAQmB;AAPjB,kGAAA,OAAO,OAAA"}
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"}
@@ -1,8 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
- export { Admin } from "./admin.mjs";
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, } from "./report.mjs";
7
- export { Routing, } from "./routing.mjs";
8
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,KAAK,EAAE;OACT,EAAE,MAAM,EAAgD;OACxD,EACL,WAAW,GAQZ;OACM,EACL,gBAAgB,GAUjB;OACM,EACL,MAAM,GAOP;OACM,EACL,OAAO,GAOR"}
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"}
@@ -0,0 +1,194 @@
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 models. 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
+ *
21
+ * **Usage:**
22
+ *
23
+ * 1. Pass your messages in OpenAI format (array of objects with 'role' and
24
+ * 'content')
25
+ * 2. Specify which LLM providers you want to route between
26
+ * 3. Optionally provide a preference_id to use a custom router that you've trained
27
+ * 4. Receive a recommended model and session_id
28
+ * 5. Use the session_id to submit feedback and improve routing
29
+ *
30
+ * **Related Endpoints:**
31
+ *
32
+ * - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for
33
+ * personalized routing
34
+ * - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation
35
+ * data
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const response = await client.modelRouter.selectModel({
40
+ * llm_providers: [
41
+ * { provider: 'openai', model: 'gpt-4o' },
42
+ * {
43
+ * provider: 'anthropic',
44
+ * model: 'claude-sonnet-4-5-20250929',
45
+ * },
46
+ * { provider: 'google', model: 'gemini-2.5-flash' },
47
+ * ],
48
+ * messages: [
49
+ * {
50
+ * role: 'system',
51
+ * content: 'You are a helpful assistant.',
52
+ * },
53
+ * {
54
+ * role: 'user',
55
+ * content: 'Explain quantum computing in simple terms',
56
+ * },
57
+ * ],
58
+ * });
59
+ * ```
60
+ */
61
+ selectModel(params: ModelRouterSelectModelParams, options?: RequestOptions): APIPromise<ModelRouterSelectModelResponse>;
62
+ }
63
+ /**
64
+ * Response from model selection endpoint.
65
+ */
66
+ export interface ModelRouterSelectModelResponse {
67
+ /**
68
+ * List containing the selected provider
69
+ */
70
+ providers: Array<ModelRouterSelectModelResponse.Provider>;
71
+ /**
72
+ * Unique session ID for this routing decision
73
+ */
74
+ session_id: string;
75
+ }
76
+ export declare namespace ModelRouterSelectModelResponse {
77
+ /**
78
+ * Selected LLM provider information from model selection endpoints.
79
+ *
80
+ * Part of ModelSelectResponse. Contains the provider and model that Not Diamond's
81
+ * routing algorithm selected as optimal for your query. Use these values to make
82
+ * your LLM API call to the recommended model.
83
+ */
84
+ interface Provider {
85
+ /**
86
+ * Model identifier for the selected model (e.g., 'gpt-4o',
87
+ * 'claude-3-opus-20240229')
88
+ */
89
+ model: string;
90
+ /**
91
+ * Provider name for the selected model (e.g., 'openai', 'anthropic', 'google')
92
+ */
93
+ provider: string;
94
+ }
95
+ }
96
+ export interface ModelRouterSelectModelParams {
97
+ /**
98
+ * Body param: List of LLM providers to route between. Specify at least one
99
+ * provider in format {provider, model}
100
+ */
101
+ llm_providers: Array<PromptAdaptationAPI.RequestProvider | ModelRouterSelectModelParams.OpenRouterProvider>;
102
+ /**
103
+ * Body param: Array of message objects in OpenAI format (with 'role' and 'content'
104
+ * keys)
105
+ */
106
+ messages: Array<{
107
+ [key: string]: string | Array<unknown>;
108
+ }> | string;
109
+ /**
110
+ * Query param: Optional format type. Use 'openrouter' to accept and return
111
+ * OpenRouter-format model identifiers
112
+ */
113
+ type?: string | null;
114
+ /**
115
+ * Body param: Whether to hash message content for privacy
116
+ */
117
+ hash_content?: boolean;
118
+ /**
119
+ * Body param: Maximum number of models to consider for routing. If not specified,
120
+ * considers all provided models
121
+ */
122
+ max_model_depth?: number | null;
123
+ /**
124
+ * Body param: Optimization metric for model selection
125
+ */
126
+ metric?: string;
127
+ /**
128
+ * Body param: Preference ID for personalized routing. Create one via POST
129
+ * /v2/preferences/userPreferenceCreate
130
+ */
131
+ preference_id?: string | null;
132
+ /**
133
+ * Body param: Previous session ID to link related requests
134
+ */
135
+ previous_session?: string | null;
136
+ /**
137
+ * Body param: OpenAI-format function calling tools
138
+ */
139
+ tools?: Array<{
140
+ [key: string]: unknown;
141
+ }> | null;
142
+ /**
143
+ * Body param: Optimization tradeoff strategy. Use 'cost' to prioritize cost
144
+ * savings or 'latency' to prioritize speed
145
+ */
146
+ tradeoff?: string | null;
147
+ }
148
+ export declare namespace ModelRouterSelectModelParams {
149
+ /**
150
+ * Model for specifying an LLM provider using OpenRouter format.
151
+ *
152
+ * Used in model routing requests when you want to specify providers using the
153
+ * OpenRouter naming convention (combined 'provider/model' format). This is an
154
+ * alternative to the standard RequestProvider which uses separate provider and
155
+ * model fields.
156
+ *
157
+ * **When to use:**
158
+ *
159
+ * - When working with OpenRouter-compatible systems
160
+ * - When you prefer the unified 'provider/model' format
161
+ * - For models accessed via OpenRouter proxy
162
+ */
163
+ interface OpenRouterProvider {
164
+ /**
165
+ * OpenRouter model identifier in 'provider/model' format (e.g., 'openai/gpt-4o',
166
+ * 'anthropic/claude-sonnet-4-5-20250929')
167
+ */
168
+ model: string;
169
+ /**
170
+ * Maximum context length for the model (required for custom models)
171
+ */
172
+ context_length?: number | null;
173
+ /**
174
+ * Input token price per million tokens in USD (required for custom models)
175
+ */
176
+ input_price?: number | null;
177
+ /**
178
+ * Whether this is a custom model not in Not Diamond's supported model list
179
+ */
180
+ is_custom?: boolean;
181
+ /**
182
+ * Average latency in seconds (required for custom models)
183
+ */
184
+ latency?: number | null;
185
+ /**
186
+ * Output token price per million tokens in USD (required for custom models)
187
+ */
188
+ output_price?: number | null;
189
+ }
190
+ }
191
+ export declare namespace ModelRouter {
192
+ export { type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
193
+ }
194
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsDG;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"}