pareta 1.2.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.d.cts CHANGED
@@ -187,6 +187,19 @@ declare class Speech extends BaseModel {
187
187
  /** Write the decoded audio to `path` (Node only — lazy node:fs). */
188
188
  save(path: string): Promise<this>;
189
189
  }
190
+ /** Image result from `images.generate(...)`. `.image` is decoded PNG bytes;
191
+ * `.size` is the ACTUAL delivered size. Billed flat per image (the
192
+ * `X-Pareta-Billed` response header carries the receipt). */
193
+ declare class ImageGeneration extends BaseModel {
194
+ /** The generated image, base64-decoded to raw PNG bytes. */
195
+ get image(): Uint8Array;
196
+ get b64Json(): string | null;
197
+ get size(): string | null;
198
+ get model(): string | null;
199
+ get created(): number | null;
200
+ /** Write the decoded PNG to `path` (Node only — lazy node:fs). */
201
+ save(path: string): Promise<this>;
202
+ }
190
203
 
191
204
  /**
192
205
  * `client.chat.completions` — OpenAI-compatible chat completions.
@@ -246,8 +259,10 @@ declare class Models {
246
259
  }
247
260
 
248
261
  /**
249
- * `client.tasks` — browse the benchmark catalog and match free-text intent to
250
- * a task (`match` is the discovery surface: it tells you what Pareta can do).
262
+ * `client.tasks` — the grading-contract directory for evals. A task names how
263
+ * a dataset is scored (row shape + scorer); inference never takes one. `match`
264
+ * maps a plain-English description of your dataset to the contract that
265
+ * grades it — feed the matched task id into `evals.runs.create(task=...)`.
251
266
  */
252
267
 
253
268
  declare class Tasks {
@@ -452,6 +467,56 @@ declare class Audio {
452
467
  speech(text: string, opts?: SpeechOptions): Promise<Speech>;
453
468
  }
454
469
 
470
+ /**
471
+ * `pa.images` — the image capability lanes (generate + edit), TS parity with
472
+ * the Python SDK's `client.images`.
473
+ *
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.
486
+ *
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.
491
+ */
492
+
493
+ type ImageInput = string | Blob | ArrayBuffer | Uint8Array | {
494
+ base64: string;
495
+ };
496
+ interface ImageGenerateOptions {
497
+ /** Delivery size, e.g. "2560x1440" (omit for 1024x1024). Flat price. */
498
+ size?: string;
499
+ /** Pin the noise seed for reproducibility. */
500
+ seed?: number;
501
+ }
502
+ interface ImageEditOptions {
503
+ /** Pin the noise seed for reproducibility. */
504
+ seed?: number;
505
+ }
506
+ declare class Images {
507
+ private readonly client;
508
+ constructor(client: Transport);
509
+ /** Generate one image from a text prompt. Returns an `ImageGeneration`
510
+ * whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
511
+ * Node). Billed flat per image. */
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>;
518
+ }
519
+
455
520
  /**
456
521
  * `pa.rerank(...)` + `pa.embeddings(...)` — the Retrieval capability lanes
457
522
  * (the RAG stack: embeddings for recall, reranking for precision).
@@ -462,7 +527,7 @@ declare class Audio {
462
527
  * POST /v1/embeddings {input[], input_type?} -> unit-normalized vectors
463
528
  *
464
529
  * Rerank is metered per document scored; embeddings per input token. You never
465
- * pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `bge-1`),
530
+ * pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `qwen-embed-1`),
466
531
  * exactly as `model:"auto"` does for chat.
467
532
  *
468
533
  * Exposed as callable client fields (`pa.rerank(...)`) rather than resource
@@ -540,6 +605,8 @@ declare class Pareta implements Transport {
540
605
  readonly rerank: RerankFn;
541
606
  /** Text embeddings (the Retrieval recall lane) — `pa.embeddings(input, {inputType})`. */
542
607
  readonly embeddings: EmbeddingsFn;
608
+ /** Image generation — `pa.images.generate(prompt, {size, seed})`, flat price per image. */
609
+ readonly images: Images;
543
610
  constructor(options?: ParetaOptions);
544
611
  /** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
545
612
  static fromEnv(options?: ParetaOptions): Pareta;
@@ -563,7 +630,7 @@ declare class Pareta implements Transport {
563
630
  stream<T = unknown>(method: string, path: string, opts?: StreamOptions): AsyncGenerator<T>;
564
631
  }
565
632
 
566
- declare const VERSION = "1.2.0";
633
+ declare const VERSION = "1.4.0";
567
634
 
568
635
  /**
569
636
  * Typed error hierarchy for the Pareta SDK — a faithful port of the Python
@@ -655,4 +722,4 @@ declare class EndpointNotReadyError extends APIStatusError {
655
722
  constructor(message: string, init: APIStatusErrorInit);
656
723
  }
657
724
 
658
- 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, 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
@@ -187,6 +187,19 @@ declare class Speech extends BaseModel {
187
187
  /** Write the decoded audio to `path` (Node only — lazy node:fs). */
188
188
  save(path: string): Promise<this>;
189
189
  }
