@@ -17,25 +17,25 @@ The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https
17
17
### NPM
18
18
19
19
``` bash
20
- npm add openapi
20
+ npm add @livepeer/ai
21
21
```
22
22
23
23
### PNPM
24
24
25
25
``` bash
26
- pnpm add openapi
26
+ pnpm add @livepeer/ai
27
27
```
28
28
29
29
### Bun
30
30
31
31
``` bash
32
- bun add openapi
32
+ bun add @livepeer/ai
33
33
```
34
34
35
35
### Yarn
36
36
37
37
``` bash
38
- yarn add openapi zod
38
+ yarn add @livepeer/ai zod
39
39
40
40
# Note that Yarn does not install peer dependencies automatically. You will need
41
41
# to install zod as shown above.
@@ -54,14 +54,14 @@ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
54
54
### Example
55
55
56
56
``` typescript
57
- import { SDK } from " openapi " ;
57
+ import { Livepeer } from " @livepeer/ai " ;
58
58
59
- const sdk = new SDK ({
59
+ const livepeer = new Livepeer ({
60
60
httpBearer: " <YOUR_BEARER_TOKEN_HERE>" ,
61
61
});
62
62
63
63
async function run() {
64
- const result = await sdk .generate .textToImage ({
64
+ const result = await livepeer .generate .textToImage ({
65
65
prompt: " <value>" ,
66
66
});
67
67
@@ -134,15 +134,15 @@ Certain SDK methods accept files as part of a multi-part request. It is possible
134
134
> - ** Node.js v18:** A file stream can be created using the ` fileFrom ` helper from [ ` fetch-blob/from.js ` ] ( https://www.npmjs.com/package/fetch-blob ) .
135
135
136
136
``` typescript
137
+ import { Livepeer } from " @livepeer/ai" ;
137
138
import { openAsBlob } from " node:fs" ;
138
- import { SDK } from " openapi" ;
139
139
140
- const sdk = new SDK ({
140
+ const livepeer = new Livepeer ({
141
141
httpBearer: " <YOUR_BEARER_TOKEN_HERE>" ,
142
142
});
143
143
144
144
async function run() {
145
- const result = await sdk .generate .imageToImage ({
145
+ const result = await livepeer .generate .imageToImage ({
146
146
image: await openAsBlob (" example.file" ),
147
147
prompt: " <value>" ,
148
148
});
@@ -163,14 +163,14 @@ Some of the endpoints in this SDK support retries. If you use the SDK without a
163
163
164
164
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
165
165
``` typescript
166
- import { SDK } from " openapi " ;
166
+ import { Livepeer } from " @livepeer/ai " ;
167
167
168
- const sdk = new SDK ({
168
+ const livepeer = new Livepeer ({
169
169
httpBearer: " <YOUR_BEARER_TOKEN_HERE>" ,
170
170
});
171
171
172
172
async function run() {
173
- const result = await sdk .generate .textToImage ({
173
+ const result = await livepeer .generate .textToImage ({
174
174
prompt: " <value>" ,
175
175
}, {
176
176
retries: {
@@ -195,9 +195,9 @@ run();
195
195
196
196
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
197
197
``` typescript
198
- import { SDK } from " openapi " ;
198
+ import { Livepeer } from " @livepeer/ai " ;
199
199
200
- const sdk = new SDK ({
200
+ const livepeer = new Livepeer ({
201
201
retryConfig: {
202
202
strategy: " backoff" ,
203
203
backoff: {
@@ -212,7 +212,7 @@ const sdk = new SDK({
212
212
});
213
213
214
214
async function run() {
215
- const result = await sdk .generate .textToImage ({
215
+ const result = await livepeer .generate .textToImage ({
216
216
prompt: " <value>" ,
217
217
});
218
218
@@ -240,21 +240,21 @@ Validation errors can also occur when either method arguments or data returned f
240
240
241
241
242
242
``` typescript
243
- import { SDK } from " openapi " ;
243
+ import { Livepeer } from " @livepeer/ai " ;
244
244
import {
245
245
HTTPError ,
246
246
HTTPValidationError ,
247
247
SDKValidationError ,
248
- } from " openapi /models/errors" ;
248
+ } from " @livepeer/ai /models/errors" ;
249
249
250
- const sdk = new SDK ({
250
+ const livepeer = new Livepeer ({
251
251
httpBearer: " <YOUR_BEARER_TOKEN_HERE>" ,
252
252
});
253
253
254
254
async function run() {
255
255
let result;
256
256
try {
257
- result = await sdk .generate .textToImage ({
257
+ result = await livepeer .generate .textToImage ({
258
258
prompt: " <value>" ,
259
259
});
260
260
@@ -304,15 +304,15 @@ You can override the default server globally by passing a server index to the `s
304
304
| 1 | ` https://livepeer.studio/api/beta/generate ` | None |
305
305
306
306
``` typescript
307
- import { SDK } from " openapi " ;
307
+ import { Livepeer } from " @livepeer/ai " ;
308
308
309
- const sdk = new SDK ({
309
+ const livepeer = new Livepeer ({
310
310
serverIdx: 1 ,
311
311
httpBearer: " <YOUR_BEARER_TOKEN_HERE>" ,
312
312
});
313
313
314
314
async function run() {
315
- const result = await sdk .generate .textToImage ({
315
+ const result = await livepeer .generate .textToImage ({
316
316
prompt: " <value>" ,
317
317
});
318
318
@@ -330,15 +330,15 @@ run();
330
330
The default server can also be overridden globally by passing a URL to the ` serverURL ` optional parameter when initializing the SDK client instance. For example:
331
331
332
332
``` typescript
333
- import { SDK } from " openapi " ;
333
+ import { Livepeer } from " @livepeer/ai " ;
334
334
335
- const sdk = new SDK ({
335
+ const livepeer = new Livepeer ({
336
336
serverURL: " https://dream-gateway.livepeer.cloud" ,
337
337
httpBearer: " <YOUR_BEARER_TOKEN_HERE>" ,
338
338
});
339
339
340
340
async function run() {
341
- const result = await sdk .generate .textToImage ({
341
+ const result = await livepeer .generate .textToImage ({
342
342
prompt: " <value>" ,
343
343
});
344
344
@@ -369,8 +369,8 @@ custom header and a timeout to requests and how to use the `"requestError"` hook
369
369
to log errors:
370
370
371
371
``` typescript
372
- import { SDK } from " openapi " ;
373
- import { HTTPClient } from " openapi /lib/http" ;
372
+ import { Livepeer } from " @livepeer/ai " ;
373
+ import { HTTPClient } from " @livepeer/ai /lib/http" ;
374
374
375
375
const httpClient = new HTTPClient ({
376
376
// fetcher takes a function that has the same signature as native `fetch`.
@@ -396,7 +396,7 @@ httpClient.addHook("requestError", (error, request) => {
396
396
console .groupEnd ();
397
397
});
398
398
399
- const sdk = new SDK ({ httpClient });
399
+ const sdk = new Livepeer ({ httpClient });
400
400
```
401
401
<!-- End Custom HTTP Client [http-client] -->
402
402
@@ -413,14 +413,14 @@ This SDK supports the following security scheme globally:
413
413
414
414
To authenticate with the API the ` httpBearer ` parameter must be set when initializing the SDK client instance. For example:
415
415
``` typescript
416
- import { SDK } from " openapi " ;
416
+ import { Livepeer } from " @livepeer/ai " ;
417
417
418
- const sdk = new SDK ({
418
+ const livepeer = new Livepeer ({
419
419
httpBearer: " <YOUR_BEARER_TOKEN_HERE>" ,
420
420
});
421
421
422
422
async function run() {
423
- const result = await sdk .generate .textToImage ({
423
+ const result = await livepeer .generate .textToImage ({
424
424
prompt: " <value>" ,
425
425
});
426
426
@@ -444,9 +444,9 @@ You can pass a logger that matches `console`'s interface as an SDK option.
444
444
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
445
445
446
446
``` typescript
447
- import { SDK } from " openapi " ;
447
+ import { Livepeer } from " @livepeer/ai " ;
448
448
449
- const sdk = new SDK ({ debugLogger: console });
449
+ const sdk = new Livepeer ({ debugLogger: console });
450
450
```
451
451
<!-- End Debugging [debug] -->
452
452
0 commit comments