@byte_fluffy/nexra-sdk 0.1.0-alpha.3 → 0.1.0-alpha.5

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 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
- size: "1024x1024",
22
+ resolution: "1K",
23
+ ratio: "1:1",
20
24
  quality: "medium",
21
25
  };
22
26
  const quote = await nexra.catalog.quote({
@@ -27,9 +31,39 @@ 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
+ ## Directory layout
44
+
45
+ ```
46
+ src/
47
+ index.ts Public entry; re-exports the catalog, client, etc.
48
+ catalog/
49
+ index.ts CatalogClient, getModelSpec, listModelSpecs
50
+ generated/ Generated artifacts (committed; required to publish)
51
+ image.generated.json One file per model kind (image, video, audio, ...)
52
+ index.ts Imports every kind JSON and exports the merged array
53
+ generated/
54
+ version.generated.ts SDK_VERSION used by the transport
55
+ ... client, tasks, assets, input, sse, webhooks, errors, ...
56
+ scripts/
57
+ generate-public-catalog.ts Projects models from @nexra/models and writes
58
+ src/catalog/generated/*
59
+ ```
60
+
61
+ ### Adding a new public model
62
+
63
+ 1. Add its ID to `PUBLIC_MODEL_IDS` in `scripts/generate-public-catalog.ts`.
64
+ 2. Run `bun run generate` (from `packages/sdk`).
65
+ 3. The script groups projected models by `model.kind`, writes one
66
+ `src/catalog/generated/<kind>.generated.json` per kind (new kinds appear
67
+ automatically), regenerates the merging `index.ts`, and bumps
68
+ `src/generated/version.generated.ts`. No hand-written code changes.
69
+
package/dist/catalog.d.ts CHANGED
@@ -1 +1 @@
1
- export { d as CatalogClient, h as CreateNexraQuoteRequest, u as NexraBillingCurrency, v as NexraModelOperation, w as NexraModelSpec, x as NexraModelSpecFilter, y as NexraQuote, z as NexraSalePrice, N as NexraSettlement, R as getModelSpec, V as listModelSpecs } from './catalog-mytCeh5t.js';
1
+ export { d as CatalogClient, h as CreateNexraQuoteRequest, j as MediaGeometryField, k as MediaGeometryProjection, w as NexraBillingCurrency, x as NexraModelOperation, y as NexraModelSpec, z as NexraModelSpecFilter, A as NexraQuote, D as NexraSalePrice, N as NexraSettlement, U as UnifiedMediaGeometry, S as applyMediaGeometry, W as decodeMediaGeometry, X as encodeMediaGeometry, Z as getModelSpec, $ as listModelSpecs, a0 as projectMediaGeometry } from './index-FyUOK0F-.js';
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
- } from "./chunk-IMJZBLDE.js";
7
+ listModelSpecs,
8
+ projectMediaGeometry
9
+ } from "./chunk-2C2ZZKUC.js";
6
10
  export {
7
11
  CatalogClient,
12
+ applyMediaGeometry,
13
+ decodeMediaGeometry,
14
+ encodeMediaGeometry,
8
15
  getModelSpec,
9
- listModelSpecs
16
+ listModelSpecs,
17
+ projectMediaGeometry
10
18
  };