notdiamond 2.0.0-rc1 → 2.0.0-rc4

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 (167) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +19 -21
  3. package/client.d.mts +21 -35
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +21 -35
  6. package/client.d.ts.map +1 -1
  7. package/client.js +23 -39
  8. package/client.js.map +1 -1
  9. package/client.mjs +23 -39
  10. package/client.mjs.map +1 -1
  11. package/internal/tslib.js +17 -17
  12. package/internal/utils/env.d.mts.map +1 -1
  13. package/internal/utils/env.d.ts.map +1 -1
  14. package/internal/utils/env.js +4 -2
  15. package/internal/utils/env.js.map +1 -1
  16. package/internal/utils/env.mjs +4 -2
  17. package/internal/utils/env.mjs.map +1 -1
  18. package/package.json +10 -11
  19. package/resources/index.d.mts +6 -6
  20. package/resources/index.d.mts.map +1 -1
  21. package/resources/index.d.ts +6 -6
  22. package/resources/index.d.ts.map +1 -1
  23. package/resources/index.js +8 -8
  24. package/resources/index.js.map +1 -1
  25. package/resources/index.mjs +4 -4
  26. package/resources/index.mjs.map +1 -1
  27. package/resources/model-router.d.mts +311 -0
  28. package/resources/model-router.d.mts.map +1 -0
  29. package/resources/model-router.d.ts +311 -0
  30. package/resources/model-router.d.ts.map +1 -0
  31. package/resources/model-router.js +97 -0
  32. package/resources/model-router.js.map +1 -0
  33. package/resources/model-router.mjs +93 -0
  34. package/resources/model-router.mjs.map +1 -0
  35. package/resources/models.d.mts +50 -25
  36. package/resources/models.d.mts.map +1 -1
  37. package/resources/models.d.ts +50 -25
  38. package/resources/models.d.ts.map +1 -1
  39. package/resources/models.js +5 -0
  40. package/resources/models.js.map +1 -1
  41. package/resources/models.mjs +5 -0
  42. package/resources/models.mjs.map +1 -1
  43. package/resources/preferences.d.mts +49 -47
  44. package/resources/preferences.d.mts.map +1 -1
  45. package/resources/preferences.d.ts +49 -47
  46. package/resources/preferences.d.ts.map +1 -1
  47. package/resources/preferences.js +30 -33
  48. package/resources/preferences.js.map +1 -1
  49. package/resources/preferences.mjs +30 -33
  50. package/resources/preferences.mjs.map +1 -1
  51. package/resources/prompt/adapt.d.mts +352 -0
  52. package/resources/prompt/adapt.d.mts.map +1 -0
  53. package/resources/prompt/adapt.d.ts +352 -0
  54. package/resources/prompt/adapt.d.ts.map +1 -0
  55. package/resources/prompt/adapt.js +154 -0
  56. package/resources/prompt/adapt.js.map +1 -0
  57. package/resources/prompt/adapt.mjs +150 -0
  58. package/resources/prompt/adapt.mjs.map +1 -0
  59. package/resources/prompt/index.d.mts +3 -0
  60. package/resources/prompt/index.d.mts.map +1 -0
  61. package/resources/prompt/index.d.ts +3 -0
  62. package/resources/prompt/index.d.ts.map +1 -0
  63. package/resources/prompt/index.js +9 -0
  64. package/resources/prompt/index.js.map +1 -0
  65. package/resources/prompt/index.mjs +4 -0
  66. package/resources/prompt/index.mjs.map +1 -0
  67. package/resources/prompt/prompt.d.mts +338 -0
  68. package/resources/prompt/prompt.d.mts.map +1 -0
  69. package/resources/prompt/prompt.d.ts +338 -0
  70. package/resources/prompt/prompt.d.ts.map +1 -0
  71. package/resources/prompt/prompt.js +128 -0
  72. package/resources/prompt/prompt.js.map +1 -0
  73. package/resources/prompt/prompt.mjs +123 -0
  74. package/resources/prompt/prompt.mjs.map +1 -0
  75. package/resources/prompt.d.mts +2 -0
  76. package/resources/prompt.d.mts.map +1 -0
  77. package/resources/prompt.d.ts +2 -0
  78. package/resources/prompt.d.ts.map +1 -0
  79. package/resources/prompt.js +6 -0
  80. package/resources/prompt.js.map +1 -0
  81. package/resources/prompt.mjs +3 -0
  82. package/resources/prompt.mjs.map +1 -0
  83. package/resources/pzn.d.mts +225 -0
  84. package/resources/pzn.d.mts.map +1 -0
  85. package/resources/pzn.d.ts +225 -0
  86. package/resources/pzn.d.ts.map +1 -0
  87. package/resources/{routing.js → pzn.js} +28 -71
  88. package/resources/pzn.js.map +1 -0
  89. package/resources/{routing.mjs → pzn.mjs} +26 -69
  90. package/resources/pzn.mjs.map +1 -0
  91. package/resources/report/index.d.mts +3 -0
  92. package/resources/report/index.d.mts.map +1 -0
  93. package/resources/report/index.d.ts +3 -0
  94. package/resources/report/index.d.ts.map +1 -0
  95. package/resources/report/index.js +9 -0
  96. package/resources/report/index.js.map +1 -0
  97. package/resources/report/index.mjs +4 -0
  98. package/resources/report/index.mjs.map +1 -0
  99. package/resources/report/metrics.d.mts +87 -0
  100. package/resources/report/metrics.d.mts.map +1 -0
  101. package/resources/report/metrics.d.ts +87 -0
  102. package/resources/report/metrics.d.ts.map +1 -0
  103. package/resources/report/metrics.js +57 -0
  104. package/resources/report/metrics.js.map +1 -0
  105. package/resources/report/metrics.mjs +53 -0
  106. package/resources/report/metrics.mjs.map +1 -0
  107. package/resources/report/report.d.mts +10 -0
  108. package/resources/report/report.d.mts.map +1 -0
  109. package/resources/report/report.d.ts +10 -0
  110. package/resources/report/report.d.ts.map +1 -0
  111. package/resources/report/report.js +17 -0
  112. package/resources/report/report.js.map +1 -0
  113. package/resources/report/report.mjs +12 -0
  114. package/resources/report/report.mjs.map +1 -0
  115. package/resources/report.d.mts +1 -244
  116. package/resources/report.d.mts.map +1 -1
  117. package/resources/report.d.ts +1 -244
  118. package/resources/report.d.ts.map +1 -1
  119. package/resources/report.js +2 -82
  120. package/resources/report.js.map +1 -1
  121. package/resources/report.mjs +1 -80
  122. package/resources/report.mjs.map +1 -1
  123. package/src/client.ts +71 -120
  124. package/src/internal/utils/env.ts +4 -2
  125. package/src/resources/index.ts +24 -34
  126. package/src/resources/model-router.ts +356 -0
  127. package/src/resources/models.ts +55 -32
  128. package/src/resources/preferences.ts +61 -70
  129. package/src/resources/prompt/adapt.ts +402 -0
  130. package/src/resources/prompt/index.ts +16 -0
  131. package/src/resources/prompt/prompt.ts +398 -0
  132. package/src/resources/prompt.ts +3 -0
  133. package/src/resources/pzn.ts +273 -0
  134. package/src/resources/report/index.ts +4 -0
  135. package/src/resources/report/metrics.ts +99 -0
  136. package/src/resources/report/report.ts +19 -0
  137. package/src/resources/report.ts +1 -298
  138. package/src/version.ts +1 -1
  139. package/version.d.mts +1 -1
  140. package/version.d.ts +1 -1
  141. package/version.js +1 -1
  142. package/version.mjs +1 -1
  143. package/resources/admin.d.mts +0 -4
  144. package/resources/admin.d.mts.map +0 -1
  145. package/resources/admin.d.ts +0 -4
  146. package/resources/admin.d.ts.map +0 -1
  147. package/resources/admin.js +0 -9
  148. package/resources/admin.js.map +0 -1
  149. package/resources/admin.mjs +0 -5
  150. package/resources/admin.mjs.map +0 -1
  151. package/resources/prompt-adaptation.d.mts +0 -574
  152. package/resources/prompt-adaptation.d.mts.map +0 -1
  153. package/resources/prompt-adaptation.d.ts +0 -574
  154. package/resources/prompt-adaptation.d.ts.map +0 -1
  155. package/resources/prompt-adaptation.js +0 -289
  156. package/resources/prompt-adaptation.js.map +0 -1
  157. package/resources/prompt-adaptation.mjs +0 -285
  158. package/resources/prompt-adaptation.mjs.map +0 -1
  159. package/resources/routing.d.mts +0 -391
  160. package/resources/routing.d.mts.map +0 -1
  161. package/resources/routing.d.ts +0 -391
  162. package/resources/routing.d.ts.map +0 -1
  163. package/resources/routing.js.map +0 -1
  164. package/resources/routing.mjs.map +0 -1
  165. package/src/resources/admin.ts +0 -5
  166. package/src/resources/prompt-adaptation.ts +0 -700
  167. package/src/resources/routing.ts +0 -476
