pareta 1.3.0 → 1.4.0
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/dist/index.cjs +29 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -13
- package/dist/index.d.ts +32 -13
- package/dist/index.mjs +29 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -468,27 +468,41 @@ declare class Audio {
|
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
/**
|
|
471
|
-
* `pa.images` — the image
|
|
472
|
-
* Python SDK's `client.images`.
|
|
471
|
+
* `pa.images` — the image capability lanes (generate + edit), TS parity with
|
|
472
|
+
* the Python SDK's `client.images`.
|
|
473
473
|
*
|
|
474
|
-
* Dedicated
|
|
475
|
-
* POST /v1/images/generations {prompt, size?, seed?}
|
|
476
|
-
*
|
|
474
|
+
* Dedicated routes, not `chat.completions`:
|
|
475
|
+
* POST /v1/images/generations {prompt, size?, seed?} -> {created, model,
|
|
476
|
+
* data: [{b64_json}], size}
|
|
477
|
+
* POST /v1/images/edits {prompt, image (b64), seed?} -> same shape
|
|
478
|
+
*
|
|
479
|
+
* Both run on Pareta's open image model (`hidream-1`) and are metered at a
|
|
480
|
+
* FLAT price per call — generation by image (every size costs the same;
|
|
481
|
+
* the model renders at full 2K internally), editing by edit (the output
|
|
482
|
+
* keeps the reference's aspect ratio). The `X-Pareta-Billed` response
|
|
483
|
+
* header carries the per-request receipt in micro-USD. Delivery sizes for
|
|
484
|
+
* generation (server-authoritative): 1024x1024 (default), 2048x2048,
|
|
485
|
+
* 2304x1728, 1728x2304, 2560x1440, 1440x2560.
|
|
477
486
|
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
* micro-USD. Delivery sizes today (server-authoritative): 1024x1024
|
|
483
|
-
* (default), 2048x2048, 2304x1728, 1728x2304, 2560x1440, 1440x2560.
|
|
487
|
+
* Edit input follows the audio FileInput convention: a string is a FILE
|
|
488
|
+
* PATH (read via lazy node:fs — browser/edge bundles stay clean);
|
|
489
|
+
* Blob/ArrayBuffer/Uint8Array are raw bytes; `{ base64 }` passes
|
|
490
|
+
* pre-encoded image data through untouched.
|
|
484
491
|
*/
|
|
485
492
|
|
|
493
|
+
type ImageInput = string | Blob | ArrayBuffer | Uint8Array | {
|
|
494
|
+
base64: string;
|
|
495
|
+
};
|
|
486
496
|
interface ImageGenerateOptions {
|
|
487
497
|
/** Delivery size, e.g. "2560x1440" (omit for 1024x1024). Flat price. */
|
|
488
498
|
size?: string;
|
|
489
499
|
/** Pin the noise seed for reproducibility. */
|
|
490
500
|
seed?: number;
|
|
491
501
|
}
|
|
502
|
+
interface ImageEditOptions {
|
|
503
|
+
/** Pin the noise seed for reproducibility. */
|
|
504
|
+
seed?: number;
|
|
505
|
+
}
|
|
492
506
|
declare class Images {
|
|
493
507
|
private readonly client;
|
|
494
508
|
constructor(client: Transport);
|
|
@@ -496,6 +510,11 @@ declare class Images {
|
|
|
496
510
|
* whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
|
|
497
511
|
* Node). Billed flat per image. */
|
|
498
512
|
generate(prompt: string, opts?: ImageGenerateOptions): Promise<ImageGeneration>;
|
|
513
|
+
/** Edit one reference image with a plain-language instruction (no mask).
|
|
514
|
+
* `image` is a file path, raw bytes, a Blob, or `{ base64 }` (≤25MB
|
|
515
|
+
* decoded). The output keeps the reference's aspect ratio. Billed flat
|
|
516
|
+
* per edit. */
|
|
517
|
+
edit(image: ImageInput, prompt: string, opts?: ImageEditOptions): Promise<ImageGeneration>;
|
|
499
518
|
}
|
|
500
519
|
|
|
501
520
|
/**
|
|
@@ -611,7 +630,7 @@ declare class Pareta implements Transport {
|
|
|
611
630
|
stream<T = unknown>(method: string, path: string, opts?: StreamOptions): AsyncGenerator<T>;
|
|
612
631
|
}
|
|
613
632
|
|
|
614
|
-
declare const VERSION = "1.
|
|
633
|
+
declare const VERSION = "1.4.0";
|
|
615
634
|
|
|
616
635
|
/**
|
|
617
636
|
* Typed error hierarchy for the Pareta SDK — a faithful port of the Python
|
|
@@ -703,4 +722,4 @@ declare class EndpointNotReadyError extends APIStatusError {
|
|
|
703
722
|
constructor(message: string, init: APIStatusErrorInit);
|
|
704
723
|
}
|
|
705
724
|
|
|
706
|
-
export { APIConnectionError, APIStatusError, APITimeoutError, Audio, type AudioInput, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, type ImageGenerateOptions, ImageGeneration, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Speech, type SpeechOptions, Task, TaskMatch, TaskMatchCandidate, Transcription, type TranscriptionOptions, type Transport, Usage, VERSION, type ValidationErrorItem };
|
|
725
|
+
export { APIConnectionError, APIStatusError, APITimeoutError, Audio, type AudioInput, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, type ImageEditOptions, type ImageGenerateOptions, ImageGeneration, type ImageInput, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Speech, type SpeechOptions, Task, TaskMatch, TaskMatchCandidate, Transcription, type TranscriptionOptions, type Transport, Usage, VERSION, type ValidationErrorItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -468,27 +468,41 @@ declare class Audio {
|
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
/**
|
|
471
|
-
* `pa.images` — the image
|
|
472
|
-
* Python SDK's `client.images`.
|
|
471
|
+
* `pa.images` — the image capability lanes (generate + edit), TS parity with
|
|
472
|
+
* the Python SDK's `client.images`.
|
|
473
473
|
*
|
|
474
|
-
* Dedicated
|
|
475
|
-
* POST /v1/images/generations {prompt, size?, seed?}
|
|
476
|
-
*
|
|
474
|
+
* Dedicated routes, not `chat.completions`:
|
|
475
|
+
* POST /v1/images/generations {prompt, size?, seed?} -> {created, model,
|
|
476
|
+
* data: [{b64_json}], size}
|
|
477
|
+
* POST /v1/images/edits {prompt, image (b64), seed?} -> same shape
|
|
478
|
+
*
|
|
479
|
+
* Both run on Pareta's open image model (`hidream-1`) and are metered at a
|
|
480
|
+
* FLAT price per call — generation by image (every size costs the same;
|
|
481
|
+
* the model renders at full 2K internally), editing by edit (the output
|
|
482
|
+
* keeps the reference's aspect ratio). The `X-Pareta-Billed` response
|
|
483
|
+
* header carries the per-request receipt in micro-USD. Delivery sizes for
|
|
484
|
+
* generation (server-authoritative): 1024x1024 (default), 2048x2048,
|
|
485
|
+
* 2304x1728, 1728x2304, 2560x1440, 1440x2560.
|
|
477
486
|
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
* micro-USD. Delivery sizes today (server-authoritative): 1024x1024
|
|
483
|
-
* (default), 2048x2048, 2304x1728, 1728x2304, 2560x1440, 1440x2560.
|
|
487
|
+
* Edit input follows the audio FileInput convention: a string is a FILE
|
|
488
|
+
* PATH (read via lazy node:fs — browser/edge bundles stay clean);
|
|
489
|
+
* Blob/ArrayBuffer/Uint8Array are raw bytes; `{ base64 }` passes
|
|
490
|
+
* pre-encoded image data through untouched.
|
|
484
491
|
*/
|
|
485
492
|
|
|
493
|
+
type ImageInput = string | Blob | ArrayBuffer | Uint8Array | {
|
|
494
|
+
base64: string;
|
|
495
|
+
};
|
|
486
496
|
interface ImageGenerateOptions {
|
|
487
497
|
/** Delivery size, e.g. "2560x1440" (omit for 1024x1024). Flat price. */
|
|
488
498
|
size?: string;
|
|
489
499
|
/** Pin the noise seed for reproducibility. */
|
|
490
500
|
seed?: number;
|
|
491
501
|
}
|
|
502
|
+
interface ImageEditOptions {
|
|
503
|
+
/** Pin the noise seed for reproducibility. */
|
|
504
|
+
seed?: number;
|
|
505
|
+
}
|
|
492
506
|
declare class Images {
|
|
493
507
|
private readonly client;
|
|
494
508
|
constructor(client: Transport);
|
|
@@ -496,6 +510,11 @@ declare class Images {
|
|
|
496
510
|
* whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
|
|
497
511
|
* Node). Billed flat per image. */
|
|
498
512
|
generate(prompt: string, opts?: ImageGenerateOptions): Promise<ImageGeneration>;
|
|
513
|
+
/** Edit one reference image with a plain-language instruction (no mask).
|
|
514
|
+
* `image` is a file path, raw bytes, a Blob, or `{ base64 }` (≤25MB
|
|
515
|
+
* decoded). The output keeps the reference's aspect ratio. Billed flat
|
|
516
|
+
* per edit. */
|
|
517
|
+
edit(image: ImageInput, prompt: string, opts?: ImageEditOptions): Promise<ImageGeneration>;
|
|
499
518
|
}
|
|
500
519
|
|
|
501
520
|
/**
|
|
@@ -611,7 +630,7 @@ declare class Pareta implements Transport {
|
|
|
611
630
|
stream<T = unknown>(method: string, path: string, opts?: StreamOptions): AsyncGenerator<T>;
|
|
612
631
|
}
|
|
613
632
|
|
|
614
|
-
declare const VERSION = "1.
|
|
633
|
+
declare const VERSION = "1.4.0";
|
|
615
634
|
|
|
616
635
|
/**
|
|
617
636
|
* Typed error hierarchy for the Pareta SDK — a faithful port of the Python
|
|
@@ -703,4 +722,4 @@ declare class EndpointNotReadyError extends APIStatusError {
|
|
|
703
722
|
constructor(message: string, init: APIStatusErrorInit);
|
|
704
723
|
}
|
|
705
724
|
|
|
706
|
-
export { APIConnectionError, APIStatusError, APITimeoutError, Audio, type AudioInput, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, type ImageGenerateOptions, ImageGeneration, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Speech, type SpeechOptions, Task, TaskMatch, TaskMatchCandidate, Transcription, type TranscriptionOptions, type Transport, Usage, VERSION, type ValidationErrorItem };
|
|
725
|
+
export { APIConnectionError, APIStatusError, APITimeoutError, Audio, type AudioInput, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, type ImageEditOptions, type ImageGenerateOptions, ImageGeneration, type ImageInput, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Speech, type SpeechOptions, Task, TaskMatch, TaskMatchCandidate, Transcription, type TranscriptionOptions, type Transport, Usage, VERSION, type ValidationErrorItem };
|
package/dist/index.mjs
CHANGED
|
@@ -172,7 +172,7 @@ function parseSSE(reader, opts) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// src/version.ts
|
|
175
|
-
var VERSION = "1.
|
|
175
|
+
var VERSION = "1.4.0";
|
|
176
176
|
|
|
177
177
|
// src/money.ts
|
|
178
178
|
var MICRO_PER_CENT = 10000n;
|
|
@@ -915,6 +915,21 @@ var Audio = class {
|
|
|
915
915
|
|
|
916
916
|
// src/resources/images.ts
|
|
917
917
|
var PATH3 = "/v1/images/generations";
|
|
918
|
+
var EDIT_PATH = "/v1/images/edits";
|
|
919
|
+
async function toBase642(image) {
|
|
920
|
+
if (typeof image === "string") {
|
|
921
|
+
const { readFile } = await import('fs/promises');
|
|
922
|
+
return bytesToBase64(new Uint8Array(await readFile(image)));
|
|
923
|
+
}
|
|
924
|
+
if (typeof image === "object" && image !== null && "base64" in image) {
|
|
925
|
+
if (!image.base64 || !image.base64.trim()) throw new ParetaError("image.base64 is empty");
|
|
926
|
+
return image.base64;
|
|
927
|
+
}
|
|
928
|
+
if (image instanceof Blob) return bytesToBase64(new Uint8Array(await image.arrayBuffer()));
|
|
929
|
+
const bytes = image instanceof Uint8Array ? image : new Uint8Array(image);
|
|
930
|
+
if (bytes.byteLength === 0) throw new ParetaError("image is empty");
|
|
931
|
+
return bytesToBase64(bytes);
|
|
932
|
+
}
|
|
918
933
|
var Images = class {
|
|
919
934
|
constructor(client) {
|
|
920
935
|
this.client = client;
|
|
@@ -933,6 +948,19 @@ var Images = class {
|
|
|
933
948
|
cast: (raw) => new ImageGeneration(raw)
|
|
934
949
|
});
|
|
935
950
|
}
|
|
951
|
+
/** Edit one reference image with a plain-language instruction (no mask).
|
|
952
|
+
* `image` is a file path, raw bytes, a Blob, or `{ base64 }` (≤25MB
|
|
953
|
+
* decoded). The output keeps the reference's aspect ratio. Billed flat
|
|
954
|
+
* per edit. */
|
|
955
|
+
async edit(image, prompt, opts = {}) {
|
|
956
|
+
if (!prompt || !prompt.trim()) throw new ParetaError("prompt is required");
|
|
957
|
+
const body = { prompt, image: await toBase642(image) };
|
|
958
|
+
if (opts.seed !== void 0) body.seed = opts.seed;
|
|
959
|
+
return this.client.request("POST", EDIT_PATH, {
|
|
960
|
+
body,
|
|
961
|
+
cast: (raw) => new ImageGeneration(raw)
|
|
962
|
+
});
|
|
963
|
+
}
|
|
936
964
|
};
|
|
937
965
|
|
|
938
966
|
// src/resources/retrieval.ts
|