190
+ /** Image result from `images.generate(...)`. `.image` is decoded PNG bytes;
191
+ * `.size` is the ACTUAL delivered size. Billed flat per image (the
192
+ * `X-Pareta-Billed` response header carries the receipt). */
193
+ declare class ImageGeneration extends BaseModel {
194
+ /** The generated image, base64-decoded to raw PNG bytes. */
195
+ get image(): Uint8Array;
196
+ get b64Json(): string | null;
197
+ get size(): string | null;
198
+ get model(): string | null;
199
+ get created(): number | null;
200
+ /** Write the decoded PNG to `path` (Node only — lazy node:fs). */
201
+ save(path: string): Promise<this>;
202
+ }
190
203
 
191
204
  /**
192
205
  * `client.chat.completions` — OpenAI-compatible chat completions.
@@ -246,8 +259,10 @@ declare class Models {
246
259
  }
247
260
 
248
261
  /**
249
- * `client.tasks` — browse the benchmark catalog and match free-text intent to
250
- * a task (`match` is the discovery surface: it tells you what Pareta can do).
262
+ * `client.tasks` — the grading-contract directory for evals. A task names how
263
+ * a dataset is scored (row shape + scorer); inference never takes one. `match`
264
+ * maps a plain-English description of your dataset to the contract that
265
+ * grades it — feed the matched task id into `evals.runs.create(task=...)`.
251
266
  */
252
267
 
253
268
  declare class Tasks {
@@ -452,6 +467,56 @@ declare class Audio {
452
467
  speech(text: string, opts?: SpeechOptions): Promise<Speech>;
453
468
  }
454
469
 
470
+ /**
471
+ * `pa.images` — the image capability lanes (generate + edit), TS parity with
472
+ * the Python SDK's `client.images`.
473
+ *
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.
486
+ *
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.
491
+ */
492
+
493
+ type ImageInput = string | Blob | ArrayBuffer | Uint8Array | {
494
+ base64: string;
495
+ };
496
+ interface ImageGenerateOptions {
497
+ /** Delivery size, e.g. "2560x1440" (omit for 1024x1024). Flat price. */
498
+ size?: string;
499
+ /** Pin the noise seed for reproducibility. */
500
+ seed?: number;
501
+ }
502
+ interface ImageEditOptions {
503
+ /** Pin the noise seed for reproducibility. */
504
+ seed?: number;
505
+ }
506
+ declare class Images {
507
+ private readonly client;
508
+ constructor(client: Transport);
509
+ /** Generate one image from a text prompt. Returns an `ImageGeneration`
510
+ * whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
511
+ * Node). Billed flat per image. */
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>;
518
+ }
519
+
455
520
  /**
456
521
  * `pa.rerank(...)` + `pa.embeddings(...)` — the Retrieval capability lanes
457
522
  * (the RAG stack: embeddings for recall, reranking for precision).
@@ -462,7 +527,7 @@ declare class Audio {
462
527
  * POST /v1/embeddings {input[], input_type?} -> unit-normalized vectors
463
528
  *
464
529
  * Rerank is metered per document scored; embeddings per input token. You never
465
- * pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `bge-1`),
530
+ * pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `qwen-embed-1`),
466
531
  * exactly as `model:"auto"` does for chat.
467
532
  *
468
533
  * Exposed as callable client fields (`pa.rerank(...)`) rather than resource
@@ -540,6 +605,8 @@ declare class Pareta implements Transport {
540
605
  readonly rerank: RerankFn;
541
606
  /** Text embeddings (the Retrieval recall lane) — `pa.embeddings(input, {inputType})`. */
542
607
  readonly embeddings: EmbeddingsFn;
608
+ /** Image generation — `pa.images.generate(prompt, {size, seed})`, flat price per image. */
609
+ readonly images: Images;
543
610
  constructor(options?: ParetaOptions);
544
611
  /** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
545
612
  static fromEnv(options?: ParetaOptions): Pareta;
@@ -563,7 +630,7 @@ declare class Pareta implements Transport {
563
630
  stream<T = unknown>(method: string, path: string, opts?: StreamOptions): AsyncGenerator<T>;
564
631
  }
565
632
 
566
- declare const VERSION = "1.2.0";
633
+ declare const VERSION = "1.4.0";
567
634
 
568
635
  /**
569
636
  * Typed error hierarchy for the Pareta SDK — a faithful port of the Python
@@ -655,4 +722,4 @@ declare class EndpointNotReadyError extends APIStatusError {
655
722
  constructor(message: string, init: APIStatusErrorInit);
656
723
  }
657
724
 
658
- 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, 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.2.0";
175
+ var VERSION = "1.4.0";
176
176
 
177
177
  // src/money.ts
178
178
  var MICRO_PER_CENT = 10000n;
@@ -531,6 +531,32 @@ var Speech = class extends BaseModel {
531
531
  return this;
532
532
  }
533
533
  };
534
+ var ImageGeneration = class extends BaseModel {
535
+ /** The generated image, base64-decoded to raw PNG bytes. */
536
+ get image() {
537
+ const b64 = this.b64Json ?? "";
538
+ return b64 ? base64ToBytes(b64) : new Uint8Array(0);
539
+ }
540
+ get b64Json() {
541
+ const data = this.raw.data ?? [];
542
+ return data[0]?.b64_json ?? null;
543
+ }
544
+ get size() {
545
+ return this.raw.size ?? null;
546
+ }
547
+ get model() {
548
+ return this.raw.model ?? null;
549
+ }
550
+ get created() {
551
+ return this.raw.created ?? null;
552
+ }
553
+ /** Write the decoded PNG to `path` (Node only — lazy node:fs). */
554
+ async save(path) {
555
+ const { writeFile } = await import('fs/promises');
556
+ await writeFile(path, this.image);
557
+ return this;
558
+ }
559
+ };
534
560
 