@@ -0,0 +1,311 @@
1
+ import { APIResource } from "../core/resource.mjs";
2
+ import * as AdaptAPI from "./prompt/adapt.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
+ * Openhands Model Select
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const response = await client.modelRouter.openHandsSelect({
12
+ * llm_providers: [
13
+ * { model: 'gpt-4o', provider: 'openai' },
14
+ * {
15
+ * model: 'claude-sonnet-4-5-20250929',
16
+ * provider: 'anthropic',
17
+ * },
18
+ * { model: 'gemini-1.5-pro', provider: 'google' },
19
+ * ],
20
+ * messages: [
21
+ * {
22
+ * content: 'You are a helpful assistant.',
23
+ * role: 'system',
24
+ * },
25
+ * { content: 'Explain quantum computing', role: 'user' },
26
+ * ],
27
+ * });
28
+ * ```
29
+ */
30
+ openHandsSelect(body: ModelRouterOpenHandsSelectParams, options?: RequestOptions): APIPromise<unknown>;
31
+ /**
32
+ * Select the optimal LLM to handle your query based on Not Diamond's routing
33
+ * algorithm.
34
+ *
35
+ * This endpoint analyzes your messages and returns the best-suited model from your
36
+ * specified providers. The router considers factors like query complexity, model
37
+ * capabilities, cost, and latency based on your preferences.
38
+ *
39
+ * **Key Features:**
40
+ *
41
+ * - Intelligent routing across multiple LLM providers
42
+ * - Support for custom routers trained on your evaluation data
43
+ * - Optional cost/latency optimization
44
+ * - Function calling support for compatible models
45
+ * - Privacy-preserving content hashing
46
+ *
47
+ * **Usage:**
48
+ *
49
+ * 1. Pass your messages in OpenAI format (array of objects with 'role' and
50
+ * 'content')
51
+ * 2. Specify which LLM providers you want to route between
52
+ * 3. Optionally provide a preference_id for personalized routing
53
+ * 4. Receive a recommended model and session_id
54
+ * 5. Use the session_id to submit feedback and improve routing
55
+ *
56
+ * **Related Endpoints:**
57
+ *
58
+ * - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for
59
+ * personalized routing
60
+ * - `POST /v2/report/metrics/feedback` - Submit feedback on routing decisions
61
+ * - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation
62
+ * data
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const response = await client.modelRouter.selectModel({
67
+ * llm_providers: [
68
+ * { provider: 'openai', model: 'gpt-4o' },
69
+ * {
70
+ * provider: 'anthropic',
71
+ * model: 'claude-sonnet-4-5-20250929',
72
+ * },
73
+ * { provider: 'google', model: 'gemini-1.5-pro' },
74
+ * ],
75
+ * messages: [
76
+ * {
77
+ * role: 'system',
78
+ * content: 'You are a helpful assistant.',
79
+ * },
80
+ * {
81
+ * role: 'user',
82
+ * content: 'Explain quantum computing in simple terms',
83
+ * },
84
+ * ],
85
+ * });
86
+ * ```
87
+ */
88
+ selectModel(params: ModelRouterSelectModelParams, options?: RequestOptions): APIPromise<ModelRouterSelectModelResponse>;
89
+ }
90
+ export type ModelRouterOpenHandsSelectResponse = unknown;
91
+ /**
92
+ * Response from model selection endpoint.
93
+ */
94
+ export interface ModelRouterSelectModelResponse {
95
+ /**
96
+ * List containing the selected provider
97
+ */
98
+ providers: Array<ModelRouterSelectModelResponse.Provider>;
99
+ /**
100
+ * Unique session ID for this routing decision
101
+ */
102
+ session_id: string;
103
+ }
104
+ export declare namespace ModelRouterSelectModelResponse {
105
+ /**
106
+ * Selected LLM provider information from model selection endpoints.
107
+ *
108
+ * Part of ModelSelectResponse. Contains the provider and model that Not Diamond's
109
+ * routing algorithm selected as optimal for your query. Use these values to make
110
+ * your LLM API call to the recommended model.
111
+ */
112
+ interface Provider {
113
+ /**
114
+ * Model identifier for the selected model (e.g., 'gpt-4o',
115
+ * 'claude-3-opus-20240229')
116
+ */
117
+ model: string;
118
+ /**
119
+ * Provider name for the selected model (e.g., 'openai', 'anthropic', 'google')
120
+ */
121
+ provider: string;
122
+ }
123
+ }
124
+ export interface ModelRouterOpenHandsSelectParams {
125
+ /**
126
+ * List of LLM providers to route between. Specify at least one provider in format
127
+ * {provider, model}
128
+ */
129
+ llm_providers: Array<AdaptAPI.RequestProvider | ModelRouterOpenHandsSelectParams.OpenRouterProvider>;
130
+ /**
131
+ * Array of message objects in OpenAI format (with 'role' and 'content' keys)
132
+ */
133
+ messages: Array<{
134
+ [key: string]: string | Array<unknown>;
135
+ }> | string;
136
+ /**
137
+ * Whether to hash message content for privacy
138
+ */
139
+ hash_content?: boolean;
140
+ /**
141
+ * Maximum number of models to consider for routing. If not specified, considers
142
+ * all provided models
143
+ */
144
+ max_model_depth?: number | null;
145
+ /**
146
+ * Optimization metric for model selection
147
+ */
148
+ metric?: string;
149
+ /**
150
+ * Preference ID for personalized routing. Create one via POST
151
+ * /v2/preferences/userPreferenceCreate
152
+ */
153
+ preference_id?: string | null;
154
+ /**
155
+ * Previous session ID to link related requests
156
+ */
157
+ previous_session?: string | null;
158
+ /**
159
+ * OpenAI-format function calling tools
160
+ */
161
+ tools?: Array<{
162
+ [key: string]: unknown;
163
+ }> | null;
164
+ /**
165
+ * Optimization tradeoff strategy. Use 'cost' to prioritize cost savings or
166
+ * 'latency' to prioritize speed
167
+ */
168
+ tradeoff?: string | null;
169
+ }
170
+ export declare namespace ModelRouterOpenHandsSelectParams {
171
+ /**
172
+ * Model for specifying an LLM provider using OpenRouter format.
173
+ *
174
+ * Used in model routing requests when you want to specify providers using the
175
+ * OpenRouter naming convention (combined 'provider/model' format). This is an
176
+ * alternative to the standard RequestProvider which uses separate provider and
177
+ * model fields.
178
+ *
179
+ * **When to use:**
180
+ *
181
+ * - When working with OpenRouter-compatible systems
182
+ * - When you prefer the unified 'provider/model' format
183
+ * - For models accessed via OpenRouter proxy
184
+ */
185
+ interface OpenRouterProvider {
186
+ /**
187
+ * OpenRouter model identifier in 'provider/model' format (e.g., 'openai/gpt-4o',
188
+ * 'anthropic/claude-sonnet-4-5-20250929')
189
+ */
190
+ model: string;
191
+ /**
192
+ * Maximum context length for the model (required for custom models)
193
+ */
194
+ context_length?: number | null;
195
+ /**
196
+ * Input token price per million tokens in USD (required for custom models)
197
+ */
198
+ input_price?: number | null;
199
+ /**
200
+ * Whether this is a custom model not in Not Diamond's supported model list
201
+ */
202
+ is_custom?: boolean;
203
+ /**
204
+ * Average latency in seconds (required for custom models)
205
+ */
206
+ latency?: number | null;
207
+ /**
208
+ * Output token price per million tokens in USD (required for custom models)
209
+ */
210
+ output_price?: number | null;
211
+ }
212
+ }
213
+ export interface ModelRouterSelectModelParams {
214
+ /**
215
+ * Body param: List of LLM providers to route between. Specify at least one
216
+ * provider in format {provider, model}
217
+ */
218
+ llm_providers: Array<AdaptAPI.RequestProvider | ModelRouterSelectModelParams.OpenRouterProvider>;
219
+ /**
220
+ * Body param: Array of message objects in OpenAI format (with 'role' and 'content'
221
+ * keys)
222
+ */
223
+ messages: Array<{
224
+ [key: string]: string | Array<unknown>;
225
+ }> | string;
226
+ /**
227
+ * Query param: Optional format type. Use 'openrouter' to accept and return
228
+ * OpenRouter-format model identifiers
229
+ */
230
+ type?: string | null;
231
+ /**
232
+ * Body param: Whether to hash message content for privacy
233
+ */
234
+ hash_content?: boolean;
235
+ /**
236
+ * Body param: Maximum number of models to consider for routing. If not specified,
237
+ * considers all provided models
238
+ */
239
+ max_model_depth?: number | null;
240
+ /**
241
+ * Body param: Optimization metric for model selection
242
+ */
243
+ metric?: string;
244
+ /**
245
+ * Body param: Preference ID for personalized routing. Create one via POST
246
+ * /v2/preferences/userPreferenceCreate
247
+ */
248
+ preference_id?: string | null;
249
+ /**
250
+ * Body param: Previous session ID to link related requests
251
+ */
252
+ previous_session?: string | null;
253
+ /**
254
+ * Body param: OpenAI-format function calling tools
255
+ */
256
+ tools?: Array<{
257
+ [key: string]: unknown;
258
+ }> | null;
259
+ /**
260
+ * Body param: Optimization tradeoff strategy. Use 'cost' to prioritize cost
261
+ * savings or 'latency' to prioritize speed
262
+ */
263
+ tradeoff?: string | null;
264
+ }
265
+ export declare namespace ModelRouterSelectModelParams {
266
+ /**
267
+ * Model for specifying an LLM provider using OpenRouter format.
268
+ *
269
+ * Used in model routing requests when you want to specify providers using the
270
+ * OpenRouter naming convention (combined 'provider/model' format). This is an
271
+ * alternative to the standard RequestProvider which uses separate provider and
272
+ * model fields.
273
+ *
274
+ * **When to use:**
275
+ *
276
+ * - When working with OpenRouter-compatible systems
277
+ * - When you prefer the unified 'provider/model' format
278
+ * - For models accessed via OpenRouter proxy
279
+ */
280
+ interface OpenRouterProvider {
281
+ /**
282
+ * OpenRouter model identifier in 'provider/model' format (e.g., 'openai/gpt-4o',
283
+ * 'anthropic/claude-sonnet-4-5-20250929')
284
+ */
285
+ model: string;
286
+ /**
287
+ * Maximum context length for the model (required for custom models)
288
+ */
289
+ context_length?: number | null;
290
+ /**
291
+ * Input token price per million tokens in USD (required for custom models)
292
+ */
293
+ input_price?: number | null;
294
+ /**
295
+ * Whether this is a custom model not in Not Diamond's supported model list
296
+ */
297
+ is_custom?: boolean;
298
+ /**
299
+ * Average latency in seconds (required for custom models)
300
+ */
301
+ latency?: number | null;
302
+ /**
303
+ * Output token price per million tokens in USD (required for custom models)
304
+ */
305
+ output_price?: number | null;
306
+ }
307
+ }
308
+ export declare namespace ModelRouter {
309
+ export { type ModelRouterOpenHandsSelectResponse as ModelRouterOpenHandsSelectResponse, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterOpenHandsSelectParams as ModelRouterOpenHandsSelectParams, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
310
+ }
311
+ //# 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,QAAQ;OACb,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,eAAe,CAAC,IAAI,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAItG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,WAAW,CACT,MAAM,EAAE,4BAA4B,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,8BAA8B,CAAC;CAI9C;AAED,MAAM,MAAM,kCAAkC,GAAG,OAAO,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,Q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E,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,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,gCAAgC,IAAI,gCAAgC,EACzE,KAAK,4BAA4B,IAAI,4BAA4B,GAClE,CAAC;CACH"}
@@ -0,0 +1,311 @@
1
+ import { APIResource } from "../core/resource.js";
2
+ import * as AdaptAPI from "./prompt/adapt.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
+ * Openhands Model Select
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const response = await client.modelRouter.openHandsSelect({
12
+ * llm_providers: [
13
+ * { model: 'gpt-4o', provider: 'openai' },
14
+ * {
15
+ * model: 'claude-sonnet-4-5-20250929',
16
+ * provider: 'anthropic',
17
+ * },
18
+ * { model: 'gemini-1.5-pro', provider: 'google' },
19
+ * ],
20
+ * messages: [
21
+ * {
22
+ * content: 'You are a helpful assistant.',
23
+ * role: 'system',
24
+ * },
25
+ * { content: 'Explain quantum computing', role: 'user' },
26
+ * ],
27
+ * });
28
+ * ```
29
+ */
30
+ openHandsSelect(body: ModelRouterOpenHandsSelectParams, options?: RequestOptions): APIPromise<unknown>;
31
+ /**
32
+ * Select the optimal LLM to handle your query based on Not Diamond's routing
33
+ * algorithm.
34
+ *
35
+ * This endpoint analyzes your messages and returns the best-suited model from your
36
+ * specified providers. The router considers factors like query complexity, model
37
+ * capabilities, cost, and latency based on your preferences.
38
+ *
39
+ * **Key Features:**
40
+ *
41
+ * - Intelligent routing across multiple LLM providers
42
+ * - Support for custom routers trained on your evaluation data
43
+ * - Optional cost/latency optimization
44
+ * - Function calling support for compatible models
45
+ * - Privacy-preserving content hashing
46
+ *
47
+ * **Usage:**
48
+ *
49
+ * 1. Pass your messages in OpenAI format (array of objects with 'role' and
50
+ * 'content')
51
+ * 2. Specify which LLM providers you want to route between
52
+ * 3. Optionally provide a preference_id for personalized routing
53
+ * 4. Receive a recommended model and session_id
54
+ * 5. Use the session_id to submit feedback and improve routing
55
+ *
56
+ * **Related Endpoints:**
57
+ *
58
+ * - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for
59
+ * personalized routing
60
+ * - `POST /v2/report/metrics/feedback` - Submit feedback on routing decisions
61
+ * - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation
62
+ * data
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const response = await client.modelRouter.selectModel({
67
+ * llm_providers: [
68
+ * { provider: 'openai', model: 'gpt-4o' },
69
+ * {
70
+ * provider: 'anthropic',
71
+ * model: 'claude-sonnet-4-5-20250929',
72
+ * },
73
+ * { provider: 'google', model: 'gemini-1.5-pro' },
74
+ * ],
75
+ * messages: [
76
+ * {
77
+ * role: 'system',
78
+ * content: 'You are a helpful assistant.',
79
+ * },
80
+ * {
81
+ * role: 'user',
82
+ * content: 'Explain quantum computing in simple terms',
83
+ * },
84
+ * ],
85
+ * });
86
+ * ```
87
+ */
88
+ selectModel(params: ModelRouterSelectModelParams, options?: RequestOptions): APIPromise<ModelRouterSelectModelResponse>;
89
+ }
90
+ export type ModelRouterOpenHandsSelectResponse = unknown;
91
+ /**
92
+ * Response from model selection endpoint.
93
+ */
94
+ export interface ModelRouterSelectModelResponse {
95
+ /**
96
+ * List containing the selected provider
97
+ */
98
+ providers: Array<ModelRouterSelectModelResponse.Provider>;
99
+ /**
100
+ * Unique session ID for this routing decision
101
+ */
102
+ session_id: string;
103
+ }
104
+ export declare namespace ModelRouterSelectModelResponse {
105
+ /**
106
+ * Selected LLM provider information from model selection endpoints.
107
+ *
108
+ * Part of ModelSelectResponse. Contains the provider and model that Not Diamond's
109
+ * routing algorithm selected as optimal for your query. Use these values to make
110
+ * your LLM API call to the recommended model.
111
+ */
112
+ interface Provider {
113
+ /**
114
+ * Model identifier for the selected model (e.g., 'gpt-4o',
115
+ * 'claude-3-opus-20240229')
116
+ */
117
+ model: string;
118
+ /**
119
+ * Provider name for the selected model (e.g., 'openai', 'anthropic', 'google')
120
+ */
121
+ provider: string;
122
+ }
123
+ }
124
+ export interface ModelRouterOpenHandsSelectParams {
125
+ /**
126
+ * List of LLM providers to route between. Specify at least one provider in format
127
+ * {provider, model}
128
+ */
129
+ llm_providers: Array<AdaptAPI.RequestProvider | ModelRouterOpenHandsSelectParams.OpenRouterProvider>;
130
+ /**
131
+ * Array of message objects in OpenAI format (with 'role' and 'content' keys)
132
+ */
133
+ messages: Array<{
134
+ [key: string]: string | Array<unknown>;
135
+ }> | string;
136
+ /**
137
+ * Whether to hash message content for privacy
138
+ */
139
+ hash_content?: boolean;
140
+ /**
141
+ * Maximum number of models to consider for routing. If not specified, considers
142
+ * all provided models
143
+ */
144
+ max_model_depth?: number | null;
145
+ /**
146
+ * Optimization metric for model selection
147
+ */
148
+ metric?: string;
149
+ /**
150
+ * Preference ID for personalized routing. Create one via POST
151
+ * /v2/preferences/userPreferenceCreate
152
+ */
153
+ preference_id?: string | null;
154
+ /**
155
+ * Previous session ID to link related requests
156
+ */
157
+ previous_session?: string | null;
158
+ /**
159
+ * OpenAI-format function calling tools
160
+ */
161
+ tools?: Array<{
162
+ [key: string]: unknown;
163
+ }> | null;
164
+ /**
165
+ * Optimization tradeoff strategy. Use 'cost' to prioritize cost savings or
166
+ * 'latency' to prioritize speed
167
+ */
168
+ tradeoff?: string | null;
169
+ }
170
+ export declare namespace ModelRouterOpenHandsSelectParams {
171
+ /**
172
+ * Model for specifying an LLM provider using OpenRouter format.
173
+ *
174
+ * Used in model routing requests when you want to specify providers using the
175
+ * OpenRouter naming convention (combined 'provider/model' format). This is an
176
+ * alternative to the standard RequestProvider which uses separate provider and
177
+ * model fields.
178
+ *
179
+ * **When to use:**
180
+ *
181
+ * - When working with OpenRouter-compatible systems
182
+ * - When you prefer the unified 'provider/model' format
183
+ * - For models accessed via OpenRouter proxy
184
+ */
185
+ interface OpenRouterProvider {
186
+ /**
187
+ * OpenRouter model identifier in 'provider/model' format (e.g., 'openai/gpt-4o',
188
+ * 'anthropic/claude-sonnet-4-5-20250929')
189
+ */
190
+ model: string;
191
+ /**
192
+ * Maximum context length for the model (required for custom models)
193
+ */
194
+ context_length?: number | null;
195
+ /**
196
+ * Input token price per million tokens in USD (required for custom models)
197
+ */
198
+ input_price?: number | null;
199
+ /**
200
+ * Whether this is a custom model not in Not Diamond's supported model list
201
+ */
202
+ is_custom?: boolean;
203
+ /**
204
+ * Average latency in seconds (required for custom models)
205
+ */
206
+ latency?: number | null;
207
+ /**
208
+ * Output token price per million tokens in USD (required for custom models)
209
+ */
210
+ output_price?: number | null;
211
+ }
212
+ }
213
+ export interface ModelRouterSelectModelParams {
214
+ /**
215
+ * Body param: List of LLM providers to route between. Specify at least one
216
+ * provider in format {provider, model}
217
+ */
218
+ llm_providers: Array<AdaptAPI.RequestProvider | ModelRouterSelectModelParams.OpenRouterProvider>;
219
+ /**
220
+ * Body param: Array of message objects in OpenAI format (with 'role' and 'content'
221
+ * keys)
222
+ */
223
+ messages: Array<{
224
+ [key: string]: string | Array<unknown>;
225
+ }> | string;
226
+ /**
227
+ * Query param: Optional format type. Use 'openrouter' to accept and return
228
+ * OpenRouter-format model identifiers
229
+ */
230
+ type?: string | null;
231
+ /**
232
+ * Body param: Whether to hash message content for privacy
233
+ */
234
+ hash_content?: boolean;
235
+ /**
236
+ * Body param: Maximum number of models to consider for routing. If not specified,
237
+ * considers all provided models
238
+ */
239
+ max_model_depth?: number | null;
240
+ /**
241
+ * Body param: Optimization metric for model selection
242
+ */
243
+ metric?: string;
244
+ /**
245
+ * Body param: Preference ID for personalized routing. Create one via POST
246
+ * /v2/preferences/userPreferenceCreate
247
+ */
248
+ preference_id?: string | null;
249
+ /**
250
+ * Body param: Previous session ID to link related requests
251
+ */
252
+ previous_session?: string | null;
253
+ /**
254
+ * Body param: OpenAI-format function calling tools
255
+ */
256
+ tools?: Array<{
257
+ [key: string]: unknown;
258
+ }> | null;
259
+ /**
260
+ * Body param: Optimization tradeoff strategy. Use 'cost' to prioritize cost
261
+ * savings or 'latency' to prioritize speed
262
+ */
263
+ tradeoff?: string | null;
264
+ }
265
+ export declare namespace ModelRouterSelectModelParams {
266
+ /**
267
+ * Model for specifying an LLM provider using OpenRouter format.
268
+ *
269
+ * Used in model routing requests when you want to specify providers using the
270
+ * OpenRouter naming convention (combined 'provider/model' format). This is an
271
+ * alternative to the standard RequestProvider which uses separate provider and
272
+ * model fields.
273
+ *
274
+ * **When to use:**
275
+ *
276
+ * - When working with OpenRouter-compatible systems
277
+ * - When you prefer the unified 'provider/model' format
278
+ * - For models accessed via OpenRouter proxy
279
+ */
280
+ interface OpenRouterProvider {
281
+ /**
282
+ * OpenRouter model identifier in 'provider/model' format (e.g., 'openai/gpt-4o',
283
+ * 'anthropic/claude-sonnet-4-5-20250929')
284
+ */
285
+ model: string;
286
+ /**
287
+ * Maximum context length for the model (required for custom models)
288
+ */
289
+ context_length?: number | null;
290
+ /**
291
+ * Input token price per million tokens in USD (required for custom models)
292
+ */
293
+ input_price?: number | null;
294
+ /**
295
+ * Whether this is a custom model not in Not Diamond's supported model list
296
+ */
297
+ is_custom?: boolean;
298
+ /**
299
+ * Average latency in seconds (required for custom models)
300
+ */
301
+ latency?: number | null;
302
+ /**
303
+ * Output token price per million tokens in USD (required for custom models)
304
+ */
305
+ output_price?: number | null;
306
+ }
307
+ }
308
+ export declare namespace ModelRouter {
309
+ export { type ModelRouterOpenHandsSelectResponse as ModelRouterOpenHandsSelectResponse, type ModelRouterSelectModelResponse as ModelRouterSelectModelResponse, type ModelRouterOpenHandsSelectParams as ModelRouterOpenHandsSelectParams, type ModelRouterSelectModelParams as ModelRouterSelectModelParams, };
310
+ }
311
+ //# 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,QAAQ;OACb,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,eAAe,CAAC,IAAI,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAItG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,WAAW,CACT,MAAM,EAAE,4BAA4B,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,8BAA8B,CAAC;CAI9C;AAED,MAAM,MAAM,kCAAkC,GAAG,OAAO,CAAC;AAEzD;;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,gCAAgC;IAC/C;;;OAGG;IACH,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,eAAe,GAAG,gCAAgC,CAAC,kBAAkB,CAAC,CAAC;IAErG;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CA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