@byte_fluffy/nexra-sdk 0.1.0-alpha.26 → 0.1.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -0
- package/dist/catalog.d.ts +11 -3
- package/dist/catalog.js +4 -2
- package/dist/{chunk-73CGYVFV.js → chunk-ECF5MLSM.js} +551 -171
- package/dist/{chunk-KEAAHI25.js → chunk-IEBCNRT4.js} +4 -0
- package/dist/index.d.ts +20 -6
- package/dist/index.js +50 -55
- package/dist/{media-geometry-CRCAkREf.d.ts → media-geometry-BoxkWQlj.d.ts} +30 -1
- package/dist/media.js +1 -1
- package/dist/{types-CmZz1KmL.d.ts → types-BYmoc0n8.d.ts} +38 -2
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,108 @@ available from `@byte_fluffy/nexra-sdk/media`.
|
|
|
37
37
|
The default API base URL is `https://api.nexra-ai.com/v1`. When overriding
|
|
38
38
|
`baseUrl`, include the `/v1` API prefix.
|
|
39
39
|
|
|
40
|
+
## Model display names
|
|
41
|
+
|
|
42
|
+
`getModelSpec`, `listModelSpecs`, `nexra.models.search`, `nexra.models.get`, and
|
|
43
|
+
`nexra.catalog.model` return display names with spaces between words and
|
|
44
|
+
capitalized initials, such as
|
|
45
|
+
`Grok Imagine Image`, `GPT 5.4`, and `Wan 2.7 Image Pro`. Brand spelling, acronyms,
|
|
46
|
+
and decimal versions are preserved. Model detail family versions follow the same
|
|
47
|
+
format.
|
|
48
|
+
|
|
49
|
+
Use `formatModelDisplayName(name)` to apply this format to other display labels.
|
|
50
|
+
It is available from the package root and `/catalog`. Formatting affects only
|
|
51
|
+
`displayName`: use the static catalog's `id`, model discovery's `slug`, or the
|
|
52
|
+
live catalog's `modelId` for requests, never the formatted display name.
|
|
53
|
+
|
|
54
|
+
## Live model catalog
|
|
55
|
+
|
|
56
|
+
`getModelSpec` and `listModelSpecs` read the catalog bundled with this SDK release.
|
|
57
|
+
Use `catalog.model(publicId, operation)` to read the currently published database
|
|
58
|
+
input schema, display name, sale prices and actual model revision. A successful
|
|
59
|
+
`available: false` response authoritatively confirms an unavailable or retired
|
|
60
|
+
public identity; HTTP failures throw and must preserve the last successful value.
|
|
61
|
+
An unknown identity returns 404. Model IDs are URL-encoded by the SDK.
|
|
62
|
+
|
|
63
|
+
`catalog.changes` lists lightweight public model/operation identities and their
|
|
64
|
+
latest revisions. Start with `after: "0"` for initial alignment. Keep the first
|
|
65
|
+
page's `revision` as `upper` for every remaining page and pass its opaque
|
|
66
|
+
`nextCursor`. The cursor is bound to that `after`/`upper` window. Revisions are
|
|
67
|
+
64-bit decimal strings; compare them with `BigInt`, not JavaScript numbers.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
let after = "0";
|
|
71
|
+
let cursor: string | undefined;
|
|
72
|
+
let upper: string | undefined;
|
|
73
|
+
do {
|
|
74
|
+
const page = await nexra.catalog.changes({ after, upper, cursor });
|
|
75
|
+
upper ??= page.revision;
|
|
76
|
+
// Record changed identities for independent background model reads.
|
|
77
|
+
enqueueChanges(page.data);
|
|
78
|
+
cursor = page.nextCursor;
|
|
79
|
+
} while (cursor);
|
|
80
|
+
after = upper!;
|
|
81
|
+
|
|
82
|
+
for await (const event of nexra.catalog.events({ after, signal })) {
|
|
83
|
+
enqueueChanges(event.data);
|
|
84
|
+
after = event.revision;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`enqueueChanges` is application code that records the affected identities before
|
|
89
|
+
advancing the receiving cursor; it does not block on all model reads. Each model
|
|
90
|
+
response carries its own actual revision. Do not label an older response with the
|
|
91
|
+
requested target revision or let it overwrite newer state. An identity updated
|
|
92
|
+
beyond a page window's fixed upper bound appears in the next window, including
|
|
93
|
+
when its index row was replaced during pagination.
|
|
94
|
+
|
|
95
|
+
`catalog.events` opens one authenticated SSE stream, ignores heartbeats, and
|
|
96
|
+
emits complete `catalog.quote-context.changed` windows with `{ revision,
|
|
97
|
+
changedAt, data }`. Notifications wake the API instance immediately; a per-instance
|
|
98
|
+
60-second revision check recovers silent notification loss. When a stream ends or
|
|
99
|
+
throws, the application reconnects using its retained `after` cursor; the SDK
|
|
100
|
+
does not reconnect automatically. Abort the supplied signal to stop an active
|
|
101
|
+
read. Leaving the iterator cancels and releases the response stream. Keep cached
|
|
102
|
+
values and cursors separate for different API sources and authorization identities.
|
|
103
|
+
No credentials, channel costs or user discounts are included in the public events.
|
|
104
|
+
|
|
105
|
+
## Private ElevenLabs voices
|
|
106
|
+
|
|
107
|
+
Voice design uses `elevenlabs/eleven_multilingual_ttv_v2`, with exactly one prompt
|
|
108
|
+
and one script content part. Preview IDs remain in `task.output.previews`; the
|
|
109
|
+
corresponding audio is returned in the ordered persisted `task.assets` list.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const design = await nexra.run("elevenlabs/eleven_multilingual_ttv_v2", {
|
|
113
|
+
content: [
|
|
114
|
+
{ type: "text", role: "prompt", text: "A warm, clear and natural narrator voice." },
|
|
115
|
+
{ type: "text", role: "script", text: previewScript },
|
|
116
|
+
],
|
|
117
|
+
}, { idempotencyKey: designKey });
|
|
118
|
+
const creation = await nexra.voices.create({
|
|
119
|
+
name: "Narrator",
|
|
120
|
+
source: { kind: "design", taskId: design.task.id, previewId: selectedPreviewId },
|
|
121
|
+
}, { idempotencyKey: saveKey });
|
|
122
|
+
await nexra.tasks.wait(creation.taskId);
|
|
123
|
+
const voice = await nexra.voices.get(creation.voice.id);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Cloning is a voice-resource operation, not a separate vendor model. Upload owned
|
|
127
|
+
audio through `nexra.assets.upload`, then call `nexra.voices.create` with
|
|
128
|
+
`source: { kind: "clone", samples: [sample.id] }`. The service accepts one to five
|
|
129
|
+
stored audio samples totaling at most 25 MiB. Retain the sample IDs and the same
|
|
130
|
+
idempotency key when retrying a creation.
|
|
131
|
+
|
|
132
|
+
`nexra.voices.list` and `get` read current authenticated resource state. Only an
|
|
133
|
+
active voice can be used for `elevenlabs/eleven_multilingual_v2` speech, using its
|
|
134
|
+
public `voice_` ID. Creation and synthesis settle separately; creation does not
|
|
135
|
+
imply verification or support for renewal, deletion, or voice conversion.
|
|
136
|
+
|
|
137
|
+
Applications using a shared API key must enforce their own end-user ownership
|
|
138
|
+
before reading or consuming a resource; API-key ownership covers the Nexra
|
|
139
|
+
account, not an application's individual users. Published model choices are
|
|
140
|
+
available through `nexra.models.resources(modelId, resource)`.
|
|
141
|
+
|
|
40
142
|
Static catalog APIs are also available from `@byte_fluffy/nexra-sdk/catalog`.
|
|
41
143
|
Exact non-negative decimal helpers are available from
|
|
42
144
|
`@byte_fluffy/nexra-sdk/decimal`.
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { H as HttpTransport, N as NexraSalePriceList, C as CreateNexraQuoteRequest,
|
|
2
|
-
export { M as MediaGeometryField,
|
|
1
|
+
import { H as HttpTransport, N as NexraCatalogChangeParams, a as NexraCatalogChangePage, b as NexraCatalogModelState, c as NexraSalePriceList, C as CreateNexraQuoteRequest, d as NexraQuote, e as CreateNexraDisplayQuoteBatchRequest, f as NexraDisplayQuoteBatch, g as NexraCatalogRevision, h as NexraModelSpec, i as NexraModelSpecFilter } from './media-geometry-BoxkWQlj.js';
|
|
2
|
+
export { M as MediaGeometryField, j as MediaGeometryProjection, k as NexraBillingCurrency, l as NexraCatalogModelIdentity, m as NexraModelEndpointSpec, n as NexraModelOperation, o as NexraSalePrice, p as NexraSettlement, U as UnifiedMediaGeometry, q as applyMediaGeometry, r as decodeMediaGeometry, s as encodeMediaGeometry, t as projectMediaGeometry } from './media-geometry-BoxkWQlj.js';
|
|
3
3
|
import './json-Drjj1OKl.js';
|
|
4
4
|
|
|
5
|
+
declare function formatModelDisplayName(displayName: string): string;
|
|
6
|
+
|
|
5
7
|
declare class CatalogClient {
|
|
6
8
|
private readonly transport;
|
|
7
9
|
constructor(transport: HttpTransport);
|
|
10
|
+
changes(params?: NexraCatalogChangeParams, signal?: AbortSignal): Promise<NexraCatalogChangePage>;
|
|
11
|
+
model(modelId: string, operation: string, signal?: AbortSignal): Promise<NexraCatalogModelState>;
|
|
12
|
+
events(options?: {
|
|
13
|
+
after?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}): AsyncGenerator<NexraCatalogChangePage>;
|
|
8
16
|
listPrices(signal?: AbortSignal): Promise<NexraSalePriceList>;
|
|
9
17
|
quote(request: CreateNexraQuoteRequest, signal?: AbortSignal): Promise<NexraQuote>;
|
|
10
18
|
quoteBatch(request: CreateNexraDisplayQuoteBatchRequest, signal?: AbortSignal): Promise<NexraDisplayQuoteBatch>;
|
|
@@ -13,4 +21,4 @@ declare class CatalogClient {
|
|
|
13
21
|
declare function getModelSpec(modelId: string): NexraModelSpec | undefined;
|
|
14
22
|
declare function listModelSpecs(filter?: NexraModelSpecFilter): readonly NexraModelSpec[];
|
|
15
23
|
|
|
16
|
-
export { CatalogClient, CreateNexraDisplayQuoteBatchRequest, CreateNexraQuoteRequest, NexraCatalogRevision, NexraDisplayQuoteBatch, NexraModelSpec, NexraModelSpecFilter, NexraQuote, NexraSalePriceList, getModelSpec, listModelSpecs };
|
|
24
|
+
export { CatalogClient, CreateNexraDisplayQuoteBatchRequest, CreateNexraQuoteRequest, NexraCatalogChangePage, NexraCatalogChangeParams, NexraCatalogModelState, NexraCatalogRevision, NexraDisplayQuoteBatch, NexraModelSpec, NexraModelSpecFilter, NexraQuote, NexraSalePriceList, formatModelDisplayName, getModelSpec, listModelSpecs };
|
package/dist/catalog.js
CHANGED
|
@@ -3,16 +3,18 @@ import {
|
|
|
3
3
|
applyMediaGeometry,
|
|
4
4
|
decodeMediaGeometry,
|
|
5
5
|
encodeMediaGeometry,
|
|
6
|
+
formatModelDisplayName,
|
|
6
7
|
getModelSpec,
|
|
7
8
|
listModelSpecs,
|
|
8
9
|
projectMediaGeometry
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-ECF5MLSM.js";
|
|
11
|
+
import "./chunk-IEBCNRT4.js";
|
|
11
12
|
export {
|
|
12
13
|
CatalogClient,
|
|
13
14
|
applyMediaGeometry,
|
|
14
15
|
decodeMediaGeometry,
|
|
15
16
|
encodeMediaGeometry,
|
|
17
|
+
formatModelDisplayName,
|
|
16
18
|
getModelSpec,
|
|
17
19
|
listModelSpecs,
|
|
18
20
|
projectMediaGeometry
|