nadir-sdk 0.1.0
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/README.md +94 -0
- package/dist/index.cjs +337 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +268 -0
- package/dist/index.d.ts +268 -0
- package/dist/index.js +304 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
interface ChatMessage {
|
|
2
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
3
|
+
content: string | null;
|
|
4
|
+
tool_calls?: unknown[];
|
|
5
|
+
cache_control?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
interface ReasoningConfig {
|
|
8
|
+
effort?: "low" | "medium" | "high";
|
|
9
|
+
max_tokens?: number;
|
|
10
|
+
}
|
|
11
|
+
interface ProviderPreferences {
|
|
12
|
+
order?: string[];
|
|
13
|
+
ignore?: string[];
|
|
14
|
+
sort?: string;
|
|
15
|
+
require_parameters?: string[];
|
|
16
|
+
}
|
|
17
|
+
interface ChatCompletionCreateParams {
|
|
18
|
+
messages: ChatMessage[];
|
|
19
|
+
model?: string;
|
|
20
|
+
temperature?: number;
|
|
21
|
+
max_tokens?: number;
|
|
22
|
+
top_p?: number;
|
|
23
|
+
frequency_penalty?: number;
|
|
24
|
+
presence_penalty?: number;
|
|
25
|
+
stream?: boolean;
|
|
26
|
+
response_format?: Record<string, unknown>;
|
|
27
|
+
reasoning?: ReasoningConfig;
|
|
28
|
+
provider?: ProviderPreferences;
|
|
29
|
+
route?: "fallback";
|
|
30
|
+
fallback_models?: string[];
|
|
31
|
+
transforms?: string[];
|
|
32
|
+
layers?: {
|
|
33
|
+
routing?: boolean;
|
|
34
|
+
fallback?: boolean;
|
|
35
|
+
optimize?: boolean;
|
|
36
|
+
};
|
|
37
|
+
tools?: unknown[];
|
|
38
|
+
tool_choice?: unknown;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
interface Message {
|
|
42
|
+
role: string;
|
|
43
|
+
content: string | null;
|
|
44
|
+
tool_calls?: unknown[];
|
|
45
|
+
}
|
|
46
|
+
interface Choice {
|
|
47
|
+
index: number;
|
|
48
|
+
message?: Message;
|
|
49
|
+
delta?: Message;
|
|
50
|
+
finish_reason: string | null;
|
|
51
|
+
}
|
|
52
|
+
interface Usage {
|
|
53
|
+
prompt_tokens: number;
|
|
54
|
+
completion_tokens: number;
|
|
55
|
+
total_tokens: number;
|
|
56
|
+
reasoning_tokens?: number;
|
|
57
|
+
cache_creation_input_tokens?: number;
|
|
58
|
+
cache_read_input_tokens?: number;
|
|
59
|
+
}
|
|
60
|
+
interface NadirMetadata {
|
|
61
|
+
model_selection_type?: string;
|
|
62
|
+
strategy?: string;
|
|
63
|
+
selected_model?: string;
|
|
64
|
+
complexity_score?: number;
|
|
65
|
+
analyzer_used?: string;
|
|
66
|
+
tier?: string;
|
|
67
|
+
confidence?: number;
|
|
68
|
+
cost?: Record<string, unknown>;
|
|
69
|
+
benchmark_comparison?: Record<string, unknown>;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
interface ChatCompletion {
|
|
73
|
+
id: string;
|
|
74
|
+
object: string;
|
|
75
|
+
created: number;
|
|
76
|
+
model: string;
|
|
77
|
+
choices: Choice[];
|
|
78
|
+
usage?: Usage;
|
|
79
|
+
nadir_metadata?: NadirMetadata;
|
|
80
|
+
}
|
|
81
|
+
interface ChatCompletionChunk {
|
|
82
|
+
id: string;
|
|
83
|
+
object: string;
|
|
84
|
+
created: number;
|
|
85
|
+
model: string;
|
|
86
|
+
choices: Choice[];
|
|
87
|
+
usage?: Usage;
|
|
88
|
+
}
|
|
89
|
+
interface CreateClusterParams {
|
|
90
|
+
name: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
examples?: string[];
|
|
93
|
+
classification_criteria?: string;
|
|
94
|
+
}
|
|
95
|
+
interface CreateOrganizationParams {
|
|
96
|
+
name: string;
|
|
97
|
+
slug: string;
|
|
98
|
+
plan_type?: string;
|
|
99
|
+
}
|
|
100
|
+
interface RecommendParams {
|
|
101
|
+
prompt: string;
|
|
102
|
+
system_message?: string;
|
|
103
|
+
models?: string[];
|
|
104
|
+
providers?: string[];
|
|
105
|
+
max_models?: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Async iterable wrapper around an SSE response stream.
|
|
110
|
+
*
|
|
111
|
+
* Usage:
|
|
112
|
+
* ```ts
|
|
113
|
+
* for await (const chunk of stream) {
|
|
114
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare class Stream<T> implements AsyncIterable<T> {
|
|
119
|
+
private reader;
|
|
120
|
+
private decoder;
|
|
121
|
+
private buffer;
|
|
122
|
+
private done;
|
|
123
|
+
private parse;
|
|
124
|
+
constructor(body: ReadableStream<Uint8Array>, parse: (data: unknown) => T);
|
|
125
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
126
|
+
private processBuffer;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Nadir Node.js SDK — OpenAI-compatible client for the Nadir LLM router.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* import { NadirClient } from "nadir-sdk";
|
|
135
|
+
*
|
|
136
|
+
* const client = new NadirClient({ apiKey: "ndr_..." });
|
|
137
|
+
*
|
|
138
|
+
* // Chat completion — Nadir picks the optimal model
|
|
139
|
+
* const response = await client.chat.completions.create({
|
|
140
|
+
* messages: [{ role: "user", content: "Hello!" }],
|
|
141
|
+
* });
|
|
142
|
+
* console.log(response.choices[0].message?.content);
|
|
143
|
+
*
|
|
144
|
+
* // Streaming
|
|
145
|
+
* const stream = await client.chat.completions.create({
|
|
146
|
+
* messages: [{ role: "user", content: "Tell me a story" }],
|
|
147
|
+
* stream: true,
|
|
148
|
+
* });
|
|
149
|
+
* for await (const chunk of stream) {
|
|
150
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
|
|
151
|
+
* }
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
interface NadirClientOptions {
|
|
156
|
+
/** Nadir API key (`ndr_...`). Falls back to `NADIR_API_KEY` env var. */
|
|
157
|
+
apiKey?: string;
|
|
158
|
+
/** API base URL. Falls back to `NADIR_BASE_URL` env var. */
|
|
159
|
+
baseURL?: string;
|
|
160
|
+
/** Request timeout in milliseconds (default 120_000). */
|
|
161
|
+
timeout?: number;
|
|
162
|
+
}
|
|
163
|
+
declare class Completions {
|
|
164
|
+
private client;
|
|
165
|
+
constructor(client: NadirClient);
|
|
166
|
+
/** Create a chat completion (non-streaming). */
|
|
167
|
+
create(params: ChatCompletionCreateParams & {
|
|
168
|
+
stream?: false;
|
|
169
|
+
}): Promise<ChatCompletion>;
|
|
170
|
+
/** Create a streaming chat completion. */
|
|
171
|
+
create(params: ChatCompletionCreateParams & {
|
|
172
|
+
stream: true;
|
|
173
|
+
}): Promise<Stream<ChatCompletionChunk>>;
|
|
174
|
+
/** Create a chat completion (overload resolution). */
|
|
175
|
+
create(params: ChatCompletionCreateParams): Promise<ChatCompletion | Stream<ChatCompletionChunk>>;
|
|
176
|
+
}
|
|
177
|
+
declare class Chat {
|
|
178
|
+
readonly completions: Completions;
|
|
179
|
+
constructor(client: NadirClient);
|
|
180
|
+
}
|
|
181
|
+
declare class SmartExport {
|
|
182
|
+
private client;
|
|
183
|
+
constructor(client: NadirClient);
|
|
184
|
+
status(): Promise<Record<string, unknown>>;
|
|
185
|
+
train(clusterId: string, options?: {
|
|
186
|
+
baseModel?: string;
|
|
187
|
+
}): Promise<Record<string, unknown>>;
|
|
188
|
+
exportData(clusterId: string, options?: {
|
|
189
|
+
format?: string;
|
|
190
|
+
}): Promise<Record<string, unknown>>;
|
|
191
|
+
listJobs(): Promise<Record<string, unknown>>;
|
|
192
|
+
getJob(jobId: string): Promise<Record<string, unknown>>;
|
|
193
|
+
cancelJob(jobId: string): Promise<Record<string, unknown>>;
|
|
194
|
+
}
|
|
195
|
+
declare class Clustering {
|
|
196
|
+
private client;
|
|
197
|
+
constructor(client: NadirClient);
|
|
198
|
+
classify(prompt: string): Promise<Record<string, unknown>>;
|
|
199
|
+
listClusters(): Promise<Record<string, unknown>>;
|
|
200
|
+
createCluster(params: CreateClusterParams): Promise<Record<string, unknown>>;
|
|
201
|
+
}
|
|
202
|
+
declare class Organizations {
|
|
203
|
+
private client;
|
|
204
|
+
constructor(client: NadirClient);
|
|
205
|
+
list(): Promise<Record<string, unknown>>;
|
|
206
|
+
create(params: CreateOrganizationParams): Promise<Record<string, unknown>>;
|
|
207
|
+
get(orgId: string): Promise<Record<string, unknown>>;
|
|
208
|
+
}
|
|
209
|
+
declare class NadirClient {
|
|
210
|
+
private readonly apiKey;
|
|
211
|
+
private readonly baseURL;
|
|
212
|
+
private readonly timeout;
|
|
213
|
+
/** OpenAI-compatible chat completions namespace. */
|
|
214
|
+
readonly chat: Chat;
|
|
215
|
+
/** Smart Export / distillation endpoints. */
|
|
216
|
+
readonly smartExport: SmartExport;
|
|
217
|
+
/** Prompt clustering endpoints. */
|
|
218
|
+
readonly clustering: Clustering;
|
|
219
|
+
/** Organization management endpoints. */
|
|
220
|
+
readonly organizations: Organizations;
|
|
221
|
+
constructor(options?: NadirClientOptions);
|
|
222
|
+
/** Get a model recommendation without making an LLM call. */
|
|
223
|
+
recommend(params: RecommendParams): Promise<Record<string, unknown>>;
|
|
224
|
+
/** List available models. */
|
|
225
|
+
listModels(): Promise<Record<string, unknown>>;
|
|
226
|
+
/** List user presets. */
|
|
227
|
+
listPresets(): Promise<Record<string, unknown>>;
|
|
228
|
+
/** Check API health. */
|
|
229
|
+
health(): Promise<Record<string, unknown>>;
|
|
230
|
+
/** @internal */
|
|
231
|
+
_request<T = Record<string, unknown>>(method: string, path: string, body?: unknown): Promise<T>;
|
|
232
|
+
/** @internal — returns the raw Response (for streaming). */
|
|
233
|
+
_rawRequest(method: string, path: string, body?: unknown): Promise<Response>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Base error for all Nadir API errors. */
|
|
237
|
+
declare class NadirError extends Error {
|
|
238
|
+
readonly status: number;
|
|
239
|
+
readonly body: unknown;
|
|
240
|
+
readonly errorType: string | undefined;
|
|
241
|
+
constructor(message: string, options?: {
|
|
242
|
+
status?: number;
|
|
243
|
+
body?: unknown;
|
|
244
|
+
errorType?: string;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** Raised on 401 Unauthorized — invalid or missing API key. */
|
|
248
|
+
declare class AuthenticationError extends NadirError {
|
|
249
|
+
constructor(message: string, body?: unknown);
|
|
250
|
+
}
|
|
251
|
+
/** Raised on 429 Too Many Requests. */
|
|
252
|
+
declare class RateLimitError extends NadirError {
|
|
253
|
+
readonly retryAfter: number | undefined;
|
|
254
|
+
constructor(message: string, options?: {
|
|
255
|
+
body?: unknown;
|
|
256
|
+
retryAfter?: number;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/** Raised on server errors (4xx/5xx) not covered by a more specific class. */
|
|
260
|
+
declare class APIError extends NadirError {
|
|
261
|
+
constructor(message: string, status: number, body?: unknown);
|
|
262
|
+
}
|
|
263
|
+
/** Raised when the SDK cannot reach the Nadir API. */
|
|
264
|
+
declare class ConnectionError extends NadirError {
|
|
265
|
+
constructor(message: string);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export { APIError, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, type Choice, ConnectionError, type CreateClusterParams, type CreateOrganizationParams, type Message, NadirClient, type NadirClientOptions, NadirError, type NadirMetadata, type ProviderPreferences, RateLimitError, type ReasoningConfig, type RecommendParams, Stream, type Usage };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
interface ChatMessage {
|
|
2
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
3
|
+
content: string | null;
|
|
4
|
+
tool_calls?: unknown[];
|
|
5
|
+
cache_control?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
interface ReasoningConfig {
|
|
8
|
+
effort?: "low" | "medium" | "high";
|
|
9
|
+
max_tokens?: number;
|
|
10
|
+
}
|
|
11
|
+
interface ProviderPreferences {
|
|
12
|
+
order?: string[];
|
|
13
|
+
ignore?: string[];
|
|
14
|
+
sort?: string;
|
|
15
|
+
require_parameters?: string[];
|
|
16
|
+
}
|
|
17
|
+
interface ChatCompletionCreateParams {
|
|
18
|
+
messages: ChatMessage[];
|
|
19
|
+
model?: string;
|
|
20
|
+
temperature?: number;
|
|
21
|
+
max_tokens?: number;
|
|
22
|
+
top_p?: number;
|
|
23
|
+
frequency_penalty?: number;
|
|
24
|
+
presence_penalty?: number;
|
|
25
|
+
stream?: boolean;
|
|
26
|
+
response_format?: Record<string, unknown>;
|
|
27
|
+
reasoning?: ReasoningConfig;
|
|
28
|
+
provider?: ProviderPreferences;
|
|
29
|
+
route?: "fallback";
|
|
30
|
+
fallback_models?: string[];
|
|
31
|
+
transforms?: string[];
|
|
32
|
+
layers?: {
|
|
33
|
+
routing?: boolean;
|
|
34
|
+
fallback?: boolean;
|
|
35
|
+
optimize?: boolean;
|
|
36
|
+
};
|
|
37
|
+
tools?: unknown[];
|
|
38
|
+
tool_choice?: unknown;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
interface Message {
|
|
42
|
+
role: string;
|
|
43
|
+
content: string | null;
|
|
44
|
+
tool_calls?: unknown[];
|
|
45
|
+
}
|
|
46
|
+
interface Choice {
|
|
47
|
+
index: number;
|
|
48
|
+
message?: Message;
|
|
49
|
+
delta?: Message;
|
|
50
|
+
finish_reason: string | null;
|
|
51
|
+
}
|
|
52
|
+
interface Usage {
|
|
53
|
+
prompt_tokens: number;
|
|
54
|
+
completion_tokens: number;
|
|
55
|
+
total_tokens: number;
|
|
56
|
+
reasoning_tokens?: number;
|
|
57
|
+
cache_creation_input_tokens?: number;
|
|
58
|
+
cache_read_input_tokens?: number;
|
|
59
|
+
}
|
|
60
|
+
interface NadirMetadata {
|
|
61
|
+
model_selection_type?: string;
|
|
62
|
+
strategy?: string;
|
|
63
|
+
selected_model?: string;
|
|
64
|
+
complexity_score?: number;
|
|
65
|
+
analyzer_used?: string;
|
|
66
|
+
tier?: string;
|
|
67
|
+
confidence?: number;
|
|
68
|
+
cost?: Record<string, unknown>;
|
|
69
|
+
benchmark_comparison?: Record<string, unknown>;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
interface ChatCompletion {
|
|
73
|
+
id: string;
|
|
74
|
+
object: string;
|
|
75
|
+
created: number;
|
|
76
|
+
model: string;
|
|
77
|
+
choices: Choice[];
|
|
78
|
+
usage?: Usage;
|
|
79
|
+
nadir_metadata?: NadirMetadata;
|
|
80
|
+
}
|
|
81
|
+
interface ChatCompletionChunk {
|
|
82
|
+
id: string;
|
|
83
|
+
object: string;
|
|
84
|
+
created: number;
|
|
85
|
+
model: string;
|
|
86
|
+
choices: Choice[];
|
|
87
|
+
usage?: Usage;
|
|
88
|
+
}
|
|
89
|
+
interface CreateClusterParams {
|
|
90
|
+
name: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
examples?: string[];
|
|
93
|
+
classification_criteria?: string;
|
|
94
|
+
}
|
|
95
|
+
interface CreateOrganizationParams {
|
|
96
|
+
name: string;
|
|
97
|
+
slug: string;
|
|
98
|
+
plan_type?: string;
|
|
99
|
+
}
|
|
100
|
+
interface RecommendParams {
|
|
101
|
+
prompt: string;
|
|
102
|
+
system_message?: string;
|
|
103
|
+
models?: string[];
|
|
104
|
+
providers?: string[];
|
|
105
|
+
max_models?: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Async iterable wrapper around an SSE response stream.
|
|
110
|
+
*
|
|
111
|
+
* Usage:
|
|
112
|
+
* ```ts
|
|
113
|
+
* for await (const chunk of stream) {
|
|
114
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare class Stream<T> implements AsyncIterable<T> {
|
|
119
|
+
private reader;
|
|
120
|
+
private decoder;
|
|
121
|
+
private buffer;
|
|
122
|
+
private done;
|
|
123
|
+
private parse;
|
|
124
|
+
constructor(body: ReadableStream<Uint8Array>, parse: (data: unknown) => T);
|
|
125
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
126
|
+
private processBuffer;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Nadir Node.js SDK — OpenAI-compatible client for the Nadir LLM router.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* import { NadirClient } from "nadir-sdk";
|
|
135
|
+
*
|
|
136
|
+
* const client = new NadirClient({ apiKey: "ndr_..." });
|
|
137
|
+
*
|
|
138
|
+
* // Chat completion — Nadir picks the optimal model
|
|
139
|
+
* const response = await client.chat.completions.create({
|
|
140
|
+
* messages: [{ role: "user", content: "Hello!" }],
|
|
141
|
+
* });
|
|
142
|
+
* console.log(response.choices[0].message?.content);
|
|
143
|
+
*
|
|
144
|
+
* // Streaming
|
|
145
|
+
* const stream = await client.chat.completions.create({
|
|
146
|
+
* messages: [{ role: "user", content: "Tell me a story" }],
|
|
147
|
+
* stream: true,
|
|
148
|
+
* });
|
|
149
|
+
* for await (const chunk of stream) {
|
|
150
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
|
|
151
|
+
* }
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
interface NadirClientOptions {
|
|
156
|
+
/** Nadir API key (`ndr_...`). Falls back to `NADIR_API_KEY` env var. */
|
|
157
|
+
apiKey?: string;
|
|
158
|
+
/** API base URL. Falls back to `NADIR_BASE_URL` env var. */
|
|
159
|
+
baseURL?: string;
|
|
160
|
+
/** Request timeout in milliseconds (default 120_000). */
|
|
161
|
+
timeout?: number;
|
|
162
|
+
}
|
|
163
|
+
declare class Completions {
|
|
164
|
+
private client;
|
|
165
|
+
constructor(client: NadirClient);
|
|
166
|
+
/** Create a chat completion (non-streaming). */
|
|
167
|
+
create(params: ChatCompletionCreateParams & {
|
|
168
|
+
stream?: false;
|
|
169
|
+
}): Promise<ChatCompletion>;
|
|
170
|
+
/** Create a streaming chat completion. */
|
|
171
|
+
create(params: ChatCompletionCreateParams & {
|
|
172
|
+
stream: true;
|
|
173
|
+
}): Promise<Stream<ChatCompletionChunk>>;
|
|
174
|
+
/** Create a chat completion (overload resolution). */
|
|
175
|
+
create(params: ChatCompletionCreateParams): Promise<ChatCompletion | Stream<ChatCompletionChunk>>;
|
|
176
|
+
}
|
|
177
|
+
declare class Chat {
|
|
178
|
+
readonly completions: Completions;
|
|
179
|
+
constructor(client: NadirClient);
|
|
180
|
+
}
|
|
181
|
+
declare class SmartExport {
|
|
182
|
+
private client;
|
|
183
|
+
constructor(client: NadirClient);
|
|
184
|
+
status(): Promise<Record<string, unknown>>;
|
|
185
|
+
train(clusterId: string, options?: {
|
|
186
|
+
baseModel?: string;
|
|
187
|
+
}): Promise<Record<string, unknown>>;
|
|
188
|
+
exportData(clusterId: string, options?: {
|
|
189
|
+
format?: string;
|
|
190
|
+
}): Promise<Record<string, unknown>>;
|
|
191
|
+
listJobs(): Promise<Record<string, unknown>>;
|
|
192
|
+
getJob(jobId: string): Promise<Record<string, unknown>>;
|
|
193
|
+
cancelJob(jobId: string): Promise<Record<string, unknown>>;
|
|
194
|
+
}
|
|
195
|
+
declare class Clustering {
|
|
196
|
+
private client;
|
|
197
|
+
constructor(client: NadirClient);
|
|
198
|
+
classify(prompt: string): Promise<Record<string, unknown>>;
|
|
199
|
+
listClusters(): Promise<Record<string, unknown>>;
|
|
200
|
+
createCluster(params: CreateClusterParams): Promise<Record<string, unknown>>;
|
|
201
|
+
}
|
|
202
|
+
declare class Organizations {
|
|
203
|
+
private client;
|
|
204
|
+
constructor(client: NadirClient);
|
|
205
|
+
list(): Promise<Record<string, unknown>>;
|
|
206
|
+
create(params: CreateOrganizationParams): Promise<Record<string, unknown>>;
|
|
207
|
+
get(orgId: string): Promise<Record<string, unknown>>;
|
|
208
|
+
}
|
|
209
|
+
declare class NadirClient {
|
|
210
|
+
private readonly apiKey;
|
|
211
|
+
private readonly baseURL;
|
|
212
|
+
private readonly timeout;
|
|
213
|
+
/** OpenAI-compatible chat completions namespace. */
|
|
214
|
+
readonly chat: Chat;
|
|
215
|
+
/** Smart Export / distillation endpoints. */
|
|
216
|
+
readonly smartExport: SmartExport;
|
|
217
|
+
/** Prompt clustering endpoints. */
|
|
218
|
+
readonly clustering: Clustering;
|
|
219
|
+
/** Organization management endpoints. */
|
|
220
|
+
readonly organizations: Organizations;
|
|
221
|
+
constructor(options?: NadirClientOptions);
|
|
222
|
+
/** Get a model recommendation without making an LLM call. */
|
|
223
|
+
recommend(params: RecommendParams): Promise<Record<string, unknown>>;
|
|
224
|
+
/** List available models. */
|
|
225
|
+
listModels(): Promise<Record<string, unknown>>;
|
|
226
|
+
/** List user presets. */
|
|
227
|
+
listPresets(): Promise<Record<string, unknown>>;
|
|
228
|
+
/** Check API health. */
|
|
229
|
+
health(): Promise<Record<string, unknown>>;
|
|
230
|
+
/** @internal */
|
|
231
|
+
_request<T = Record<string, unknown>>(method: string, path: string, body?: unknown): Promise<T>;
|
|
232
|
+
/** @internal — returns the raw Response (for streaming). */
|
|
233
|
+
_rawRequest(method: string, path: string, body?: unknown): Promise<Response>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Base error for all Nadir API errors. */
|
|
237
|
+
declare class NadirError extends Error {
|
|
238
|
+
readonly status: number;
|
|
239
|
+
readonly body: unknown;
|
|
240
|
+
readonly errorType: string | undefined;
|
|
241
|
+
constructor(message: string, options?: {
|
|
242
|
+
status?: number;
|
|
243
|
+
body?: unknown;
|
|
244
|
+
errorType?: string;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** Raised on 401 Unauthorized — invalid or missing API key. */
|
|
248
|
+
declare class AuthenticationError extends NadirError {
|
|
249
|
+
constructor(message: string, body?: unknown);
|
|
250
|
+
}
|
|
251
|
+
/** Raised on 429 Too Many Requests. */
|
|
252
|
+
declare class RateLimitError extends NadirError {
|
|
253
|
+
readonly retryAfter: number | undefined;
|
|
254
|
+
constructor(message: string, options?: {
|
|
255
|
+
body?: unknown;
|
|
256
|
+
retryAfter?: number;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/** Raised on server errors (4xx/5xx) not covered by a more specific class. */
|
|
260
|
+
declare class APIError extends NadirError {
|
|
261
|
+
constructor(message: string, status: number, body?: unknown);
|
|
262
|
+
}
|
|
263
|
+
/** Raised when the SDK cannot reach the Nadir API. */
|
|
264
|
+
declare class ConnectionError extends NadirError {
|
|
265
|
+
constructor(message: string);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export { APIError, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, type Choice, ConnectionError, type CreateClusterParams, type CreateOrganizationParams, type Message, NadirClient, type NadirClientOptions, NadirError, type NadirMetadata, type ProviderPreferences, RateLimitError, type ReasoningConfig, type RecommendParams, Stream, type Usage };
|