535
561
  // src/resources/chat.ts
536
562
  var PATH = "/v1/chat/completions";
@@ -887,6 +913,56 @@ var Audio = class {
887
913
  }
888
914
  };
889
915
 
916
+ // src/resources/images.ts
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
+ }
933
+ var Images = class {
934
+ constructor(client) {
935
+ this.client = client;
936
+ }
937
+ client;
938
+ /** Generate one image from a text prompt. Returns an `ImageGeneration`
939
+ * whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
940
+ * Node). Billed flat per image. */
941
+ generate(prompt, opts = {}) {
942
+ if (!prompt || !prompt.trim()) throw new ParetaError("prompt is required");
943
+ const body = { prompt };
944
+ if (opts.size) body.size = opts.size;
945
+ if (opts.seed !== void 0) body.seed = opts.seed;
946
+ return this.client.request("POST", PATH3, {
947
+ body,
948
+ cast: (raw) => new ImageGeneration(raw)
949
+ });
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
+ }
964
+ };
965
+
890
966
  // src/resources/retrieval.ts
891
967
  function makeRerank(client) {
892
968
  return (query, documents, opts = {}) => {
@@ -953,6 +1029,8 @@ var Pareta = class _Pareta {
953
1029
  rerank;
954
1030
  /** Text embeddings (the Retrieval recall lane) — `pa.embeddings(input, {inputType})`. */
955
1031
  embeddings;
1032
+ /** Image generation — `pa.images.generate(prompt, {size, seed})`, flat price per image. */
1033
+ images;
956
1034
  constructor(options = {}) {
957
1035
  if (!options.apiKey) {
958
1036
  throw new ParetaError(
@@ -976,6 +1054,7 @@ var Pareta = class _Pareta {
976
1054
  this.audio = new Audio(this);
977
1055
  this.rerank = makeRerank(this);
978
1056
  this.embeddings = makeEmbeddings(this);
1057
+ this.images = new Images(this);
979
1058
  }
980
1059
  /** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
981
1060
  static fromEnv(options = {}) {
@@ -1156,6 +1235,6 @@ var Pareta = class _Pareta {
1156
1235
  }
1157
1236
  };
1158
1237
 
1159
- export { APIConnectionError, APIStatusError, APITimeoutError, Audio, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, Choice, ConflictError, Embeddings, EndpointNotReadyError, EvalItemResult, EvalResult, EvalRun, EvalRuns, EvalSet, EvalSets, FrontierModel, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, PermissionDeniedError, RateLimitError, Rerank, RerankResult, Speech, Task, TaskMatch, TaskMatchCandidate, Transcription, Usage, VERSION };
1238
+ export { APIConnectionError, APIStatusError, APITimeoutError, Audio, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, Choice, ConflictError, Embeddings, EndpointNotReadyError, EvalItemResult, EvalResult, EvalRun, EvalRuns, EvalSet, EvalSets, FrontierModel, ImageGeneration, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, PermissionDeniedError, RateLimitError, Rerank, RerankResult, Speech, Task, TaskMatch, TaskMatchCandidate, Transcription, Usage, VERSION };
1160
1239
  //# sourceMappingURL=index.mjs.map
1161
1240
  //# sourceMappingURL=index.mjs.map