@byte_fluffy/nexra-sdk 0.1.0-alpha.1 → 0.1.0-alpha.10

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 Image model specs
52
+ language.generated.json Text/language model specs
53
+ index.ts Imports every kind JSON and exports the merged array
54
+ generated/
55
+ version.generated.ts SDK_VERSION used by the transport
56
+ ... client, tasks, assets, input, sse, webhooks, errors, ...
57
+ scripts/
58
+ generate-public-catalog.ts Projects models from @nexra/models and writes
59
+ src/catalog/generated/*
60
+ ```
61
+
62
+ ### Adding a new public model
63
+
64
+ 1. Add its ID to `PUBLIC_MODEL_IDS` in `scripts/generate-public-catalog.ts`.
65
+ 2. Run `bun run generate` (from `packages/sdk`).
66
+ 3. The script groups projected models by `model.kind`, writes one
67
+ `src/catalog/generated/<kind>.generated.json` per kind (new kinds appear
68
+ automatically), regenerates the merging `index.ts`, and bumps
69
+ `src/generated/version.generated.ts`. No hand-written code changes.
package/dist/catalog.d.ts CHANGED
@@ -1 +1,15 @@
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
+ 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
- } from "./chunk-ADKRTC6X.js";
7
+ listModelSpecs,
8
+ projectMediaGeometry
9
+ } from "./chunk-ULMZMJUL.js";
6
10
  export {
7
11
  CatalogClient,
12
+ applyMediaGeometry,
13
+ decodeMediaGeometry,
14
+ encodeMediaGeometry,
8
15
  getModelSpec,
9
- listModelSpecs
16
+ listModelSpecs,
17
+ projectMediaGeometry
10
18
  };