@apicity/fireworks 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +1694 -0
- package/dist/src/example.d.ts +8 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +143 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/fireworks.d.ts +3 -0
- package/dist/src/fireworks.d.ts.map +1 -0
- package/dist/src/fireworks.js +1732 -0
- package/dist/src/fireworks.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/middleware.d.ts +34 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +219 -0
- package/dist/src/middleware.js.map +1 -0
- package/dist/src/sse.d.ts +6 -0
- package/dist/src/sse.d.ts.map +1 -0
- package/dist/src/sse.js +55 -0
- package/dist/src/sse.js.map +1 -0
- package/dist/src/types.d.ts +1942 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +14 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/zod.d.ts +3259 -0
- package/dist/src/zod.d.ts.map +1 -0
- package/dist/src/zod.js +754 -0
- package/dist/src/zod.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,1732 @@
|
|
|
1
|
+
import { FireworksError, } from "./types.js";
|
|
2
|
+
import { sseToIterable } from "./sse.js";
|
|
3
|
+
import { FireworksChatRequestSchema, FireworksCompletionRequestSchema, FireworksEmbeddingRequestSchema, FireworksRerankRequestSchema, AnthropicMessagesRequestSchema, FireworksTextToImageRequestSchema, FireworksKontextRequestSchema, FireworksGetResultRequestSchema, FireworksTranscriptionRequestSchema, FireworksTranslationRequestSchema, FireworksStreamingTranscriptionOptionsSchema, FireworksAudioBatchTranscriptionRequestSchema, FireworksAudioBatchTranslationRequestSchema, FireworksCreateModelRequestSchema, FireworksPrepareModelRequestSchema, FireworksGetUploadEndpointRequestSchema, FireworksUpdateModelRequestSchema, FireworksValidateUploadRequestSchema, FireworksBatchJobCreateRequestSchema, FireworksSFTCreateRequestSchema, FireworksCreateDeploymentRequestSchema, FireworksUpdateDeploymentRequestSchema, FireworksScaleDeploymentRequestSchema, FireworksDpoJobCreateRequestSchema, FireworksCreateDeployedModelRequestSchema, FireworksUpdateDeployedModelRequestSchema, FireworksCreateUserRequestSchema, FireworksUpdateUserRequestSchema, FireworksCreateApiKeyRequestSchema, FireworksDeleteApiKeyRequestSchema, FireworksCreateSecretRequestSchema, FireworksUpdateSecretRequestSchema, FireworksCreateDatasetRequestSchema, FireworksUpdateDatasetRequestSchema, FireworksDatasetGetUploadEndpointRequestSchema, FireworksDatasetValidateUploadRequestSchema, FireworksCreateEvaluatorRequestSchema, FireworksUpdateEvaluatorRequestSchema, FireworksGetUploadEndpointEvaluatorRequestSchema, FireworksCreateEvaluationJobRequestSchema, FireworksRFTCreateRequestSchema, FireworksRlorTrainerJobCreateRequestSchema, FireworksRlorTrainerJobExecuteStepRequestSchema, FireworksEmptySchema, } from "./zod.js";
|
|
4
|
+
import { attachExamples } from "./example.js";
|
|
5
|
+
// Helper function to safely handle AbortSignal across different environments
|
|
6
|
+
function attachAbortHandler(signal, controller) {
|
|
7
|
+
if (!signal)
|
|
8
|
+
return;
|
|
9
|
+
// Handle both standard AbortSignal and node-fetch's AbortSignal
|
|
10
|
+
if (typeof signal.addEventListener === "function") {
|
|
11
|
+
signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
12
|
+
}
|
|
13
|
+
else if (signal.aborted) {
|
|
14
|
+
// Already aborted, abort our controller too
|
|
15
|
+
controller.abort();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function fireworks(opts) {
|
|
19
|
+
const baseURL = opts.baseURL ?? "https://api.fireworks.ai/inference/v1";
|
|
20
|
+
const modelsBaseURL = "https://api.fireworks.ai";
|
|
21
|
+
const audioBaseURL = opts.audioBaseURL ?? "https://audio-prod.api.fireworks.ai/v1";
|
|
22
|
+
const audioStreamingBaseURL = opts.audioStreamingBaseURL ?? "wss://audio-streaming.api.fireworks.ai";
|
|
23
|
+
const doFetch = opts.fetch ?? fetch;
|
|
24
|
+
const WS = opts.WebSocket ?? globalThis.WebSocket;
|
|
25
|
+
const timeout = opts.timeout ?? 30000;
|
|
26
|
+
async function makeRequest(path, body, signal) {
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
29
|
+
if (signal) {
|
|
30
|
+
attachAbortHandler(signal, controller);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const res = await doFetch(`${baseURL}${path}`, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify(body),
|
|
40
|
+
signal: controller.signal,
|
|
41
|
+
});
|
|
42
|
+
clearTimeout(timeoutId);
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
45
|
+
let resBody = null;
|
|
46
|
+
try {
|
|
47
|
+
resBody = await res.json();
|
|
48
|
+
if (typeof resBody === "object" &&
|
|
49
|
+
resBody !== null &&
|
|
50
|
+
"error" in resBody) {
|
|
51
|
+
const err = resBody.error;
|
|
52
|
+
if (err?.message) {
|
|
53
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// ignore parse errors
|
|
59
|
+
}
|
|
60
|
+
throw new FireworksError(message, res.status, resBody);
|
|
61
|
+
}
|
|
62
|
+
return (await res.json());
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
clearTimeout(timeoutId);
|
|
66
|
+
if (error instanceof FireworksError)
|
|
67
|
+
throw error;
|
|
68
|
+
throw new FireworksError(`Fireworks request failed: ${error}`, 500);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function* makeStreamRequest(path, body, signal) {
|
|
72
|
+
const controller = new AbortController();
|
|
73
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
74
|
+
if (signal) {
|
|
75
|
+
attachAbortHandler(signal, controller);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const res = await doFetch(`${baseURL}${path}`, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: {
|
|
81
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
82
|
+
"Content-Type": "application/json",
|
|
83
|
+
},
|
|
84
|
+
body: JSON.stringify(body),
|
|
85
|
+
signal: controller.signal,
|
|
86
|
+
});
|
|
87
|
+
clearTimeout(timeoutId);
|
|
88
|
+
if (!res.ok) {
|
|
89
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
90
|
+
let resBody = null;
|
|
91
|
+
try {
|
|
92
|
+
resBody = await res.json();
|
|
93
|
+
if (typeof resBody === "object" &&
|
|
94
|
+
resBody !== null &&
|
|
95
|
+
"error" in resBody) {
|
|
96
|
+
const err = resBody.error;
|
|
97
|
+
if (err?.message) {
|
|
98
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// ignore parse errors
|
|
104
|
+
}
|
|
105
|
+
throw new FireworksError(message, res.status, resBody);
|
|
106
|
+
}
|
|
107
|
+
for await (const { data } of sseToIterable(res)) {
|
|
108
|
+
if (data === "[DONE]") {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
yield JSON.parse(data);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// ignore non-JSON lines
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
clearTimeout(timeoutId);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// POST https://api.fireworks.ai/inference/v1/messages
|
|
124
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
125
|
+
async function* messagesStreamImpl(req, signal) {
|
|
126
|
+
const controller = new AbortController();
|
|
127
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
128
|
+
try {
|
|
129
|
+
const res = await doFetch(`${baseURL}/messages`, {
|
|
130
|
+
method: "POST",
|
|
131
|
+
headers: {
|
|
132
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
133
|
+
"Content-Type": "application/json",
|
|
134
|
+
},
|
|
135
|
+
body: JSON.stringify(req),
|
|
136
|
+
signal: signal || controller.signal,
|
|
137
|
+
});
|
|
138
|
+
clearTimeout(timeoutId);
|
|
139
|
+
if (!res.ok) {
|
|
140
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
141
|
+
let resBody = null;
|
|
142
|
+
try {
|
|
143
|
+
resBody = await res.json();
|
|
144
|
+
if (typeof resBody === "object" &&
|
|
145
|
+
resBody !== null &&
|
|
146
|
+
"error" in resBody) {
|
|
147
|
+
const err = resBody.error;
|
|
148
|
+
if (err?.message) {
|
|
149
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// ignore parse errors
|
|
155
|
+
}
|
|
156
|
+
throw new FireworksError(message, res.status, resBody);
|
|
157
|
+
}
|
|
158
|
+
for await (const { event, data } of sseToIterable(res)) {
|
|
159
|
+
if (event === "message_stop") {
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const parsed = JSON.parse(data);
|
|
164
|
+
yield parsed;
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// ignore non-JSON lines
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
clearTimeout(timeoutId);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// POST https://api.fireworks.ai/inference/v1/messages
|
|
176
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
177
|
+
async function messagesImpl(req, signal) {
|
|
178
|
+
const controller = new AbortController();
|
|
179
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
180
|
+
try {
|
|
181
|
+
const res = await doFetch(`${baseURL}/messages`, {
|
|
182
|
+
method: "POST",
|
|
183
|
+
headers: {
|
|
184
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
185
|
+
"Content-Type": "application/json",
|
|
186
|
+
},
|
|
187
|
+
body: JSON.stringify(req),
|
|
188
|
+
signal: signal || controller.signal,
|
|
189
|
+
});
|
|
190
|
+
clearTimeout(timeoutId);
|
|
191
|
+
if (!res.ok) {
|
|
192
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
193
|
+
let resBody = null;
|
|
194
|
+
try {
|
|
195
|
+
resBody = await res.json();
|
|
196
|
+
if (typeof resBody === "object" &&
|
|
197
|
+
resBody !== null &&
|
|
198
|
+
"error" in resBody) {
|
|
199
|
+
const err = resBody.error;
|
|
200
|
+
if (err?.message) {
|
|
201
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// ignore parse errors
|
|
207
|
+
}
|
|
208
|
+
throw new FireworksError(message, res.status, resBody);
|
|
209
|
+
}
|
|
210
|
+
return (await res.json());
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
clearTimeout(timeoutId);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function makeWorkflowRequest(model, suffix, body, signal) {
|
|
217
|
+
const controller = new AbortController();
|
|
218
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
219
|
+
if (signal) {
|
|
220
|
+
attachAbortHandler(signal, controller);
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const url = `${baseURL}/workflows/accounts/fireworks/models/${model}${suffix}`;
|
|
224
|
+
const res = await doFetch(url, {
|
|
225
|
+
method: "POST",
|
|
226
|
+
headers: {
|
|
227
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
228
|
+
"Content-Type": "application/json",
|
|
229
|
+
Accept: "application/json",
|
|
230
|
+
},
|
|
231
|
+
body: JSON.stringify(body),
|
|
232
|
+
signal: controller.signal,
|
|
233
|
+
});
|
|
234
|
+
clearTimeout(timeoutId);
|
|
235
|
+
if (!res.ok) {
|
|
236
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
237
|
+
let resBody = null;
|
|
238
|
+
try {
|
|
239
|
+
resBody = await res.json();
|
|
240
|
+
if (typeof resBody === "object" &&
|
|
241
|
+
resBody !== null &&
|
|
242
|
+
"error" in resBody) {
|
|
243
|
+
const err = resBody.error;
|
|
244
|
+
if (err?.message) {
|
|
245
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (typeof resBody === "object" &&
|
|
249
|
+
resBody !== null &&
|
|
250
|
+
"error_message" in resBody) {
|
|
251
|
+
message = `Fireworks API error ${res.status}: ${resBody.error_message}`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
// ignore parse errors
|
|
256
|
+
}
|
|
257
|
+
throw new FireworksError(message, res.status, resBody);
|
|
258
|
+
}
|
|
259
|
+
return (await res.json());
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
clearTimeout(timeoutId);
|
|
263
|
+
if (error instanceof FireworksError)
|
|
264
|
+
throw error;
|
|
265
|
+
throw new FireworksError(`Fireworks request failed: ${error}`, 500);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function getAudioBaseURL(model) {
|
|
269
|
+
if (model === "whisper-v3-turbo") {
|
|
270
|
+
return "https://audio-turbo.api.fireworks.ai/v1";
|
|
271
|
+
}
|
|
272
|
+
return audioBaseURL;
|
|
273
|
+
}
|
|
274
|
+
async function makeAudioRequest(path, form, model, signal) {
|
|
275
|
+
const controller = new AbortController();
|
|
276
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
277
|
+
if (signal) {
|
|
278
|
+
attachAbortHandler(signal, controller);
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
const url = `${getAudioBaseURL(model)}${path}`;
|
|
282
|
+
const res = await doFetch(url, {
|
|
283
|
+
method: "POST",
|
|
284
|
+
headers: {
|
|
285
|
+
Authorization: opts.apiKey,
|
|
286
|
+
},
|
|
287
|
+
body: form,
|
|
288
|
+
signal: controller.signal,
|
|
289
|
+
});
|
|
290
|
+
clearTimeout(timeoutId);
|
|
291
|
+
if (!res.ok) {
|
|
292
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
293
|
+
let resBody = null;
|
|
294
|
+
try {
|
|
295
|
+
resBody = await res.json();
|
|
296
|
+
if (typeof resBody === "object" &&
|
|
297
|
+
resBody !== null &&
|
|
298
|
+
"error" in resBody) {
|
|
299
|
+
const err = resBody.error;
|
|
300
|
+
if (err?.message) {
|
|
301
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
// ignore parse errors
|
|
307
|
+
}
|
|
308
|
+
throw new FireworksError(message, res.status, resBody);
|
|
309
|
+
}
|
|
310
|
+
return (await res.json());
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
clearTimeout(timeoutId);
|
|
314
|
+
if (error instanceof FireworksError)
|
|
315
|
+
throw error;
|
|
316
|
+
throw new FireworksError(`Fireworks request failed: ${error}`, 500);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const audioBatchBaseURL = "https://audio-batch.api.fireworks.ai/v1";
|
|
320
|
+
async function makeAudioBatchRequest(path, form, endpointId, signal) {
|
|
321
|
+
const controller = new AbortController();
|
|
322
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
323
|
+
if (signal) {
|
|
324
|
+
attachAbortHandler(signal, controller);
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
const url = `${audioBatchBaseURL}${path}?endpoint_id=${encodeURIComponent(endpointId)}`;
|
|
328
|
+
const res = await doFetch(url, {
|
|
329
|
+
method: "POST",
|
|
330
|
+
headers: {
|
|
331
|
+
Authorization: opts.apiKey,
|
|
332
|
+
},
|
|
333
|
+
body: form,
|
|
334
|
+
signal: controller.signal,
|
|
335
|
+
});
|
|
336
|
+
clearTimeout(timeoutId);
|
|
337
|
+
if (!res.ok) {
|
|
338
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
339
|
+
let resBody = null;
|
|
340
|
+
try {
|
|
341
|
+
resBody = await res.json();
|
|
342
|
+
if (typeof resBody === "object" &&
|
|
343
|
+
resBody !== null &&
|
|
344
|
+
"error" in resBody) {
|
|
345
|
+
const err = resBody.error;
|
|
346
|
+
if (err?.message) {
|
|
347
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
// ignore parse errors
|
|
353
|
+
}
|
|
354
|
+
throw new FireworksError(message, res.status, resBody);
|
|
355
|
+
}
|
|
356
|
+
return (await res.json());
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
clearTimeout(timeoutId);
|
|
360
|
+
if (error instanceof FireworksError)
|
|
361
|
+
throw error;
|
|
362
|
+
throw new FireworksError(`Fireworks request failed: ${error}`, 500);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async function makeModelsRequest(method, path, body, query, signal) {
|
|
366
|
+
const controller = new AbortController();
|
|
367
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
368
|
+
if (signal) {
|
|
369
|
+
attachAbortHandler(signal, controller);
|
|
370
|
+
}
|
|
371
|
+
try {
|
|
372
|
+
let url = `${modelsBaseURL}${path}`;
|
|
373
|
+
if (query) {
|
|
374
|
+
const params = new URLSearchParams();
|
|
375
|
+
for (const [k, v] of Object.entries(query)) {
|
|
376
|
+
if (v !== undefined)
|
|
377
|
+
params.append(k, String(v));
|
|
378
|
+
}
|
|
379
|
+
const qs = params.toString();
|
|
380
|
+
if (qs)
|
|
381
|
+
url += `?${qs}`;
|
|
382
|
+
}
|
|
383
|
+
const headers = {
|
|
384
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
385
|
+
};
|
|
386
|
+
if (method !== "GET" && method !== "DELETE") {
|
|
387
|
+
headers["Content-Type"] = "application/json";
|
|
388
|
+
}
|
|
389
|
+
const init = {
|
|
390
|
+
method,
|
|
391
|
+
headers,
|
|
392
|
+
signal: controller.signal,
|
|
393
|
+
};
|
|
394
|
+
if (body !== undefined && method !== "GET" && method !== "DELETE") {
|
|
395
|
+
init.body = JSON.stringify(body);
|
|
396
|
+
}
|
|
397
|
+
const res = await doFetch(url, init);
|
|
398
|
+
clearTimeout(timeoutId);
|
|
399
|
+
if (!res.ok) {
|
|
400
|
+
let message = `Fireworks API error: ${res.status}`;
|
|
401
|
+
let resBody = null;
|
|
402
|
+
try {
|
|
403
|
+
resBody = await res.json();
|
|
404
|
+
if (typeof resBody === "object" &&
|
|
405
|
+
resBody !== null &&
|
|
406
|
+
"error" in resBody) {
|
|
407
|
+
const err = resBody.error;
|
|
408
|
+
if (err?.message) {
|
|
409
|
+
message = `Fireworks API error ${res.status}: ${err.message}`;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
catch {
|
|
414
|
+
// ignore parse errors
|
|
415
|
+
}
|
|
416
|
+
throw new FireworksError(message, res.status, resBody);
|
|
417
|
+
}
|
|
418
|
+
return (await res.json());
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
clearTimeout(timeoutId);
|
|
422
|
+
if (error instanceof FireworksError)
|
|
423
|
+
throw error;
|
|
424
|
+
throw new FireworksError(`Fireworks request failed: ${error}`, 500);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
// ============================================================
|
|
428
|
+
// Verb-Prefixed API Surface Implementation
|
|
429
|
+
// ============================================================
|
|
430
|
+
// POST namespace - methods that use HTTP POST
|
|
431
|
+
const postV1 = {
|
|
432
|
+
chat: {
|
|
433
|
+
// POST https://api.fireworks.ai/inference/v1/chat/completions
|
|
434
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
435
|
+
completions: Object.assign(async (req, signal) => {
|
|
436
|
+
return await makeRequest("/chat/completions", req, signal);
|
|
437
|
+
}, {
|
|
438
|
+
schema: FireworksChatRequestSchema,
|
|
439
|
+
}),
|
|
440
|
+
},
|
|
441
|
+
// POST https://api.fireworks.ai/inference/v1/completions
|
|
442
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
443
|
+
completions: Object.assign(async (req, signal) => {
|
|
444
|
+
return await makeRequest("/completions", req, signal);
|
|
445
|
+
}, {
|
|
446
|
+
schema: FireworksCompletionRequestSchema,
|
|
447
|
+
}),
|
|
448
|
+
// POST https://api.fireworks.ai/inference/v1/embeddings
|
|
449
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
450
|
+
embeddings: Object.assign(async (req, signal) => {
|
|
451
|
+
return await makeRequest("/embeddings", req, signal);
|
|
452
|
+
}, {
|
|
453
|
+
schema: FireworksEmbeddingRequestSchema,
|
|
454
|
+
}),
|
|
455
|
+
// POST https://api.fireworks.ai/inference/v1/rerank
|
|
456
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
457
|
+
rerank: Object.assign(async (req, signal) => {
|
|
458
|
+
return await makeRequest("/rerank", req, signal);
|
|
459
|
+
}, {
|
|
460
|
+
schema: FireworksRerankRequestSchema,
|
|
461
|
+
}),
|
|
462
|
+
messages: Object.assign(messagesImpl, {
|
|
463
|
+
schema: AnthropicMessagesRequestSchema,
|
|
464
|
+
}),
|
|
465
|
+
workflows: {
|
|
466
|
+
// POST https://api.fireworks.ai/inference/v1/workflows/accounts/fireworks/models/{model}/text_to_image
|
|
467
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
468
|
+
textToImage: Object.assign(async (model, req, signal) => {
|
|
469
|
+
return await makeWorkflowRequest(model, "/text_to_image", req, signal);
|
|
470
|
+
}, {
|
|
471
|
+
schema: FireworksTextToImageRequestSchema,
|
|
472
|
+
}),
|
|
473
|
+
// POST https://api.fireworks.ai/inference/v1/workflows/accounts/fireworks/models/{model}
|
|
474
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
475
|
+
kontext: Object.assign(async (model, req, signal) => {
|
|
476
|
+
return await makeWorkflowRequest(model, "", { safety_tolerance: 6, ...req }, signal);
|
|
477
|
+
}, {
|
|
478
|
+
schema: FireworksKontextRequestSchema,
|
|
479
|
+
}),
|
|
480
|
+
// POST https://api.fireworks.ai/inference/v1/workflows/accounts/fireworks/models/{model}/get_result
|
|
481
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
482
|
+
getResult: Object.assign(async (model, req, signal) => {
|
|
483
|
+
return await makeWorkflowRequest(model, "/get_result", req, signal);
|
|
484
|
+
}, {
|
|
485
|
+
schema: FireworksGetResultRequestSchema,
|
|
486
|
+
}),
|
|
487
|
+
},
|
|
488
|
+
audio: {
|
|
489
|
+
// POST https://api.fireworks.ai/inference/v1/audio/transcriptions
|
|
490
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
491
|
+
transcriptions: Object.assign(async (req, signal) => {
|
|
492
|
+
const form = new FormData();
|
|
493
|
+
if (typeof req.file === "string") {
|
|
494
|
+
form.append("file", req.file);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
form.append("file", req.file);
|
|
498
|
+
}
|
|
499
|
+
if (req.model !== undefined)
|
|
500
|
+
form.append("model", req.model);
|
|
501
|
+
if (req.vad_model !== undefined)
|
|
502
|
+
form.append("vad_model", req.vad_model);
|
|
503
|
+
if (req.alignment_model !== undefined)
|
|
504
|
+
form.append("alignment_model", req.alignment_model);
|
|
505
|
+
if (req.language !== undefined)
|
|
506
|
+
form.append("language", req.language);
|
|
507
|
+
if (req.prompt !== undefined)
|
|
508
|
+
form.append("prompt", req.prompt);
|
|
509
|
+
if (req.temperature !== undefined) {
|
|
510
|
+
form.append("temperature", Array.isArray(req.temperature)
|
|
511
|
+
? JSON.stringify(req.temperature)
|
|
512
|
+
: String(req.temperature));
|
|
513
|
+
}
|
|
514
|
+
if (req.response_format !== undefined)
|
|
515
|
+
form.append("response_format", req.response_format);
|
|
516
|
+
if (req.timestamp_granularities !== undefined) {
|
|
517
|
+
form.append("timestamp_granularities", Array.isArray(req.timestamp_granularities)
|
|
518
|
+
? req.timestamp_granularities.join(",")
|
|
519
|
+
: req.timestamp_granularities);
|
|
520
|
+
}
|
|
521
|
+
if (req.diarize !== undefined)
|
|
522
|
+
form.append("diarize", req.diarize);
|
|
523
|
+
if (req.min_speakers !== undefined)
|
|
524
|
+
form.append("min_speakers", String(req.min_speakers));
|
|
525
|
+
if (req.max_speakers !== undefined)
|
|
526
|
+
form.append("max_speakers", String(req.max_speakers));
|
|
527
|
+
if (req.preprocessing !== undefined)
|
|
528
|
+
form.append("preprocessing", req.preprocessing);
|
|
529
|
+
return await makeAudioRequest("/audio/transcriptions", form, req.model, signal);
|
|
530
|
+
}, {
|
|
531
|
+
schema: FireworksTranscriptionRequestSchema,
|
|
532
|
+
}),
|
|
533
|
+
// POST https://api.fireworks.ai/inference/v1/audio/translations
|
|
534
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
535
|
+
translations: Object.assign(async (req, signal) => {
|
|
536
|
+
const form = new FormData();
|
|
537
|
+
if (typeof req.file === "string") {
|
|
538
|
+
form.append("file", req.file);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
form.append("file", req.file);
|
|
542
|
+
}
|
|
543
|
+
if (req.model !== undefined)
|
|
544
|
+
form.append("model", req.model);
|
|
545
|
+
if (req.vad_model !== undefined)
|
|
546
|
+
form.append("vad_model", req.vad_model);
|
|
547
|
+
if (req.alignment_model !== undefined)
|
|
548
|
+
form.append("alignment_model", req.alignment_model);
|
|
549
|
+
if (req.language !== undefined)
|
|
550
|
+
form.append("language", req.language);
|
|
551
|
+
if (req.prompt !== undefined)
|
|
552
|
+
form.append("prompt", req.prompt);
|
|
553
|
+
if (req.temperature !== undefined) {
|
|
554
|
+
form.append("temperature", Array.isArray(req.temperature)
|
|
555
|
+
? JSON.stringify(req.temperature)
|
|
556
|
+
: String(req.temperature));
|
|
557
|
+
}
|
|
558
|
+
if (req.response_format !== undefined)
|
|
559
|
+
form.append("response_format", req.response_format);
|
|
560
|
+
if (req.timestamp_granularities !== undefined) {
|
|
561
|
+
form.append("timestamp_granularities", Array.isArray(req.timestamp_granularities)
|
|
562
|
+
? req.timestamp_granularities.join(",")
|
|
563
|
+
: req.timestamp_granularities);
|
|
564
|
+
}
|
|
565
|
+
if (req.preprocessing !== undefined)
|
|
566
|
+
form.append("preprocessing", req.preprocessing);
|
|
567
|
+
return await makeAudioRequest("/audio/translations", form, req.model, signal);
|
|
568
|
+
}, {
|
|
569
|
+
schema: FireworksTranslationRequestSchema,
|
|
570
|
+
}),
|
|
571
|
+
batch: {
|
|
572
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
573
|
+
// POST https://api.fireworks.ai/inference/v1/audio/transcriptions
|
|
574
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
575
|
+
transcriptions: Object.assign(async (req, signal) => {
|
|
576
|
+
const form = new FormData();
|
|
577
|
+
if (typeof req.file === "string") {
|
|
578
|
+
form.append("file", req.file);
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
form.append("file", req.file);
|
|
582
|
+
}
|
|
583
|
+
if (req.model !== undefined)
|
|
584
|
+
form.append("model", req.model);
|
|
585
|
+
if (req.vad_model !== undefined)
|
|
586
|
+
form.append("vad_model", req.vad_model);
|
|
587
|
+
if (req.alignment_model !== undefined)
|
|
588
|
+
form.append("alignment_model", req.alignment_model);
|
|
589
|
+
if (req.language !== undefined)
|
|
590
|
+
form.append("language", req.language);
|
|
591
|
+
if (req.prompt !== undefined)
|
|
592
|
+
form.append("prompt", req.prompt);
|
|
593
|
+
if (req.temperature !== undefined) {
|
|
594
|
+
form.append("temperature", Array.isArray(req.temperature)
|
|
595
|
+
? JSON.stringify(req.temperature)
|
|
596
|
+
: String(req.temperature));
|
|
597
|
+
}
|
|
598
|
+
if (req.response_format !== undefined)
|
|
599
|
+
form.append("response_format", req.response_format);
|
|
600
|
+
if (req.timestamp_granularities !== undefined) {
|
|
601
|
+
form.append("timestamp_granularities", Array.isArray(req.timestamp_granularities)
|
|
602
|
+
? req.timestamp_granularities.join(",")
|
|
603
|
+
: req.timestamp_granularities);
|
|
604
|
+
}
|
|
605
|
+
if (req.diarize !== undefined)
|
|
606
|
+
form.append("diarize", req.diarize);
|
|
607
|
+
if (req.min_speakers !== undefined)
|
|
608
|
+
form.append("min_speakers", String(req.min_speakers));
|
|
609
|
+
if (req.max_speakers !== undefined)
|
|
610
|
+
form.append("max_speakers", String(req.max_speakers));
|
|
611
|
+
if (req.preprocessing !== undefined)
|
|
612
|
+
form.append("preprocessing", req.preprocessing);
|
|
613
|
+
return await makeAudioBatchRequest("/audio/transcriptions", form, req.endpoint_id, signal);
|
|
614
|
+
}, {
|
|
615
|
+
schema: FireworksAudioBatchTranscriptionRequestSchema,
|
|
616
|
+
}),
|
|
617
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
618
|
+
// POST https://api.fireworks.ai/inference/v1/audio/translations
|
|
619
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
620
|
+
translations: Object.assign(async (req, signal) => {
|
|
621
|
+
const form = new FormData();
|
|
622
|
+
if (typeof req.file === "string") {
|
|
623
|
+
form.append("file", req.file);
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
form.append("file", req.file);
|
|
627
|
+
}
|
|
628
|
+
if (req.model !== undefined)
|
|
629
|
+
form.append("model", req.model);
|
|
630
|
+
if (req.vad_model !== undefined)
|
|
631
|
+
form.append("vad_model", req.vad_model);
|
|
632
|
+
if (req.alignment_model !== undefined)
|
|
633
|
+
form.append("alignment_model", req.alignment_model);
|
|
634
|
+
if (req.language !== undefined)
|
|
635
|
+
form.append("language", req.language);
|
|
636
|
+
if (req.prompt !== undefined)
|
|
637
|
+
form.append("prompt", req.prompt);
|
|
638
|
+
if (req.temperature !== undefined) {
|
|
639
|
+
form.append("temperature", Array.isArray(req.temperature)
|
|
640
|
+
? JSON.stringify(req.temperature)
|
|
641
|
+
: String(req.temperature));
|
|
642
|
+
}
|
|
643
|
+
if (req.response_format !== undefined)
|
|
644
|
+
form.append("response_format", req.response_format);
|
|
645
|
+
if (req.timestamp_granularities !== undefined) {
|
|
646
|
+
form.append("timestamp_granularities", Array.isArray(req.timestamp_granularities)
|
|
647
|
+
? req.timestamp_granularities.join(",")
|
|
648
|
+
: req.timestamp_granularities);
|
|
649
|
+
}
|
|
650
|
+
if (req.preprocessing !== undefined)
|
|
651
|
+
form.append("preprocessing", req.preprocessing);
|
|
652
|
+
return await makeAudioBatchRequest("/audio/translations", form, req.endpoint_id, signal);
|
|
653
|
+
}, {
|
|
654
|
+
schema: FireworksAudioBatchTranslationRequestSchema,
|
|
655
|
+
}),
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
accounts: {
|
|
659
|
+
users: {
|
|
660
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
661
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users
|
|
662
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
663
|
+
create: Object.assign(async (accountId, req, options, signal) => {
|
|
664
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/users`, req, options, signal);
|
|
665
|
+
}, {
|
|
666
|
+
schema: FireworksCreateUserRequestSchema,
|
|
667
|
+
}),
|
|
668
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
669
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users/{userId}
|
|
670
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
671
|
+
update: Object.assign(async (accountId, userId, req, signal) => {
|
|
672
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/users/${userId}`, req, undefined, signal);
|
|
673
|
+
}, {
|
|
674
|
+
schema: FireworksUpdateUserRequestSchema,
|
|
675
|
+
async post(accountId, userId, req, signal) {
|
|
676
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/users/${userId}`, req, undefined, signal);
|
|
677
|
+
},
|
|
678
|
+
}),
|
|
679
|
+
},
|
|
680
|
+
models: {
|
|
681
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
682
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models
|
|
683
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
684
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
685
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/models`, req, undefined, signal);
|
|
686
|
+
}, {
|
|
687
|
+
schema: FireworksCreateModelRequestSchema,
|
|
688
|
+
}),
|
|
689
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
690
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models/{modelId}:prepare
|
|
691
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
692
|
+
prepare: Object.assign(async (accountId, modelId, req, signal) => {
|
|
693
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/models/${modelId}:prepare`, req, undefined, signal);
|
|
694
|
+
}, {
|
|
695
|
+
schema: FireworksPrepareModelRequestSchema,
|
|
696
|
+
}),
|
|
697
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
698
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models/{modelId}:getUploadEndpoint
|
|
699
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
700
|
+
getUploadEndpoint: Object.assign(async (accountId, modelId, req, signal) => {
|
|
701
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/models/${modelId}:getUploadEndpoint`, req, undefined, signal);
|
|
702
|
+
}, {
|
|
703
|
+
schema: FireworksGetUploadEndpointRequestSchema,
|
|
704
|
+
}),
|
|
705
|
+
},
|
|
706
|
+
deployments: {
|
|
707
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
708
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployments
|
|
709
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
710
|
+
create: Object.assign(async (accountId, req, options, signal) => {
|
|
711
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/deployments`, req, options, signal);
|
|
712
|
+
}, {
|
|
713
|
+
schema: FireworksCreateDeploymentRequestSchema,
|
|
714
|
+
}),
|
|
715
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
716
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployments/{deploymentId}:undelete
|
|
717
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
718
|
+
undelete: async (accountId, deploymentId, signal) => {
|
|
719
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/deployments/${deploymentId}:undelete`, {}, undefined, signal);
|
|
720
|
+
},
|
|
721
|
+
},
|
|
722
|
+
deployedModels: {
|
|
723
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
724
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployedModels
|
|
725
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
726
|
+
create: Object.assign(async (accountId, req, options, signal) => {
|
|
727
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/deployedModels`, req, options, signal);
|
|
728
|
+
}, {
|
|
729
|
+
schema: FireworksCreateDeployedModelRequestSchema,
|
|
730
|
+
}),
|
|
731
|
+
},
|
|
732
|
+
apiKeys: {
|
|
733
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
734
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users/{userId}/apiKeys
|
|
735
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
736
|
+
create: Object.assign(async (accountId, userId, req, signal) => {
|
|
737
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/users/${userId}/apiKeys`, req, undefined, signal);
|
|
738
|
+
}, {
|
|
739
|
+
schema: FireworksCreateApiKeyRequestSchema,
|
|
740
|
+
}),
|
|
741
|
+
},
|
|
742
|
+
secrets: {
|
|
743
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
744
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/secrets
|
|
745
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
746
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
747
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/secrets`, req, undefined, signal);
|
|
748
|
+
}, {
|
|
749
|
+
schema: FireworksCreateSecretRequestSchema,
|
|
750
|
+
}),
|
|
751
|
+
},
|
|
752
|
+
datasets: {
|
|
753
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
754
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets
|
|
755
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
756
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
757
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/datasets`, req, undefined, signal);
|
|
758
|
+
}, {
|
|
759
|
+
schema: FireworksCreateDatasetRequestSchema,
|
|
760
|
+
}),
|
|
761
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
762
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets/{datasetId}:getUploadEndpoint
|
|
763
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
764
|
+
getUploadEndpoint: Object.assign(async (accountId, datasetId, req, signal) => {
|
|
765
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/datasets/${datasetId}:getUploadEndpoint`, req, undefined, signal);
|
|
766
|
+
}, {
|
|
767
|
+
schema: FireworksDatasetGetUploadEndpointRequestSchema,
|
|
768
|
+
}),
|
|
769
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
770
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets/{datasetId}:validateUpload
|
|
771
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
772
|
+
validateUpload: Object.assign(async (accountId, datasetId, req, signal) => {
|
|
773
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/datasets/${datasetId}:validateUpload`, req ?? {}, undefined, signal);
|
|
774
|
+
}, {
|
|
775
|
+
schema: FireworksDatasetValidateUploadRequestSchema,
|
|
776
|
+
}),
|
|
777
|
+
},
|
|
778
|
+
batchInferenceJobs: {
|
|
779
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
780
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/batchInferenceJobs
|
|
781
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
782
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
783
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/batchInferenceJobs`, req, undefined, signal);
|
|
784
|
+
}, {
|
|
785
|
+
schema: FireworksBatchJobCreateRequestSchema,
|
|
786
|
+
}),
|
|
787
|
+
},
|
|
788
|
+
supervisedFineTuningJobs: {
|
|
789
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
790
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/supervisedFineTuningJobs
|
|
791
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
792
|
+
create: Object.assign(async (req, signal) => {
|
|
793
|
+
const { accountId, supervisedFineTuningJobId, ...body } = req;
|
|
794
|
+
const query = {};
|
|
795
|
+
if (supervisedFineTuningJobId) {
|
|
796
|
+
query.supervisedFineTuningJobId = supervisedFineTuningJobId;
|
|
797
|
+
}
|
|
798
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/supervisedFineTuningJobs`, body, Object.keys(query).length > 0 ? query : undefined, signal);
|
|
799
|
+
}, {
|
|
800
|
+
schema: FireworksSFTCreateRequestSchema,
|
|
801
|
+
}),
|
|
802
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
803
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{param}/supervisedFineTuningJobs/{param}:resume
|
|
804
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
805
|
+
resume: async (req, signal) => {
|
|
806
|
+
return await makeModelsRequest("POST", `/v1/accounts/${req.accountId}/supervisedFineTuningJobs/${req.jobId}:resume`, {}, undefined, signal);
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
dpoJobs: {
|
|
810
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
811
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/dpoJobs
|
|
812
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
813
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
814
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/dpoJobs`, req, undefined, signal);
|
|
815
|
+
}, {
|
|
816
|
+
schema: FireworksDpoJobCreateRequestSchema,
|
|
817
|
+
}),
|
|
818
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
819
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/dpoJobs/{jobId}:resume
|
|
820
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
821
|
+
resume: async (accountId, jobId, signal) => {
|
|
822
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/dpoJobs/${jobId}:resume`, {}, undefined, signal);
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
evaluators: {
|
|
826
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
827
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluatorsV2
|
|
828
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
829
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
830
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/evaluatorsV2`, req, undefined, signal);
|
|
831
|
+
}, {
|
|
832
|
+
schema: FireworksCreateEvaluatorRequestSchema,
|
|
833
|
+
}),
|
|
834
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
835
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators/{evaluatorId}:getUploadEndpoint
|
|
836
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
837
|
+
getUploadEndpoint: Object.assign(async (accountId, evaluatorId, req, signal) => {
|
|
838
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/evaluators/${evaluatorId}:getUploadEndpoint`, req, undefined, signal);
|
|
839
|
+
}, {
|
|
840
|
+
schema: FireworksGetUploadEndpointEvaluatorRequestSchema,
|
|
841
|
+
}),
|
|
842
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
843
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators/{evaluatorId}:validateUpload
|
|
844
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
845
|
+
validateUpload: async (accountId, evaluatorId, signal) => {
|
|
846
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/evaluators/${evaluatorId}:validateUpload`, {}, undefined, signal);
|
|
847
|
+
},
|
|
848
|
+
},
|
|
849
|
+
evaluationJobs: {
|
|
850
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
851
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluationJobs
|
|
852
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
853
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
854
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/evaluationJobs`, req, undefined, signal);
|
|
855
|
+
}, {
|
|
856
|
+
schema: FireworksCreateEvaluationJobRequestSchema,
|
|
857
|
+
}),
|
|
858
|
+
},
|
|
859
|
+
reinforcementFineTuningJobs: {
|
|
860
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
861
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/reinforcementFineTuningJobs
|
|
862
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
863
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
864
|
+
const { reinforcementFineTuningJobId, ...body } = req;
|
|
865
|
+
const query = {};
|
|
866
|
+
if (reinforcementFineTuningJobId) {
|
|
867
|
+
query.reinforcementFineTuningJobId = reinforcementFineTuningJobId;
|
|
868
|
+
}
|
|
869
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/reinforcementFineTuningJobs`, body, Object.keys(query).length > 0 ? query : undefined, signal);
|
|
870
|
+
}, {
|
|
871
|
+
schema: FireworksRFTCreateRequestSchema,
|
|
872
|
+
}),
|
|
873
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
874
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/reinforcementFineTuningJobs/{jobId}:resume
|
|
875
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
876
|
+
resume: async (accountId, jobId, signal) => {
|
|
877
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/reinforcementFineTuningJobs/${jobId}:resume`, {}, undefined, signal);
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
rlorTrainerJobs: {
|
|
881
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
882
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/rlorTrainerJobs
|
|
883
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
884
|
+
create: Object.assign(async (accountId, req, signal) => {
|
|
885
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/rlorTrainerJobs`, req, undefined, signal);
|
|
886
|
+
}, {
|
|
887
|
+
schema: FireworksRlorTrainerJobCreateRequestSchema,
|
|
888
|
+
}),
|
|
889
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
890
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/rlorTrainerJobs/{jobId}:executeTrainStep
|
|
891
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
892
|
+
executeTrainStep: Object.assign(async (accountId, jobId, req, signal) => {
|
|
893
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/rlorTrainerJobs/${jobId}:executeTrainStep`, req, undefined, signal);
|
|
894
|
+
}, {
|
|
895
|
+
schema: FireworksRlorTrainerJobExecuteStepRequestSchema,
|
|
896
|
+
}),
|
|
897
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
898
|
+
// POST https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/rlorTrainerJobs/{jobId}:resume
|
|
899
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
900
|
+
resume: async (accountId, jobId, signal) => {
|
|
901
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/rlorTrainerJobs/${jobId}:resume`, {}, undefined, signal);
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
},
|
|
905
|
+
};
|
|
906
|
+
// POST stream namespace - streaming methods
|
|
907
|
+
const postStreamV1 = {
|
|
908
|
+
chat: {
|
|
909
|
+
completions: Object.assign((req, signal) => {
|
|
910
|
+
return makeStreamRequest("/chat/completions", { ...req, stream: true }, signal);
|
|
911
|
+
}, {
|
|
912
|
+
schema: FireworksChatRequestSchema,
|
|
913
|
+
}),
|
|
914
|
+
},
|
|
915
|
+
completions: Object.assign((req, signal) => {
|
|
916
|
+
return makeStreamRequest("/completions", { ...req, stream: true }, signal);
|
|
917
|
+
}, {
|
|
918
|
+
schema: FireworksCompletionRequestSchema,
|
|
919
|
+
}),
|
|
920
|
+
messages: Object.assign(messagesStreamImpl, {
|
|
921
|
+
schema: AnthropicMessagesRequestSchema,
|
|
922
|
+
}),
|
|
923
|
+
};
|
|
924
|
+
// GET namespace - methods that use HTTP GET
|
|
925
|
+
const getV1 = {
|
|
926
|
+
accounts: {
|
|
927
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
928
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts
|
|
929
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
930
|
+
list: async (params, signal) => {
|
|
931
|
+
return await makeModelsRequest("GET", "/v1/accounts", undefined, params, signal);
|
|
932
|
+
},
|
|
933
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
934
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}
|
|
935
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
936
|
+
get: async (accountId, params, signal) => {
|
|
937
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}`, undefined, params, signal);
|
|
938
|
+
},
|
|
939
|
+
users: {
|
|
940
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
941
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users
|
|
942
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
943
|
+
list: async (accountId, params, signal) => {
|
|
944
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/users`, undefined, params, signal);
|
|
945
|
+
},
|
|
946
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
947
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users/{userId}
|
|
948
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
949
|
+
get: async (accountId, userId, params, signal) => {
|
|
950
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/users/${userId}`, undefined, params, signal);
|
|
951
|
+
},
|
|
952
|
+
},
|
|
953
|
+
apiKeys: {
|
|
954
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
955
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users/{userId}/apiKeys
|
|
956
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
957
|
+
list: async (accountId, userId, params, signal) => {
|
|
958
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/users/${userId}/apiKeys`, undefined, params, signal);
|
|
959
|
+
},
|
|
960
|
+
},
|
|
961
|
+
secrets: {
|
|
962
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
963
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/secrets
|
|
964
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
965
|
+
list: async (accountId, params, signal) => {
|
|
966
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/secrets`, undefined, params, signal);
|
|
967
|
+
},
|
|
968
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
969
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/secrets/{secretId}
|
|
970
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
971
|
+
get: async (accountId, secretId, params, signal) => {
|
|
972
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/secrets/${secretId}`, undefined, params, signal);
|
|
973
|
+
},
|
|
974
|
+
},
|
|
975
|
+
models: {
|
|
976
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
977
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models
|
|
978
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
979
|
+
list: Object.assign(async (accountId, req, signal) => {
|
|
980
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/models`, undefined, req, signal);
|
|
981
|
+
}, {
|
|
982
|
+
schema: FireworksEmptySchema,
|
|
983
|
+
}),
|
|
984
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
985
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models/{modelId}
|
|
986
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
987
|
+
get: Object.assign(async (accountId, modelId, req, signal) => {
|
|
988
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/models/${modelId}`, undefined, req, signal);
|
|
989
|
+
}, {
|
|
990
|
+
schema: FireworksEmptySchema,
|
|
991
|
+
}),
|
|
992
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
993
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models/{modelId}:getDownloadEndpoint
|
|
994
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
995
|
+
getDownloadEndpoint: Object.assign(async (accountId, modelId, req, signal) => {
|
|
996
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/models/${modelId}:getDownloadEndpoint`, undefined, req, signal);
|
|
997
|
+
}, {
|
|
998
|
+
schema: FireworksEmptySchema,
|
|
999
|
+
}),
|
|
1000
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1001
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models/{modelId}:validateUpload
|
|
1002
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1003
|
+
validateUpload: Object.assign(async (accountId, modelId, req, signal) => {
|
|
1004
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/models/${modelId}:validateUpload`, undefined, req, signal);
|
|
1005
|
+
}, {
|
|
1006
|
+
schema: FireworksValidateUploadRequestSchema,
|
|
1007
|
+
}),
|
|
1008
|
+
},
|
|
1009
|
+
datasets: {
|
|
1010
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1011
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets
|
|
1012
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1013
|
+
list: async (accountId, params, signal) => {
|
|
1014
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/datasets`, undefined, params, signal);
|
|
1015
|
+
},
|
|
1016
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1017
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets/{datasetId}
|
|
1018
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1019
|
+
get: async (accountId, datasetId, req, signal) => {
|
|
1020
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/datasets/${datasetId}`, undefined, req, signal);
|
|
1021
|
+
},
|
|
1022
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1023
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets/{datasetId}:getDownloadEndpoint
|
|
1024
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1025
|
+
getDownloadEndpoint: Object.assign(async (accountId, datasetId, req, signal) => {
|
|
1026
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/datasets/${datasetId}:getDownloadEndpoint`, undefined, req, signal);
|
|
1027
|
+
}, {
|
|
1028
|
+
schema: FireworksEmptySchema,
|
|
1029
|
+
}),
|
|
1030
|
+
},
|
|
1031
|
+
batchInferenceJobs: {
|
|
1032
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1033
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/batchInferenceJobs
|
|
1034
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1035
|
+
list: async (accountId, req, signal) => {
|
|
1036
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/batchInferenceJobs`, undefined, req, signal);
|
|
1037
|
+
},
|
|
1038
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1039
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/batchInferenceJobs/{jobId}
|
|
1040
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1041
|
+
get: async (accountId, jobId, signal) => {
|
|
1042
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/batchInferenceJobs/${jobId}`, undefined, undefined, signal);
|
|
1043
|
+
},
|
|
1044
|
+
},
|
|
1045
|
+
supervisedFineTuningJobs: {
|
|
1046
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1047
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/supervisedFineTuningJobs
|
|
1048
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1049
|
+
list: async (req, signal) => {
|
|
1050
|
+
const { accountId, ...params } = req;
|
|
1051
|
+
const query = {};
|
|
1052
|
+
if (params.pageSize !== undefined)
|
|
1053
|
+
query.pageSize = params.pageSize;
|
|
1054
|
+
if (params.pageToken)
|
|
1055
|
+
query.pageToken = params.pageToken;
|
|
1056
|
+
if (params.filter)
|
|
1057
|
+
query.filter = params.filter;
|
|
1058
|
+
if (params.orderBy)
|
|
1059
|
+
query.orderBy = params.orderBy;
|
|
1060
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/supervisedFineTuningJobs`, undefined, Object.keys(query).length > 0 ? query : undefined, signal);
|
|
1061
|
+
},
|
|
1062
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1063
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{param}/supervisedFineTuningJobs/{param}
|
|
1064
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1065
|
+
get: async (req, signal) => {
|
|
1066
|
+
return await makeModelsRequest("GET", `/v1/accounts/${req.accountId}/supervisedFineTuningJobs/${req.jobId}`, undefined, undefined, signal);
|
|
1067
|
+
},
|
|
1068
|
+
},
|
|
1069
|
+
deployments: {
|
|
1070
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1071
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployments
|
|
1072
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1073
|
+
list: async (accountId, params, signal) => {
|
|
1074
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/deployments`, undefined, params, signal);
|
|
1075
|
+
},
|
|
1076
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1077
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployments/{deploymentId}
|
|
1078
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1079
|
+
get: async (accountId, deploymentId, signal) => {
|
|
1080
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/deployments/${deploymentId}`, undefined, undefined, signal);
|
|
1081
|
+
},
|
|
1082
|
+
},
|
|
1083
|
+
deploymentShapes: {
|
|
1084
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1085
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deploymentShapes/{shapeId}
|
|
1086
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1087
|
+
get: async (accountId, shapeId, params, signal) => {
|
|
1088
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/deploymentShapes/${shapeId}`, undefined, params, signal);
|
|
1089
|
+
},
|
|
1090
|
+
versions: {
|
|
1091
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1092
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deploymentShapes/{shapeId}/versions
|
|
1093
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1094
|
+
list: async (accountId, shapeId, params, signal) => {
|
|
1095
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/deploymentShapes/${shapeId}/versions`, undefined, params, signal);
|
|
1096
|
+
},
|
|
1097
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1098
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deploymentShapes/{shapeId}/versions/{versionId}
|
|
1099
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1100
|
+
get: async (accountId, shapeId, versionId, params, signal) => {
|
|
1101
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/deploymentShapes/${shapeId}/versions/${versionId}`, undefined, params, signal);
|
|
1102
|
+
},
|
|
1103
|
+
},
|
|
1104
|
+
},
|
|
1105
|
+
deployedModels: {
|
|
1106
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1107
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployedModels
|
|
1108
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1109
|
+
list: async (accountId, params, signal) => {
|
|
1110
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/deployedModels`, undefined, params, signal);
|
|
1111
|
+
},
|
|
1112
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1113
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployedModels/{deployedModelId}
|
|
1114
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1115
|
+
get: async (accountId, deployedModelId, params, signal) => {
|
|
1116
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/deployedModels/${deployedModelId}`, undefined, params, signal);
|
|
1117
|
+
},
|
|
1118
|
+
},
|
|
1119
|
+
dpoJobs: {
|
|
1120
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1121
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/dpoJobs
|
|
1122
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1123
|
+
list: async (accountId, req, signal) => {
|
|
1124
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/dpoJobs`, undefined, req, signal);
|
|
1125
|
+
},
|
|
1126
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1127
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/dpoJobs/{jobId}
|
|
1128
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1129
|
+
get: async (accountId, jobId, req, signal) => {
|
|
1130
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/dpoJobs/${jobId}`, undefined, req, signal);
|
|
1131
|
+
},
|
|
1132
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1133
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/dpoJobs/{jobId}:getMetricsFileEndpoint
|
|
1134
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1135
|
+
getMetricsFileEndpoint: async (accountId, jobId, signal) => {
|
|
1136
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/dpoJobs/${jobId}:getMetricsFileEndpoint`, undefined, undefined, signal);
|
|
1137
|
+
},
|
|
1138
|
+
},
|
|
1139
|
+
evaluators: {
|
|
1140
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1141
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators
|
|
1142
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1143
|
+
list: async (accountId, params, signal) => {
|
|
1144
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/evaluators`, undefined, params, signal);
|
|
1145
|
+
},
|
|
1146
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1147
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators/{evaluatorId}
|
|
1148
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1149
|
+
get: async (accountId, evaluatorId, params, signal) => {
|
|
1150
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/evaluators/${evaluatorId}`, undefined, params, signal);
|
|
1151
|
+
},
|
|
1152
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1153
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators/{evaluatorId}:getBuildLogEndpoint
|
|
1154
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1155
|
+
getBuildLogEndpoint: async (accountId, evaluatorId, params, signal) => {
|
|
1156
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/evaluators/${evaluatorId}:getBuildLogEndpoint`, undefined, params, signal);
|
|
1157
|
+
},
|
|
1158
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1159
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators/{evaluatorId}:getSourceCodeSignedUrl
|
|
1160
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1161
|
+
getSourceCodeSignedUrl: async (accountId, evaluatorId, params, signal) => {
|
|
1162
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/evaluators/${evaluatorId}:getSourceCodeSignedUrl`, undefined, params, signal);
|
|
1163
|
+
},
|
|
1164
|
+
},
|
|
1165
|
+
evaluationJobs: {
|
|
1166
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1167
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluationJobs
|
|
1168
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1169
|
+
list: async (accountId, params, signal) => {
|
|
1170
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/evaluationJobs`, undefined, params, signal);
|
|
1171
|
+
},
|
|
1172
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1173
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluationJobs/{evaluationJobId}
|
|
1174
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1175
|
+
get: async (accountId, evaluationJobId, params, signal) => {
|
|
1176
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/evaluationJobs/${evaluationJobId}`, undefined, params, signal);
|
|
1177
|
+
},
|
|
1178
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1179
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluationJobs/{evaluationJobId}:getExecutionLogEndpoint
|
|
1180
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1181
|
+
getExecutionLogEndpoint: async (accountId, evaluationJobId, signal) => {
|
|
1182
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/evaluationJobs/${evaluationJobId}:getExecutionLogEndpoint`, undefined, undefined, signal);
|
|
1183
|
+
},
|
|
1184
|
+
},
|
|
1185
|
+
reinforcementFineTuningJobs: {
|
|
1186
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1187
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/reinforcementFineTuningJobs
|
|
1188
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1189
|
+
list: async (accountId, req, signal) => {
|
|
1190
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/reinforcementFineTuningJobs`, undefined, req, signal);
|
|
1191
|
+
},
|
|
1192
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1193
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/reinforcementFineTuningJobs/{jobId}
|
|
1194
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1195
|
+
get: async (accountId, jobId, req, signal) => {
|
|
1196
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/reinforcementFineTuningJobs/${jobId}`, undefined, req, signal);
|
|
1197
|
+
},
|
|
1198
|
+
},
|
|
1199
|
+
rlorTrainerJobs: {
|
|
1200
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1201
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/rlorTrainerJobs
|
|
1202
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1203
|
+
list: async (accountId, req, signal) => {
|
|
1204
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/rlorTrainerJobs`, undefined, req, signal);
|
|
1205
|
+
},
|
|
1206
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1207
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/rlorTrainerJobs/{jobId}
|
|
1208
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1209
|
+
get: async (accountId, jobId, req, signal) => {
|
|
1210
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/rlorTrainerJobs/${jobId}`, undefined, req, signal);
|
|
1211
|
+
},
|
|
1212
|
+
},
|
|
1213
|
+
},
|
|
1214
|
+
audio: {
|
|
1215
|
+
batch: {
|
|
1216
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1217
|
+
// GET https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/batch_job/{batchId}
|
|
1218
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1219
|
+
get: async (accountId, batchId, signal) => {
|
|
1220
|
+
return await makeModelsRequest("GET", `/v1/accounts/${accountId}/batch_job/${batchId}`, undefined, undefined, signal);
|
|
1221
|
+
},
|
|
1222
|
+
},
|
|
1223
|
+
},
|
|
1224
|
+
};
|
|
1225
|
+
// PATCH namespace - methods that use HTTP PATCH
|
|
1226
|
+
const patchV1 = {
|
|
1227
|
+
accounts: {
|
|
1228
|
+
users: {
|
|
1229
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1230
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users/{userId}
|
|
1231
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1232
|
+
update: Object.assign(async (accountId, userId, req, signal) => {
|
|
1233
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/users/${userId}`, req, undefined, signal);
|
|
1234
|
+
}, {
|
|
1235
|
+
schema: FireworksUpdateUserRequestSchema,
|
|
1236
|
+
async post(accountId, userId, req, signal) {
|
|
1237
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/users/${userId}`, req, undefined, signal);
|
|
1238
|
+
},
|
|
1239
|
+
}),
|
|
1240
|
+
},
|
|
1241
|
+
models: {
|
|
1242
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1243
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models/{modelId}
|
|
1244
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1245
|
+
update: Object.assign(async (accountId, modelId, req, signal) => {
|
|
1246
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/models/${modelId}`, req, undefined, signal);
|
|
1247
|
+
}, {
|
|
1248
|
+
schema: FireworksUpdateModelRequestSchema,
|
|
1249
|
+
async post(accountId, modelId, req, signal) {
|
|
1250
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/models/${modelId}`, req, undefined, signal);
|
|
1251
|
+
},
|
|
1252
|
+
}),
|
|
1253
|
+
},
|
|
1254
|
+
datasets: {
|
|
1255
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1256
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets/{datasetId}
|
|
1257
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1258
|
+
update: Object.assign(async (accountId, datasetId, req, signal) => {
|
|
1259
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/datasets/${datasetId}`, req, undefined, signal);
|
|
1260
|
+
}, {
|
|
1261
|
+
schema: FireworksUpdateDatasetRequestSchema,
|
|
1262
|
+
}),
|
|
1263
|
+
},
|
|
1264
|
+
deployments: {
|
|
1265
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1266
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployments/{deploymentId}
|
|
1267
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1268
|
+
update: Object.assign(async (accountId, deploymentId, req, signal) => {
|
|
1269
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/deployments/${deploymentId}`, req, undefined, signal);
|
|
1270
|
+
}, {
|
|
1271
|
+
schema: FireworksUpdateDeploymentRequestSchema,
|
|
1272
|
+
async post(accountId, deploymentId, req, signal) {
|
|
1273
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/deployments/${deploymentId}`, req, undefined, signal);
|
|
1274
|
+
},
|
|
1275
|
+
}),
|
|
1276
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1277
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployments/{deploymentId}:scale
|
|
1278
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1279
|
+
scale: Object.assign(async (accountId, deploymentId, req, signal) => {
|
|
1280
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/deployments/${deploymentId}:scale`, req, undefined, signal);
|
|
1281
|
+
}, {
|
|
1282
|
+
schema: FireworksScaleDeploymentRequestSchema,
|
|
1283
|
+
}),
|
|
1284
|
+
},
|
|
1285
|
+
deployedModels: {
|
|
1286
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1287
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployedModels/{deployedModelId}
|
|
1288
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1289
|
+
update: Object.assign(async (accountId, deployedModelId, req, signal) => {
|
|
1290
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/deployedModels/${deployedModelId}`, req, undefined, signal);
|
|
1291
|
+
}, {
|
|
1292
|
+
schema: FireworksUpdateDeployedModelRequestSchema,
|
|
1293
|
+
}),
|
|
1294
|
+
},
|
|
1295
|
+
secrets: {
|
|
1296
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1297
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/secrets/{secretId}
|
|
1298
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1299
|
+
update: Object.assign(async (accountId, secretId, req, signal) => {
|
|
1300
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/secrets/${secretId}`, req, undefined, signal);
|
|
1301
|
+
}, {
|
|
1302
|
+
schema: FireworksUpdateSecretRequestSchema,
|
|
1303
|
+
}),
|
|
1304
|
+
},
|
|
1305
|
+
evaluators: {
|
|
1306
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1307
|
+
// PATCH https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators/{evaluatorId}
|
|
1308
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1309
|
+
update: Object.assign(async (accountId, evaluatorId, req, options, signal) => {
|
|
1310
|
+
return await makeModelsRequest("PATCH", `/v1/accounts/${accountId}/evaluators/${evaluatorId}`, req, options, signal);
|
|
1311
|
+
}, {
|
|
1312
|
+
schema: FireworksUpdateEvaluatorRequestSchema,
|
|
1313
|
+
}),
|
|
1314
|
+
},
|
|
1315
|
+
},
|
|
1316
|
+
};
|
|
1317
|
+
// DELETE namespace - methods that use HTTP DELETE
|
|
1318
|
+
const deleteV1 = {
|
|
1319
|
+
accounts: {
|
|
1320
|
+
apiKeys: {
|
|
1321
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1322
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/users/{userId}/apiKeys:delete
|
|
1323
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1324
|
+
delete: Object.assign(async (accountId, userId, req, signal) => {
|
|
1325
|
+
return await makeModelsRequest("POST", `/v1/accounts/${accountId}/users/${userId}/apiKeys:delete`, req, undefined, signal);
|
|
1326
|
+
}, {
|
|
1327
|
+
schema: FireworksDeleteApiKeyRequestSchema,
|
|
1328
|
+
}),
|
|
1329
|
+
},
|
|
1330
|
+
secrets: {
|
|
1331
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1332
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/secrets/{secretId}
|
|
1333
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1334
|
+
delete: async (accountId, secretId, signal) => {
|
|
1335
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/secrets/${secretId}`, undefined, undefined, signal);
|
|
1336
|
+
},
|
|
1337
|
+
},
|
|
1338
|
+
models: {
|
|
1339
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1340
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/models/{modelId}
|
|
1341
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1342
|
+
delete: Object.assign(async (accountId, modelId, signal) => {
|
|
1343
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/models/${modelId}`, undefined, undefined, signal);
|
|
1344
|
+
}, {
|
|
1345
|
+
schema: FireworksEmptySchema,
|
|
1346
|
+
}),
|
|
1347
|
+
},
|
|
1348
|
+
datasets: {
|
|
1349
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1350
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/datasets/{datasetId}
|
|
1351
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1352
|
+
delete: async (accountId, datasetId, signal) => {
|
|
1353
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/datasets/${datasetId}`, undefined, undefined, signal);
|
|
1354
|
+
},
|
|
1355
|
+
},
|
|
1356
|
+
batchInferenceJobs: {
|
|
1357
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1358
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/batchInferenceJobs/{jobId}
|
|
1359
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1360
|
+
delete: async (accountId, jobId, signal) => {
|
|
1361
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/batchInferenceJobs/${jobId}`, undefined, undefined, signal);
|
|
1362
|
+
},
|
|
1363
|
+
},
|
|
1364
|
+
supervisedFineTuningJobs: {
|
|
1365
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1366
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{param}/supervisedFineTuningJobs/{param}
|
|
1367
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1368
|
+
delete: Object.assign(async (req, signal) => {
|
|
1369
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${req.accountId}/supervisedFineTuningJobs/${req.jobId}`, undefined, undefined, signal);
|
|
1370
|
+
}, {
|
|
1371
|
+
schema: FireworksEmptySchema,
|
|
1372
|
+
}),
|
|
1373
|
+
},
|
|
1374
|
+
deployments: {
|
|
1375
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1376
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployments/{deploymentId}
|
|
1377
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1378
|
+
delete: async (accountId, deploymentId, options, signal) => {
|
|
1379
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/deployments/${deploymentId}`, undefined, options, signal);
|
|
1380
|
+
},
|
|
1381
|
+
},
|
|
1382
|
+
deployedModels: {
|
|
1383
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1384
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/deployedModels/{deployedModelId}
|
|
1385
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1386
|
+
delete: async (accountId, deployedModelId, signal) => {
|
|
1387
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/deployedModels/${deployedModelId}`, undefined, undefined, signal);
|
|
1388
|
+
},
|
|
1389
|
+
},
|
|
1390
|
+
dpoJobs: {
|
|
1391
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1392
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/dpoJobs/{jobId}
|
|
1393
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1394
|
+
delete: async (accountId, jobId, signal) => {
|
|
1395
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/dpoJobs/${jobId}`, undefined, undefined, signal);
|
|
1396
|
+
},
|
|
1397
|
+
},
|
|
1398
|
+
evaluators: {
|
|
1399
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1400
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluators/{evaluatorId}
|
|
1401
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1402
|
+
delete: async (accountId, evaluatorId, signal) => {
|
|
1403
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/evaluators/${evaluatorId}`, undefined, undefined, signal);
|
|
1404
|
+
},
|
|
1405
|
+
},
|
|
1406
|
+
evaluationJobs: {
|
|
1407
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1408
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/evaluationJobs/{evaluationJobId}
|
|
1409
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1410
|
+
delete: async (accountId, evaluationJobId, signal) => {
|
|
1411
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/evaluationJobs/${evaluationJobId}`, undefined, undefined, signal);
|
|
1412
|
+
},
|
|
1413
|
+
},
|
|
1414
|
+
reinforcementFineTuningJobs: {
|
|
1415
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1416
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/reinforcementFineTuningJobs/{jobId}
|
|
1417
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1418
|
+
delete: async (accountId, jobId, signal) => {
|
|
1419
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/reinforcementFineTuningJobs/${jobId}`, undefined, undefined, signal);
|
|
1420
|
+
},
|
|
1421
|
+
},
|
|
1422
|
+
rlorTrainerJobs: {
|
|
1423
|
+
// sig-ok: walker can't see baseURL override / management subpath
|
|
1424
|
+
// DELETE https://api.fireworks.ai/inference/v1/v1/accounts/{accountId}/rlorTrainerJobs/{jobId}
|
|
1425
|
+
// Docs: https://docs.fireworks.ai/api-reference
|
|
1426
|
+
delete: async (accountId, jobId, signal) => {
|
|
1427
|
+
return await makeModelsRequest("DELETE", `/v1/accounts/${accountId}/rlorTrainerJobs/${jobId}`, undefined, undefined, signal);
|
|
1428
|
+
},
|
|
1429
|
+
},
|
|
1430
|
+
},
|
|
1431
|
+
};
|
|
1432
|
+
// WS (WebSocket) namespace - WebSocket streaming methods
|
|
1433
|
+
const wsV1 = {
|
|
1434
|
+
audio: {
|
|
1435
|
+
transcriptions: {
|
|
1436
|
+
streaming: Object.assign((streamOpts) => {
|
|
1437
|
+
const wsBase = streamOpts?.baseURL ?? audioStreamingBaseURL;
|
|
1438
|
+
const params = new URLSearchParams();
|
|
1439
|
+
params.set("Authorization", opts.apiKey);
|
|
1440
|
+
if (streamOpts?.language)
|
|
1441
|
+
params.set("language", streamOpts.language);
|
|
1442
|
+
if (streamOpts?.prompt)
|
|
1443
|
+
params.set("prompt", streamOpts.prompt);
|
|
1444
|
+
if (streamOpts?.temperature !== undefined)
|
|
1445
|
+
params.set("temperature", String(streamOpts.temperature));
|
|
1446
|
+
if (streamOpts?.response_format)
|
|
1447
|
+
params.set("response_format", streamOpts.response_format);
|
|
1448
|
+
if (streamOpts?.timestamp_granularities)
|
|
1449
|
+
params.set("timestamp_granularities", streamOpts.timestamp_granularities.join(","));
|
|
1450
|
+
const qs = params.toString();
|
|
1451
|
+
const url = `${wsBase}/v1/audio/transcriptions/streaming?${qs}`;
|
|
1452
|
+
const ws = new WS(url);
|
|
1453
|
+
const queue = [];
|
|
1454
|
+
let resolve = null;
|
|
1455
|
+
let done = false;
|
|
1456
|
+
function enqueue(item) {
|
|
1457
|
+
if (resolve) {
|
|
1458
|
+
const r = resolve;
|
|
1459
|
+
resolve = null;
|
|
1460
|
+
if (item.type === "message") {
|
|
1461
|
+
r({ value: item.value, done: false });
|
|
1462
|
+
}
|
|
1463
|
+
else if (item.type === "error") {
|
|
1464
|
+
r({ value: undefined, done: true });
|
|
1465
|
+
}
|
|
1466
|
+
else {
|
|
1467
|
+
r({ value: undefined, done: true });
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
else {
|
|
1471
|
+
queue.push(item);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
ws.addEventListener("message", (event) => {
|
|
1475
|
+
try {
|
|
1476
|
+
const data = typeof event.data === "string"
|
|
1477
|
+
? event.data
|
|
1478
|
+
: String(event.data);
|
|
1479
|
+
const msg = JSON.parse(data);
|
|
1480
|
+
enqueue({ type: "message", value: msg });
|
|
1481
|
+
}
|
|
1482
|
+
catch {
|
|
1483
|
+
// ignore unparseable messages
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
ws.addEventListener("error", () => {
|
|
1487
|
+
done = true;
|
|
1488
|
+
enqueue({
|
|
1489
|
+
type: "error",
|
|
1490
|
+
error: new FireworksError("WebSocket connection error", 500),
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
ws.addEventListener("close", () => {
|
|
1494
|
+
done = true;
|
|
1495
|
+
enqueue({ type: "close" });
|
|
1496
|
+
});
|
|
1497
|
+
const session = {
|
|
1498
|
+
send(audio) {
|
|
1499
|
+
ws.send(audio);
|
|
1500
|
+
},
|
|
1501
|
+
clearState(resetId) {
|
|
1502
|
+
const id = resetId ?? crypto.randomUUID();
|
|
1503
|
+
ws.send(JSON.stringify({
|
|
1504
|
+
event_id: crypto.randomUUID(),
|
|
1505
|
+
object: "stt.state.clear",
|
|
1506
|
+
reset_id: id,
|
|
1507
|
+
}));
|
|
1508
|
+
},
|
|
1509
|
+
trace(traceId) {
|
|
1510
|
+
ws.send(JSON.stringify({
|
|
1511
|
+
event_id: crypto.randomUUID(),
|
|
1512
|
+
object: "stt.input.trace",
|
|
1513
|
+
trace_id: traceId,
|
|
1514
|
+
}));
|
|
1515
|
+
},
|
|
1516
|
+
close() {
|
|
1517
|
+
ws.send(JSON.stringify({
|
|
1518
|
+
checkpoint_id: "final",
|
|
1519
|
+
}));
|
|
1520
|
+
},
|
|
1521
|
+
[Symbol.asyncIterator]() {
|
|
1522
|
+
return {
|
|
1523
|
+
next() {
|
|
1524
|
+
const item = queue.shift();
|
|
1525
|
+
if (item) {
|
|
1526
|
+
if (item.type === "message") {
|
|
1527
|
+
return Promise.resolve({
|
|
1528
|
+
value: item.value,
|
|
1529
|
+
done: false,
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
return Promise.resolve({
|
|
1533
|
+
value: undefined,
|
|
1534
|
+
done: true,
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
if (done) {
|
|
1538
|
+
return Promise.resolve({
|
|
1539
|
+
value: undefined,
|
|
1540
|
+
done: true,
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
return new Promise((r) => {
|
|
1544
|
+
resolve = r;
|
|
1545
|
+
});
|
|
1546
|
+
},
|
|
1547
|
+
};
|
|
1548
|
+
},
|
|
1549
|
+
};
|
|
1550
|
+
return session;
|
|
1551
|
+
}, {
|
|
1552
|
+
schema: FireworksStreamingTranscriptionOptionsSchema,
|
|
1553
|
+
}),
|
|
1554
|
+
},
|
|
1555
|
+
},
|
|
1556
|
+
};
|
|
1557
|
+
return attachExamples({
|
|
1558
|
+
inference: {
|
|
1559
|
+
v1: {
|
|
1560
|
+
chat: {
|
|
1561
|
+
completions: postV1.chat.completions,
|
|
1562
|
+
},
|
|
1563
|
+
completions: postV1.completions,
|
|
1564
|
+
embeddings: postV1.embeddings,
|
|
1565
|
+
rerank: postV1.rerank,
|
|
1566
|
+
messages: postV1.messages,
|
|
1567
|
+
workflows: postV1.workflows,
|
|
1568
|
+
audio: {
|
|
1569
|
+
transcriptions: Object.assign(postV1.audio.transcriptions, {
|
|
1570
|
+
streaming: wsV1.audio.transcriptions.streaming,
|
|
1571
|
+
}),
|
|
1572
|
+
translations: postV1.audio.translations,
|
|
1573
|
+
batch: {
|
|
1574
|
+
transcriptions: postV1.audio.batch.transcriptions,
|
|
1575
|
+
translations: postV1.audio.batch.translations,
|
|
1576
|
+
get: getV1.audio.batch.get,
|
|
1577
|
+
},
|
|
1578
|
+
},
|
|
1579
|
+
accounts: {
|
|
1580
|
+
list: getV1.accounts.list,
|
|
1581
|
+
get: getV1.accounts.get,
|
|
1582
|
+
users: {
|
|
1583
|
+
list: getV1.accounts.users.list,
|
|
1584
|
+
create: postV1.accounts.users.create,
|
|
1585
|
+
get: getV1.accounts.users.get,
|
|
1586
|
+
update: Object.assign(patchV1.accounts.users.update, {
|
|
1587
|
+
post: patchV1.accounts.users.update,
|
|
1588
|
+
}),
|
|
1589
|
+
post: postV1.accounts.users.create,
|
|
1590
|
+
},
|
|
1591
|
+
apiKeys: {
|
|
1592
|
+
list: getV1.accounts.apiKeys.list,
|
|
1593
|
+
create: postV1.accounts.apiKeys.create,
|
|
1594
|
+
delete: deleteV1.accounts.apiKeys.delete,
|
|
1595
|
+
},
|
|
1596
|
+
secrets: {
|
|
1597
|
+
list: getV1.accounts.secrets.list,
|
|
1598
|
+
create: postV1.accounts.secrets.create,
|
|
1599
|
+
get: getV1.accounts.secrets.get,
|
|
1600
|
+
update: patchV1.accounts.secrets.update,
|
|
1601
|
+
delete: deleteV1.accounts.secrets.delete,
|
|
1602
|
+
},
|
|
1603
|
+
models: {
|
|
1604
|
+
list: getV1.accounts.models.list,
|
|
1605
|
+
create: postV1.accounts.models.create,
|
|
1606
|
+
get: getV1.accounts.models.get,
|
|
1607
|
+
update: Object.assign(patchV1.accounts.models.update, {
|
|
1608
|
+
post: patchV1.accounts.models.update,
|
|
1609
|
+
}),
|
|
1610
|
+
delete: deleteV1.accounts.models.delete,
|
|
1611
|
+
prepare: postV1.accounts.models.prepare,
|
|
1612
|
+
getUploadEndpoint: postV1.accounts.models.getUploadEndpoint,
|
|
1613
|
+
getDownloadEndpoint: getV1.accounts.models.getDownloadEndpoint,
|
|
1614
|
+
validateUpload: getV1.accounts.models.validateUpload,
|
|
1615
|
+
post: postV1.accounts.models.create,
|
|
1616
|
+
},
|
|
1617
|
+
datasets: {
|
|
1618
|
+
list: getV1.accounts.datasets.list,
|
|
1619
|
+
create: postV1.accounts.datasets.create,
|
|
1620
|
+
get: getV1.accounts.datasets.get,
|
|
1621
|
+
update: patchV1.accounts.datasets.update,
|
|
1622
|
+
delete: deleteV1.accounts.datasets.delete,
|
|
1623
|
+
getUploadEndpoint: postV1.accounts.datasets.getUploadEndpoint,
|
|
1624
|
+
getDownloadEndpoint: getV1.accounts.datasets.getDownloadEndpoint,
|
|
1625
|
+
validateUpload: postV1.accounts.datasets.validateUpload,
|
|
1626
|
+
},
|
|
1627
|
+
batchInferenceJobs: {
|
|
1628
|
+
create: postV1.accounts.batchInferenceJobs.create,
|
|
1629
|
+
get: getV1.accounts.batchInferenceJobs.get,
|
|
1630
|
+
list: getV1.accounts.batchInferenceJobs.list,
|
|
1631
|
+
delete: deleteV1.accounts.batchInferenceJobs.delete,
|
|
1632
|
+
},
|
|
1633
|
+
supervisedFineTuningJobs: {
|
|
1634
|
+
create: postV1.accounts.supervisedFineTuningJobs.create,
|
|
1635
|
+
list: getV1.accounts.supervisedFineTuningJobs.list,
|
|
1636
|
+
get: getV1.accounts.supervisedFineTuningJobs.get,
|
|
1637
|
+
delete: deleteV1.accounts.supervisedFineTuningJobs.delete,
|
|
1638
|
+
resume: postV1.accounts.supervisedFineTuningJobs.resume,
|
|
1639
|
+
},
|
|
1640
|
+
deployments: {
|
|
1641
|
+
list: getV1.accounts.deployments.list,
|
|
1642
|
+
create: Object.assign(postV1.accounts.deployments.create, {
|
|
1643
|
+
post: postV1.accounts.deployments.create,
|
|
1644
|
+
}),
|
|
1645
|
+
get: getV1.accounts.deployments.get,
|
|
1646
|
+
update: Object.assign(patchV1.accounts.deployments.update, {
|
|
1647
|
+
post: patchV1.accounts.deployments.update,
|
|
1648
|
+
}),
|
|
1649
|
+
delete: deleteV1.accounts.deployments.delete,
|
|
1650
|
+
scale: patchV1.accounts.deployments.scale,
|
|
1651
|
+
undelete: postV1.accounts.deployments.undelete,
|
|
1652
|
+
post: postV1.accounts.deployments.create,
|
|
1653
|
+
},
|
|
1654
|
+
deployedModels: {
|
|
1655
|
+
list: getV1.accounts.deployedModels.list,
|
|
1656
|
+
create: postV1.accounts.deployedModels.create,
|
|
1657
|
+
get: getV1.accounts.deployedModels.get,
|
|
1658
|
+
update: patchV1.accounts.deployedModels.update,
|
|
1659
|
+
delete: deleteV1.accounts.deployedModels.delete,
|
|
1660
|
+
},
|
|
1661
|
+
deploymentShapes: {
|
|
1662
|
+
get: getV1.accounts.deploymentShapes.get,
|
|
1663
|
+
versions: {
|
|
1664
|
+
list: getV1.accounts.deploymentShapes.versions.list,
|
|
1665
|
+
get: getV1.accounts.deploymentShapes.versions.get,
|
|
1666
|
+
},
|
|
1667
|
+
},
|
|
1668
|
+
dpoJobs: {
|
|
1669
|
+
create: postV1.accounts.dpoJobs.create,
|
|
1670
|
+
get: getV1.accounts.dpoJobs.get,
|
|
1671
|
+
list: getV1.accounts.dpoJobs.list,
|
|
1672
|
+
delete: deleteV1.accounts.dpoJobs.delete,
|
|
1673
|
+
resume: postV1.accounts.dpoJobs.resume,
|
|
1674
|
+
getMetricsFileEndpoint: getV1.accounts.dpoJobs.getMetricsFileEndpoint,
|
|
1675
|
+
},
|
|
1676
|
+
evaluators: {
|
|
1677
|
+
create: postV1.accounts.evaluators.create,
|
|
1678
|
+
list: getV1.accounts.evaluators.list,
|
|
1679
|
+
get: getV1.accounts.evaluators.get,
|
|
1680
|
+
update: patchV1.accounts.evaluators.update,
|
|
1681
|
+
delete: deleteV1.accounts.evaluators.delete,
|
|
1682
|
+
getUploadEndpoint: postV1.accounts.evaluators.getUploadEndpoint,
|
|
1683
|
+
validateUpload: postV1.accounts.evaluators.validateUpload,
|
|
1684
|
+
getBuildLogEndpoint: getV1.accounts.evaluators.getBuildLogEndpoint,
|
|
1685
|
+
getSourceCodeSignedUrl: getV1.accounts.evaluators.getSourceCodeSignedUrl,
|
|
1686
|
+
},
|
|
1687
|
+
evaluationJobs: {
|
|
1688
|
+
create: postV1.accounts.evaluationJobs.create,
|
|
1689
|
+
list: getV1.accounts.evaluationJobs.list,
|
|
1690
|
+
get: getV1.accounts.evaluationJobs.get,
|
|
1691
|
+
delete: deleteV1.accounts.evaluationJobs.delete,
|
|
1692
|
+
getExecutionLogEndpoint: getV1.accounts.evaluationJobs.getExecutionLogEndpoint,
|
|
1693
|
+
},
|
|
1694
|
+
reinforcementFineTuningJobs: {
|
|
1695
|
+
create: postV1.accounts.reinforcementFineTuningJobs.create,
|
|
1696
|
+
list: getV1.accounts.reinforcementFineTuningJobs.list,
|
|
1697
|
+
get: getV1.accounts.reinforcementFineTuningJobs.get,
|
|
1698
|
+
delete: deleteV1.accounts.reinforcementFineTuningJobs.delete,
|
|
1699
|
+
resume: postV1.accounts.reinforcementFineTuningJobs.resume,
|
|
1700
|
+
},
|
|
1701
|
+
rlorTrainerJobs: {
|
|
1702
|
+
create: postV1.accounts.rlorTrainerJobs.create,
|
|
1703
|
+
list: getV1.accounts.rlorTrainerJobs.list,
|
|
1704
|
+
get: getV1.accounts.rlorTrainerJobs.get,
|
|
1705
|
+
delete: deleteV1.accounts.rlorTrainerJobs.delete,
|
|
1706
|
+
executeTrainStep: postV1.accounts.rlorTrainerJobs.executeTrainStep,
|
|
1707
|
+
resume: postV1.accounts.rlorTrainerJobs.resume,
|
|
1708
|
+
},
|
|
1709
|
+
},
|
|
1710
|
+
},
|
|
1711
|
+
},
|
|
1712
|
+
post: {
|
|
1713
|
+
inference: { v1: postV1 },
|
|
1714
|
+
stream: {
|
|
1715
|
+
inference: { v1: postStreamV1 },
|
|
1716
|
+
},
|
|
1717
|
+
},
|
|
1718
|
+
get: {
|
|
1719
|
+
inference: { v1: getV1 },
|
|
1720
|
+
},
|
|
1721
|
+
patch: {
|
|
1722
|
+
inference: { v1: patchV1 },
|
|
1723
|
+
},
|
|
1724
|
+
delete: {
|
|
1725
|
+
inference: { v1: deleteV1 },
|
|
1726
|
+
},
|
|
1727
|
+
ws: {
|
|
1728
|
+
inference: { v1: wsV1 },
|
|
1729
|
+
},
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
//# sourceMappingURL=fireworks.js.map
|