@byte_fluffy/nexra-sdk 0.1.0-alpha.2 → 0.1.0-alpha.20
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 +53 -3
- package/dist/catalog.d.ts +15 -1
- package/dist/catalog.js +11 -3
- package/dist/chunk-PAVF5LNU.js +41227 -0
- package/dist/index.d.ts +7 -962
- package/dist/index.js +65 -979
- package/dist/{catalog-mytCeh5t.d.ts → media-geometry-Ckr1-Mh3.d.ts} +83 -78
- package/dist/types-CvKdgo7V.d.ts +343 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +0 -0
- package/package.json +12 -2
- package/dist/chunk-WE6JHADB.js +0 -1512
package/README.md
CHANGED
|
@@ -9,14 +9,18 @@ npm install @byte_fluffy/nexra-sdk@next
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import { createNexra, getModelSpec } from "@byte_fluffy/nexra-sdk";
|
|
12
|
+
import { createNexra, getModelSpec, projectMediaGeometry } from "@byte_fluffy/nexra-sdk";
|
|
13
13
|
|
|
14
14
|
const nexra = createNexra({ apiKey: process.env.NEXRA_API_KEY });
|
|
15
|
-
const spec = getModelSpec("gpt-image-2");
|
|
15
|
+
const spec = getModelSpec("openai/gpt-image-2");
|
|
16
|
+
const geometry = projectMediaGeometry(spec!.operations[0]!.inputSchema);
|
|
17
|
+
// geometry.resolution.options → ["1K","2K","4K"]; geometry.ratio.options → ["1:1", ...]
|
|
18
|
+
|
|
16
19
|
const input = {
|
|
17
20
|
model: spec!.id,
|
|
18
21
|
prompt: "A paper boat on a blue table",
|
|
19
|
-
|
|
22
|
+
resolution: "1K",
|
|
23
|
+
ratio: "1:1",
|
|
20
24
|
quality: "medium",
|
|
21
25
|
};
|
|
22
26
|
const quote = await nexra.catalog.quote({
|
|
@@ -27,9 +31,55 @@ const quote = await nexra.catalog.quote({
|
|
|
27
31
|
const result = await nexra.run(spec!.id, { input, quoteToken: quote.quoteToken });
|
|
28
32
|
```
|
|
29
33
|
|
|
34
|
+
Apps should send the unified geometry (`resolution` + `ratio` + `quality`). Quote and `run`/`create` map those fields onto the model's native catalog parameters (GPT Image `size: 1024x1024`, Seedream `size: 2K`, Grok `resolution: 1k` + `aspect_ratio`, …). `encodeMediaGeometry` / `decodeMediaGeometry` expose the same mapping without making a request. Native `size` already in the body is left unchanged.
|
|
35
|
+
|
|
30
36
|
The default API base URL is `https://api.nexra-ai.com/v1`. When overriding
|
|
31
37
|
`baseUrl`, include the `/v1` API prefix.
|
|
32
38
|
|
|
33
39
|
Static catalog APIs are also available from `@byte_fluffy/nexra-sdk/catalog`.
|
|
34
40
|
Exact non-negative decimal helpers are available from
|
|
35
41
|
`@byte_fluffy/nexra-sdk/decimal`.
|
|
42
|
+
|
|
43
|
+
The static catalog includes the 13 verified Agnes and CTYun image/video model
|
|
44
|
+
contracts. A catalog entry describes parameters; it does not grant access to a
|
|
45
|
+
private model or publish a sale price. Check the selected environment's model
|
|
46
|
+
listing and current prices before submitting a task.
|
|
47
|
+
|
|
48
|
+
GPT-6 Sol and GPT-6 Luna are included in the language model catalog. Sale prices
|
|
49
|
+
are not bundled into the SDK; use the current prices published by the selected
|
|
50
|
+
Nexra environment:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const { prices } = await nexra.catalog.listPrices();
|
|
54
|
+
const gpt6Prices = prices.filter(({ modelId }) =>
|
|
55
|
+
modelId === "openai/gpt-6-sol" || modelId === "openai/gpt-6-luna"
|
|
56
|
+
);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Directory layout
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
src/
|
|
63
|
+
index.ts Public entry; re-exports the catalog, client, etc.
|
|
64
|
+
catalog/
|
|
65
|
+
index.ts CatalogClient, getModelSpec, listModelSpecs
|
|
66
|
+
generated/ Generated artifacts (committed; required to publish)
|
|
67
|
+
image.generated.json Image model specs
|
|
68
|
+
language.generated.json Text/language model specs
|
|
69
|
+
index.ts Imports every kind JSON and exports the merged array
|
|
70
|
+
generated/
|
|
71
|
+
version.generated.ts SDK_VERSION used by the transport
|
|
72
|
+
... client, tasks, assets, input, sse, webhooks, errors, ...
|
|
73
|
+
scripts/
|
|
74
|
+
generate-public-catalog.ts Projects models from @nexra/models and writes
|
|
75
|
+
src/catalog/generated/*
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Adding a model spec
|
|
79
|
+
|
|
80
|
+
1. Add its ID to `SDK_MODEL_IDS` in `scripts/generate-public-catalog.ts`.
|
|
81
|
+
2. Run `bun run generate` (from `packages/sdk`).
|
|
82
|
+
3. The script groups projected models by `model.kind`, writes one
|
|
83
|
+
`src/catalog/generated/<kind>.generated.json` per kind (new kinds appear
|
|
84
|
+
automatically), regenerates the merging `index.ts`, and bumps
|
|
85
|
+
`src/generated/version.generated.ts`. No hand-written code changes.
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { H as HttpTransport, N as NexraSalePriceList, C as CreateNexraQuoteRequest, a as NexraQuote, b as CreateNexraDisplayQuoteBatchRequest, c as NexraDisplayQuoteBatch, d as NexraCatalogRevision, e as NexraModelSpec, f as NexraModelSpecFilter } from './media-geometry-Ckr1-Mh3.js';
|
|
2
|
+
export { M as MediaGeometryField, g as MediaGeometryProjection, h as NexraBillingCurrency, i as NexraModelEndpointSpec, j as NexraModelOperation, k as NexraSalePrice, l as NexraSettlement, U as UnifiedMediaGeometry, m as applyMediaGeometry, n as decodeMediaGeometry, o as encodeMediaGeometry, p as projectMediaGeometry } from './media-geometry-Ckr1-Mh3.js';
|
|
3
|
+
|
|
4
|
+
declare class CatalogClient {
|
|
5
|
+
private readonly transport;
|
|
6
|
+
constructor(transport: HttpTransport);
|
|
7
|
+
listPrices(signal?: AbortSignal): Promise<NexraSalePriceList>;
|
|
8
|
+
quote(request: CreateNexraQuoteRequest, signal?: AbortSignal): Promise<NexraQuote>;
|
|
9
|
+
quoteBatch(request: CreateNexraDisplayQuoteBatchRequest, signal?: AbortSignal): Promise<NexraDisplayQuoteBatch>;
|
|
10
|
+
revision(signal?: AbortSignal): Promise<NexraCatalogRevision>;
|
|
11
|
+
}
|
|
12
|
+
declare function getModelSpec(modelId: string): NexraModelSpec | undefined;
|
|
13
|
+
declare function listModelSpecs(filter?: NexraModelSpecFilter): readonly NexraModelSpec[];
|
|
14
|
+
|
|
15
|
+
export { CatalogClient, CreateNexraDisplayQuoteBatchRequest, CreateNexraQuoteRequest, NexraCatalogRevision, NexraDisplayQuoteBatch, NexraModelSpec, NexraModelSpecFilter, NexraQuote, NexraSalePriceList, getModelSpec, listModelSpecs };
|
package/dist/catalog.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CatalogClient,
|
|
3
|
+
applyMediaGeometry,
|
|
4
|
+
decodeMediaGeometry,
|
|
5
|
+
encodeMediaGeometry,
|
|
3
6
|
getModelSpec,
|
|
4
|
-
listModelSpecs
|
|
5
|
-
|
|
7
|
+
listModelSpecs,
|
|
8
|
+
projectMediaGeometry
|
|
9
|
+
} from "./chunk-PAVF5LNU.js";
|
|
6
10
|
export {
|
|
7
11
|
CatalogClient,
|
|
12
|
+
applyMediaGeometry,
|
|
13
|
+
decodeMediaGeometry,
|
|
14
|
+
encodeMediaGeometry,
|
|
8
15
|
getModelSpec,
|
|
9
|
-
listModelSpecs
|
|
16
|
+
listModelSpecs,
|
|
17
|
+
projectMediaGeometry
|
|
10
18
|
};
|