@byte_fluffy/nexra-sdk 0.1.0-alpha.43 → 0.1.0-alpha.45
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 +32 -0
- package/dist/catalog.d.ts +2 -2
- package/dist/catalog.js +2 -2
- package/dist/{chunk-ESPUF2D4.js → chunk-FEACXUHZ.js} +20 -2
- package/dist/{chunk-TV6MEAZC.js → chunk-OX5GFYVN.js} +175 -46
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/language.d.ts +1 -1
- package/dist/language.js +2 -2
- package/dist/media-CwGmG5qB.d.ts +299 -0
- package/dist/{media-geometry-YD9Y_CFw.d.ts → media-geometry-KwQh1O8Y.d.ts} +1 -1
- package/dist/media.d.ts +2 -222
- package/dist/media.js +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/{voices-BHzDQ5xH.d.ts → voices-B09HqQJJ.d.ts} +11 -7
- package/package.json +1 -1
- package/dist/assets-Cusrjj7_.d.ts +0 -61
package/README.md
CHANGED
|
@@ -65,6 +65,38 @@ The migrated task input also accepts the existing image fields
|
|
|
65
65
|
fields `video_url`/`vid`, `config`, and `target.res`. Use one input contract per
|
|
66
66
|
request. Credentials, VOD space, and playback signing belong to the server channel.
|
|
67
67
|
|
|
68
|
+
## Image layer decomposition
|
|
69
|
+
|
|
70
|
+
Seedream Pro accepts one source image in `output_mode: "layers"`. Resolution is
|
|
71
|
+
`1K`, `1.5K`, or `2K`; `prompt_optimization` selects `standard` or `fast`.
|
|
72
|
+
Layers retain the source aspect ratio and use PNG for transparency.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import type { NexraImageLayerDecompositionOutput } from "@byte_fluffy/nexra-sdk";
|
|
76
|
+
|
|
77
|
+
const result = await nexra.tasks.run<NexraImageLayerDecompositionOutput>(
|
|
78
|
+
"bytedance/doubao-seedream-5-0-pro-260628",
|
|
79
|
+
{
|
|
80
|
+
content: [{ type: "image", source: "https://example.com/poster.png", role: "source" }],
|
|
81
|
+
output_mode: "layers",
|
|
82
|
+
resolution: "2K",
|
|
83
|
+
prompt_optimization: "standard",
|
|
84
|
+
output_format: "png",
|
|
85
|
+
},
|
|
86
|
+
{ idempotencyKey: "poster-layers-1" },
|
|
87
|
+
);
|
|
88
|
+
for (const layer of result.output.layer_decomposition.layers) {
|
|
89
|
+
const url = result.output.images[layer.image_index];
|
|
90
|
+
console.log(layer.z_index, layer.name, layer.bounding_box, url);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`image_index` associates metadata with the image array; `z_index` defines stacking
|
|
95
|
+
order, with zero for the background. Use `tasks.wait` when recovering an accepted
|
|
96
|
+
task. A background-delivery task is usable only when `deliveryStatus` is `ready`;
|
|
97
|
+
the stored image URLs can be reused without uploading them again. The provider's
|
|
98
|
+
Native request format remains available on its existing endpoint.
|
|
99
|
+
|
|
68
100
|
## Dolphin Seedance
|
|
69
101
|
|
|
70
102
|
`0.1.0-alpha.41` adds the independently addressable models
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as JsonObject } from './json-Cz0MkWQn.js';
|
|
2
|
-
import { H as HttpTransport,
|
|
3
|
-
export {
|
|
2
|
+
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 NexraModelEndpointSpec, j as NexraModelSpecFilter } from './media-geometry-KwQh1O8Y.js';
|
|
3
|
+
export { M as MediaGeometryField, k as MediaGeometryProjection, l as NexraBillingCurrency, m as NexraCatalogModelIdentity, 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-KwQh1O8Y.js';
|
|
4
4
|
|
|
5
5
|
declare function formatModelDisplayName(displayName: string, identity?: {
|
|
6
6
|
modelId: string;
|
package/dist/catalog.js
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
listModelSpecs,
|
|
10
10
|
projectMediaGeometry,
|
|
11
11
|
resolveNexraLanguageReasoning
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-OX5GFYVN.js";
|
|
13
|
+
import "./chunk-FEACXUHZ.js";
|
|
14
14
|
export {
|
|
15
15
|
CatalogClient,
|
|
16
16
|
applyMediaGeometry,
|
|
@@ -10,6 +10,7 @@ var MEDIA_KINDS = [
|
|
|
10
10
|
|
|
11
11
|
// ../contracts/src/public-error-catalog.ts
|
|
12
12
|
var PUBLIC_ERROR_CATALOG = {
|
|
13
|
+
queue_wait_timeout: { "zh-CN": "\u4EFB\u52A1\u6392\u961F\u7B49\u5F85\u6267\u884C\u8D85\u8FC7\u65F6\u9650\uFF0C\u5C1A\u672A\u63D0\u4EA4\u7ED9\u6A21\u578B\u670D\u52A1\u3002\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF1B\u6301\u7EED\u8D85\u65F6\u65F6\u51ED\u8BF7\u6C42 ID \u8054\u7CFB\u5E73\u53F0\u7BA1\u7406\u5458\u3002", en: "The task exceeded its queue wait limit before submission to the model service. Try again later; contact a platform administrator with the request ID if queue timeouts persist." },
|
|
13
14
|
task_execution_timeout: { "zh-CN": "\u4EFB\u52A1\u8D85\u8FC7\u603B\u65F6\u9650\uFF0C\u5DF2\u7ED3\u675F\u3002\u4E0A\u6E38\u53EF\u80FD\u4ECD\u5728\u5904\u7406\uFF0C\u8BF7\u5148\u6838\u5BF9\u539F\u8BF7\u6C42\u7ED3\u679C\uFF0C\u907F\u514D\u91CD\u590D\u63D0\u4EA4\u3002", en: "The task exceeded its total time limit and has ended. The upstream service may still be processing it; check the original request before submitting again." },
|
|
14
15
|
authentication_required: { "zh-CN": "\u8BF7\u6C42\u672A\u63D0\u4F9B\u53EF\u7528\u7684 Nexra \u8EAB\u4EFD\u51ED\u8BC1\u3002\u8BF7\u767B\u5F55\u8D26\u6237\uFF0C\u6216\u5728\u8BF7\u6C42\u4E2D\u63D0\u4F9B\u6709\u6548\u7684 Nexra API Key\u3002", en: "The request has no usable Nexra credentials. Sign in or include a valid Nexra API key." },
|
|
15
16
|
invalid_api_key: { "zh-CN": "\u63D0\u4F9B\u7684 Nexra API Key \u672A\u901A\u8FC7\u9A8C\u8BC1\u3002\u8BF7\u68C0\u67E5 Key \u662F\u5426\u6B63\u786E\u3001\u4ECD\u6709\u6548\u4E14\u672A\u88AB\u64A4\u9500\u3002", en: "The Nexra API key could not be verified. Check that it is correct, still valid, and has not been revoked." },
|
|
@@ -28,6 +29,7 @@ var PUBLIC_ERROR_CATALOG = {
|
|
|
28
29
|
upstream_busy: { "zh-CN": "\u6A21\u578B\u670D\u52A1\u5F53\u524D\u7E41\u5FD9\u3002\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF1B\u5982\u5DF2\u6709\u8BF7\u6C42\u6216\u4EFB\u52A1 ID\uFF0C\u8BF7\u5148\u6838\u5BF9\u539F\u8BF7\u6C42\u72B6\u6001\uFF0C\u907F\u514D\u91CD\u590D\u63D0\u4EA4\u3002", en: "The model service is currently busy. Try again later; if a request or task ID already exists, check its status first to avoid duplicate submissions." },
|
|
29
30
|
upstream_unavailable: { "zh-CN": "\u672C\u6B21\u6A21\u578B\u670D\u52A1\u8C03\u7528\u6682\u65F6\u4E0D\u53EF\u7528\u3002\u5982\u4EFB\u52A1\u5DF2\u7ECF\u63D0\u4EA4\uFF0C\u8BF7\u5148\u67E5\u8BE2\u539F\u4EFB\u52A1\u72B6\u6001\uFF1B\u6301\u7EED\u5F02\u5E38\u65F6\u51ED\u8BF7\u6C42 ID \u8054\u7CFB\u5E73\u53F0\u7BA1\u7406\u5458\u6838\u5BF9\u4E0A\u6E38\u670D\u52A1\u3002", en: "This call to the model service is currently unavailable. If a task has already been submitted, check its status first. Contact a platform administrator with the request ID if the problem persists." },
|
|
30
31
|
upstream_response_invalid: { "zh-CN": "\u6A21\u578B\u670D\u52A1\u8FD4\u56DE\u7684\u54CD\u5E94\u4E0D\u7B26\u5408\u63A5\u53E3\u7EA6\u5B9A\uFF0C\u5E73\u53F0\u65E0\u6CD5\u53EF\u9760\u8BFB\u53D6\u7ED3\u679C\u3002\u8BF7\u67E5\u770B\u53EF\u7528\u7684\u4E0A\u6E38\u9519\u8BEF\u8BE6\u60C5\u548C\u539F\u8BF7\u6C42\u72B6\u6001\uFF0C\u5E76\u51ED\u8BF7\u6C42 ID \u8054\u7CFB\u5E73\u53F0\u7BA1\u7406\u5458\u3002", en: "The model service response does not meet the API contract, so the platform cannot read the result reliably. Check the available upstream error details and original request status, and contact a platform administrator with the request ID." },
|
|
32
|
+
upstream_image_missing: { "zh-CN": "\u6A21\u578B\u672A\u8FD4\u56DE\u56FE\u7247\u3002\u8BF7\u67E5\u770B\u6A21\u578B\u8FD4\u56DE\u7684\u5177\u4F53\u8BF4\u660E\uFF0C\u5E76\u6838\u5BF9\u539F\u8BF7\u6C42\u6216\u4EFB\u52A1\u72B6\u6001\u3002", en: "The model did not return an image. Review the model's explanation and check the original request or task status." },
|
|
31
33
|
upstream_error: { "zh-CN": "\u672C\u6B21\u6A21\u578B\u670D\u52A1\u8C03\u7528\u51FA\u73B0\u9519\u8BEF\uFF0C\u5177\u4F53\u539F\u56E0\u5C1A\u672A\u786E\u8BA4\u3002\u8BF7\u67E5\u770B\u53EF\u7528\u7684\u9519\u8BEF\u8BE6\u60C5\u548C\u539F\u8BF7\u6C42\u6216\u4EFB\u52A1\u72B6\u6001\uFF1B\u9700\u8981\u534F\u52A9\u65F6\u63D0\u4F9B\u8BF7\u6C42 ID\u3002", en: "This call to the model service encountered an error whose specific cause has not been confirmed. Check the available error details and the original request or task status, and provide the request ID when requesting assistance." },
|
|
32
34
|
execution_outcome_unknown: { "zh-CN": "\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u539F\u8BF7\u6C42\u662F\u5426\u5DF2\u88AB\u53D7\u7406\u6216\u5B8C\u6210\u3002\u8BF7\u4F7F\u7528\u539F\u8BF7\u6C42\u6216\u4EFB\u52A1 ID \u67E5\u8BE2\u72B6\u6001\uFF0C\u786E\u8BA4\u7ED3\u679C\u524D\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u3002", en: "It is not yet known whether the original request was accepted or completed. Check its status using the original request or task ID, and do not submit it again until the outcome is confirmed." },
|
|
33
35
|
stream_interrupted: { "zh-CN": "\u54CD\u5E94\u672A\u5B8C\u6574\u7ED3\u675F\uFF0C\u5DF2\u6536\u5230\u7684\u8F93\u51FA\u53EF\u80FD\u4E0D\u5B8C\u6574\u3002\u8BF7\u4FDD\u7559\u539F\u8BF7\u6C42 ID \u5E76\u67E5\u8BE2\u539F\u8BF7\u6C42\u72B6\u6001\uFF0C\u786E\u8BA4\u7ED3\u679C\u524D\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u3002", en: "The response did not finish completely, so the output received may be incomplete. Keep the original request ID and check its status; do not submit again until the outcome is confirmed." },
|
|
@@ -123,7 +125,7 @@ var PUBLIC_ERROR_CATALOG = {
|
|
|
123
125
|
invalid_input_format: { "zh-CN": "\u65E0\u6CD5\u8BC6\u522B\u8F93\u5165\u683C\u5F0F\u6807\u8BC6\u3002\u8BF7\u4F7F\u7528\u63A5\u53E3\u652F\u6301\u7684 inputFormat\uFF0C\u4E0D\u8981\u81EA\u884C\u589E\u52A0\u683C\u5F0F\u7248\u672C\u3002", en: "The input format identifier is not recognized. Use an inputFormat supported by the endpoint rather than inventing a format version." },
|
|
124
126
|
invalid_input_mode: { "zh-CN": "\u8F93\u5165\u6A21\u5F0F\u4E3A\u7A7A\u6216\u4E0D\u7B26\u5408\u4EFB\u52A1\u7EC4\u8981\u6C42\u3002\u8BF7\u9009\u62E9\u652F\u6301\u7684 inputMode\uFF0C\u5E76\u63D0\u4F9B\u5339\u914D\u7684\u8F93\u5165\u5185\u5BB9\u3002", en: "The input mode is missing or does not meet the task run's requirements. Choose a supported inputMode and provide matching input content." },
|
|
125
127
|
invalid_json: { "zh-CN": "\u8BF7\u6C42\u6B63\u6587\u65E0\u6CD5\u4F5C\u4E3A\u6709\u6548 JSON \u89E3\u6790\u3002\u8BF7\u68C0\u67E5 JSON \u8BED\u6CD5\u548C\u9876\u5C42\u7ED3\u6784\uFF0C\u5E76\u4F7F\u7528\u6B63\u786E\u7684 Content-Type\u3002", en: "The request body cannot be parsed as valid JSON. Check its syntax and top-level structure and use the correct Content-Type." },
|
|
126
|
-
invalid_metadata: { "zh-CN": "\u4E1A\u52A1\u5143\u6570\u636E\u4E0D\u7B26\u5408\u8981\u6C42\u3002\u8BF7\u63D0\u4F9B JSON \u5BF9\u8C61\uFF0C\u5E76\u68C0\u67E5\u4FDD\u7559\u5B57\u6BB5 callerUrl \u7684 HTTPS \u6765\u6E90\u683C\u5F0F\
|
|
128
|
+
invalid_metadata: { "zh-CN": "\u4E1A\u52A1\u5143\u6570\u636E\u4E0D\u7B26\u5408\u8981\u6C42\u3002\u8BF7\u63D0\u4F9B JSON \u5BF9\u8C61\uFF0C\u5E76\u68C0\u67E5\u4FDD\u7559\u5B57\u6BB5 callerUrl \u7684 HTTPS \u6765\u6E90\u683C\u5F0F\u3001endUserId \u7684\u5B57\u7B26\u4E32\u683C\u5F0F\u53CA endUserIp \u7684 IPv4/IPv6 \u5730\u5740\u683C\u5F0F\u3002", en: "The metadata does not meet the requirements. Provide a JSON object and check the HTTPS origin format of callerUrl, the string format of endUserId, and the IPv4/IPv6 address format of endUserIp." },
|
|
127
129
|
invalid_model: { "zh-CN": "\u8BF7\u6C42\u4E2D\u7684\u6A21\u578B\u6807\u8BC6\u6216\u6A21\u578B\u914D\u7F6E\u4E0D\u6EE1\u8DB3\u63A5\u53E3\u8981\u6C42\u3002\u8BF7\u6838\u5BF9\u5BF9\u5E94\u63A5\u53E3\u7684 model/Model ID \u548C\u6A21\u578B\u914D\u7F6E\u5B57\u6BB5\u3002", en: "The model identifier or configuration does not meet the endpoint's requirements. Check the endpoint's model or model ID and the model configuration fields." },
|
|
128
130
|
invalid_model_endpoint: { "zh-CN": "\u6A21\u578B\u7AEF\u70B9\u914D\u7F6E\u672A\u6EE1\u8DB3\u8981\u6C42\u3002\u8BF7\u6838\u5BF9\u7AEF\u70B9\u6807\u8BC6\u3001\u534F\u8BAE\u3001\u64CD\u4F5C\u8DEF\u5F84\u548C\u53C2\u6570\u7ED3\u6784\u3002", en: "The model endpoint configuration does not meet the requirements. Check the endpoint identifier, protocol, operation paths, and parameter schema." },
|
|
129
131
|
invalid_model_import: { "zh-CN": "\u6A21\u578B\u5BFC\u5165\u4FE1\u606F\u4E0D\u5B8C\u6574\u6216\u4E0D\u5339\u914D\u3002\u8BF7\u63D0\u4F9B\u4E0A\u6E38 Model ID\uFF0C\u5E76\u9009\u62E9\u5BF9\u5E94\u7684\u4EE3\u7801\u6A21\u578B\u3002", en: "The model import information is incomplete or inconsistent. Provide the upstream model ID and select the corresponding code-defined model." },
|
|
@@ -365,6 +367,19 @@ function extractUpstreamErrorMessage(value) {
|
|
|
365
367
|
const message = record[key];
|
|
366
368
|
if (typeof message === "string" && message.trim()) return message;
|
|
367
369
|
}
|
|
370
|
+
if (Array.isArray(record.candidates)) {
|
|
371
|
+
const messages = record.candidates.flatMap((candidate2) => {
|
|
372
|
+
if (!isRecord(candidate2)) return [];
|
|
373
|
+
const parts = isRecord(candidate2.content) ? candidate2.content.parts : void 0;
|
|
374
|
+
const texts = Array.isArray(parts) ? parts.flatMap((part) => isRecord(part) && part.thought !== true && typeof part.text === "string" && part.text.trim() ? [part.text] : []) : [];
|
|
375
|
+
return texts.length ? texts : typeof candidate2.finishMessage === "string" && candidate2.finishMessage.trim() ? [candidate2.finishMessage] : [];
|
|
376
|
+
});
|
|
377
|
+
if (messages.length) return messages.join("\n");
|
|
378
|
+
}
|
|
379
|
+
if (isRecord(record.promptFeedback)) {
|
|
380
|
+
const message = record.promptFeedback.blockReasonMessage;
|
|
381
|
+
if (typeof message === "string" && message.trim()) return message;
|
|
382
|
+
}
|
|
368
383
|
return void 0;
|
|
369
384
|
};
|
|
370
385
|
return read(value, 0);
|
|
@@ -452,7 +467,7 @@ var NEXRA_MEDIA_OPERATION_DEFINITIONS = Object.freeze([
|
|
|
452
467
|
status: "active",
|
|
453
468
|
outputKind: "image",
|
|
454
469
|
features: ["text-to-image", "image-to-image", "image-reference", "image-edit", "image-inpaint", "image-control"],
|
|
455
|
-
parameterKeys: ["aspect_ratio", "resolution", "quality", "count", "output_format", "seed"]
|
|
470
|
+
parameterKeys: ["aspect_ratio", "resolution", "quality", "count", "output_format", "seed", "output_mode", "prompt_optimization"]
|
|
456
471
|
},
|
|
457
472
|
{
|
|
458
473
|
operation: "video.generate",
|
|
@@ -554,6 +569,8 @@ var NEXRA_MEDIA_INPUT_SCHEMAS = Object.freeze({
|
|
|
554
569
|
"image.generate": inputSchema(
|
|
555
570
|
[textPartSchema(["prompt", "negative_prompt"]), imagePart],
|
|
556
571
|
{
|
|
572
|
+
output_mode: { type: "string", enum: ["image", "layers"], "x-ui": { hidden: true } },
|
|
573
|
+
prompt_optimization: { type: "string", enum: ["standard", "fast"], "x-ui": { hidden: true } },
|
|
557
574
|
aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
|
|
558
575
|
resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
|
|
559
576
|
quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
|
|
@@ -646,6 +663,7 @@ function nexraMediaOperationForMode(mode) {
|
|
|
646
663
|
if (["text-to-video", "image-to-video", "multimodal-to-video", "avatar-video"].includes(mode)) return "video.generate";
|
|
647
664
|
if (["text-to-speech", "text-to-music", "text-to-sfx"].includes(mode)) return "audio.generate";
|
|
648
665
|
if (mode === "image-upscale") return "image.upscale";
|
|
666
|
+
if (mode === "video-upscale") return "video.upscale";
|
|
649
667
|
return void 0;
|
|
650
668
|
}
|
|
651
669
|
function nexraMediaInputSchemaForMode(mode) {
|