@providerprotocol/ai 0.0.25 → 0.0.27

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.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { M as Message, T as Turn, a as MessageType, b as MessageJSON, c as Tool, d as ToolUseStrategy, J as JSONSchema, S as StreamResult, A as AssistantMessage, e as TokenUsage, f as StreamEvent } from './stream-ITNFNnO4.js';
2
- export { l as AfterCallResult, B as BeforeCallResult, E as EventDelta, g as JSONSchemaProperty, h as JSONSchemaPropertyType, s as MessageMetadata, t as MessageOptions, o as MessageRole, x as StreamEventType, i as ToolCall, m as ToolExecution, k as ToolMetadata, j as ToolResult, n as ToolResultMessage, U as UserMessage, w as aggregateUsage, G as contentBlockStart, H as contentBlockStop, y as createStreamResult, u as createTurn, v as emptyUsage, q as isAssistantMessage, r as isToolResultMessage, p as isUserMessage, D as messageStart, F as messageStop, z as textDelta, C as toolCallDelta } from './stream-ITNFNnO4.js';
3
- import { U as UserContent, A as AssistantContent, P as ProviderIdentity, a as ProviderConfig, C as ContentBlock, L as LLMProvider, E as EmbeddingInput, b as EmbeddingUsage, B as BoundEmbeddingModel, I as ImageOptions, c as ImageInstance, d as LLMHandler$1, e as EmbeddingHandler, f as ImageHandler, g as Provider, M as ModelReference } from './provider-x4RocsnK.js';
4
- export { n as AudioBlock, o as BinaryBlock, a4 as BoundImageModel, q as ContentBlockType, F as EmbeddingProvider, H as EmbeddingRequest, J as EmbeddingResponse, N as EmbeddingVector, j as ErrorCode, W as GeneratedImage, h as Image, m as ImageBlock, $ as ImageCapabilities, Q as ImageEditInput, a1 as ImageEditRequest, S as ImageGenerateOptions, a5 as ImageHandler, O as ImageInput, a6 as ImageModelInput, G as ImageProvider, a3 as ImageProviderStreamResult, a0 as ImageRequest, a2 as ImageResponse, Y as ImageResult, p as ImageSource, r as ImageSourceType, Z as ImageStreamEvent, _ as ImageStreamResult, X as ImageUsage, K as KeyStrategy, l as Modality, k as ModalityType, R as ReasoningBlock, D as RetryStrategy, T as TextBlock, i as UPPError, V as VideoBlock, x as isAudioBlock, z as isBinaryBlock, w as isImageBlock, v as isReasoningBlock, u as isTextBlock, y as isVideoBlock, s as reasoning, t as text } from './provider-x4RocsnK.js';
5
- export { D as DynamicKey, E as ExponentialBackoff, L as LinearBackoff, N as NoRetry, a as RetryAfterStrategy, R as RoundRobinKeys, T as TokenBucket, W as WeightedKeys } from './retry-DTfjXXPh.js';
1
+ import { M as Message, T as Turn, a as MessageType, b as MessageJSON, c as Tool, d as ToolUseStrategy, J as JSONSchema, S as StreamResult, A as AssistantMessage, e as TokenUsage, f as StreamEvent, E as EmbeddingOptions, g as EmbeddingInstance } from './embedding-CK5oa38O.js';
2
+ export { m as AfterCallResult, B as BeforeCallResult, L as EmbedOptions, N as Embedding, R as EmbeddingModelInput, P as EmbeddingProgress, O as EmbeddingResult, Q as EmbeddingStream, y as EventDelta, h as JSONSchemaProperty, i as JSONSchemaPropertyType, t as MessageMetadata, u as MessageOptions, p as MessageRole, z as StreamEventType, j as ToolCall, n as ToolExecution, l as ToolMetadata, k as ToolResult, o as ToolResultMessage, U as UserMessage, x as aggregateUsage, I as contentBlockStart, K as contentBlockStop, C as createStreamResult, v as createTurn, w as emptyUsage, r as isAssistantMessage, s as isToolResultMessage, q as isUserMessage, G as messageStart, H as messageStop, D as textDelta, F as toolCallDelta } from './embedding-CK5oa38O.js';
3
+ import { U as UserContent, A as AssistantContent, P as ProviderIdentity, a as ProviderConfig, C as ContentBlock, L as LLMProvider, I as ImageOptions, b as ImageInstance, c as LLMHandler$1, E as EmbeddingHandler, d as ImageHandler, e as Provider, M as ModelReference } from './provider-6-mJYOOl.js';
4
+ export { l as AudioBlock, B as BinaryBlock, D as BoundEmbeddingModel, a4 as BoundImageModel, n as ContentBlockType, N as EmbeddingInput, y as EmbeddingProvider, F as EmbeddingRequest, G as EmbeddingResponse, J as EmbeddingUsage, H as EmbeddingVector, h as ErrorCode, W as GeneratedImage, f as Image, k as ImageBlock, $ as ImageCapabilities, Q as ImageEditInput, a1 as ImageEditRequest, S as ImageGenerateOptions, a5 as ImageHandler, O as ImageInput, a6 as ImageModelInput, z as ImageProvider, a3 as ImageProviderStreamResult, a0 as ImageRequest, a2 as ImageResponse, Y as ImageResult, m as ImageSource, o as ImageSourceType, Z as ImageStreamEvent, _ as ImageStreamResult, X as ImageUsage, K as KeyStrategy, j as Modality, i as ModalityType, R as ReasoningBlock, x as RetryStrategy, T as TextBlock, g as UPPError, V as VideoBlock, u as isAudioBlock, w as isBinaryBlock, s as isImageBlock, q as isReasoningBlock, p as isTextBlock, v as isVideoBlock, r as reasoning, t as text } from './provider-6-mJYOOl.js';
5
+ export { D as DynamicKey, E as ExponentialBackoff, L as LinearBackoff, N as NoRetry, a as RetryAfterStrategy, R as RoundRobinKeys, T as TokenBucket, W as WeightedKeys } from './retry-BhX8mIrL.js';
6
6
 
7
7
  /**
8
8
  * @fileoverview Thread class for managing conversation history.
@@ -550,161 +550,6 @@ interface LLMHandler<TParams = unknown> {
550
550
  */
551
551
  declare function llm<TParams = unknown>(options: LLMOptions<TParams>): LLMInstance<TParams>;
552
552
 
553
- /**
554
- * @fileoverview Embedding types for vector embedding generation.
555
- *
556
- * Defines the interfaces for configuring and executing embedding operations,
557
- * including options, instances, requests, responses, and streaming progress.
558
- *
559
- * @module types/embedding
560
- */
561
-
562
- /**
563
- * Structural type for embedding model input.
564
- * Uses structural typing to avoid generic variance issues with Provider generics.
565
- *
566
- * @remarks
567
- * This type mirrors {@link ModelReference} while keeping provider options
568
- * structurally compatible across providers.
569
- *
570
- * @see ModelReference
571
- */
572
- interface EmbeddingModelInput {
573
- readonly modelId: string;
574
- readonly provider: ProviderIdentity;
575
- /** Optional provider configuration merged into requests */
576
- readonly providerConfig?: Partial<ProviderConfig>;
577
- }
578
- /**
579
- * Options for creating an embedding instance with the embedding() function.
580
- *
581
- * @typeParam TParams - Provider-specific parameter type
582
- *
583
- * @example
584
- * ```typescript
585
- * const options: EmbeddingOptions<OpenAIEmbedParams> = {
586
- * model: openai('text-embedding-3-large'),
587
- * config: { apiKey: process.env.OPENAI_API_KEY },
588
- * params: { dimensions: 1536 }
589
- * };
590
- * ```
591
- */
592
- interface EmbeddingOptions<TParams = unknown> {
593
- /** A model reference from a provider factory */
594
- model: EmbeddingModelInput;
595
- /** Provider infrastructure configuration */
596
- config?: ProviderConfig;
597
- /** Provider-specific parameters (passed through unchanged) */
598
- params?: TParams;
599
- }
600
- /**
601
- * Options for embed() calls.
602
- */
603
- interface EmbedOptions {
604
- /**
605
- * Enable chunked processing with progress for large input sets.
606
- * When true, returns EmbeddingStream instead of Promise.
607
- */
608
- chunked?: boolean;
609
- /** Inputs per batch when chunked (default: provider max) */
610
- batchSize?: number;
611
- /** Concurrent batch limit when chunked (default: 1) */
612
- concurrency?: number;
613
- /** Abort signal for cancellation */
614
- signal?: AbortSignal;
615
- }
616
- /**
617
- * Single embedding vector result.
618
- */
619
- interface Embedding {
620
- /** The embedding vector */
621
- vector: number[];
622
- /** Vector dimensionality */
623
- dimensions: number;
624
- /** Index corresponding to input array position */
625
- index: number;
626
- /** Token count for this input (if provider reports) */
627
- tokens?: number;
628
- /** Provider-specific per-embedding metadata */
629
- metadata?: Record<string, unknown>;
630
- }
631
- /**
632
- * Result from embed() call.
633
- */
634
- interface EmbeddingResult {
635
- /** Embeddings in same order as inputs */
636
- embeddings: Embedding[];
637
- /** Usage statistics */
638
- usage: EmbeddingUsage;
639
- /** Provider-specific response metadata */
640
- metadata?: Record<string, unknown>;
641
- }
642
- /**
643
- * Progress update when using chunked mode.
644
- */
645
- interface EmbeddingProgress {
646
- /** Embeddings from the latest batch */
647
- embeddings: Embedding[];
648
- /** Total embeddings completed so far */
649
- completed: number;
650
- /** Total number of inputs */
651
- total: number;
652
- /** Percentage complete (0-100) */
653
- percent: number;
654
- }
655
- /**
656
- * Async iterable stream with final result accessor.
657
- * Returned when embed() is called with { chunked: true }.
658
- */
659
- interface EmbeddingStream extends AsyncIterable<EmbeddingProgress> {
660
- /** Promise resolving to complete result after iteration */
661
- readonly result: Promise<EmbeddingResult>;
662
- /** Abort the operation */
663
- abort(): void;
664
- }
665
- /**
666
- * Embedding instance returned by the embedding() function.
667
- *
668
- * @typeParam TParams - Provider-specific parameter type
669
- *
670
- * @example
671
- * ```typescript
672
- * const embedder = embedding({ model: openai('text-embedding-3-large') });
673
- *
674
- * // Single input
675
- * const result = await embedder.embed('Hello world');
676
- *
677
- * // Batch input
678
- * const batch = await embedder.embed(['doc1', 'doc2', 'doc3']);
679
- *
680
- * // Large-scale with progress
681
- * const stream = embedder.embed(documents, { chunked: true });
682
- * for await (const progress of stream) {
683
- * console.log(`${progress.percent}% complete`);
684
- * }
685
- * ```
686
- */
687
- interface EmbeddingInstance<TParams = unknown> {
688
- /**
689
- * Generate embeddings for one or more inputs.
690
- *
691
- * @param input - Single input or array of inputs
692
- * @param options - Optional embed options
693
- * @returns Promise<EmbeddingResult> or EmbeddingStream if chunked
694
- */
695
- embed(input: EmbeddingInput | EmbeddingInput[], options?: EmbedOptions & {
696
- chunked?: false;
697
- }): Promise<EmbeddingResult>;
698
- embed(input: EmbeddingInput[], options: EmbedOptions & {
699
- chunked: true;
700
- }): EmbeddingStream;
701
- embed(input: EmbeddingInput | EmbeddingInput[], options?: EmbedOptions): Promise<EmbeddingResult> | EmbeddingStream;
702
- /** The bound embedding model */
703
- readonly model: BoundEmbeddingModel<TParams>;
704
- /** Current parameters */
705
- readonly params: TParams | undefined;
706
- }
707
-
708
553
  /**
709
554
  * @fileoverview Embedding instance factory for the Universal Provider Protocol.
710
555
  *
@@ -977,4 +822,4 @@ declare const ai: {
977
822
  image: typeof image;
978
823
  };
979
824
 
980
- export { AssistantContent, AssistantMessage, BoundEmbeddingModel, type BoundLLMModel, ContentBlock, type EmbedOptions, type Embedding, EmbeddingHandler, EmbeddingInput, type EmbeddingInstance, type EmbeddingModelInput, type EmbeddingOptions, type EmbeddingProgress, type EmbeddingResult, type EmbeddingStream, EmbeddingUsage, ImageInstance, ImageOptions, type InferenceInput, JSONSchema, type LLMCapabilities, type LLMHandler, type LLMInstance, type LLMOptions, LLMProvider, type LLMRequest, type LLMResponse, type LLMStreamResult, Message, MessageJSON, MessageType, ModelReference, Provider, ProviderConfig, ProviderIdentity, StreamEvent, StreamResult, Thread, type ThreadJSON, TokenUsage, Tool, ToolUseStrategy, Turn, UserContent, ai, createProvider, embedding, image, llm };
825
+ export { AssistantContent, AssistantMessage, type BoundLLMModel, ContentBlock, EmbeddingHandler, EmbeddingInstance, EmbeddingOptions, ImageInstance, ImageOptions, type InferenceInput, JSONSchema, type LLMCapabilities, type LLMHandler, type LLMInstance, type LLMOptions, LLMProvider, type LLMRequest, type LLMResponse, type LLMStreamResult, Message, MessageJSON, MessageType, ModelReference, Provider, ProviderConfig, ProviderIdentity, StreamEvent, StreamResult, Thread, type ThreadJSON, TokenUsage, Tool, ToolUseStrategy, Turn, UserContent, ai, createProvider, embedding, image, llm };
@@ -1,4 +1,4 @@
1
- import { g as Provider } from '../provider-x4RocsnK.js';
1
+ import { e as Provider } from '../provider-6-mJYOOl.js';
2
2
 
3
3
  /**
4
4
  * @fileoverview Type definitions for the Ollama provider.
@@ -1,4 +1,4 @@
1
- import { g as Provider } from '../provider-x4RocsnK.js';
1
+ import { e as Provider } from '../provider-6-mJYOOl.js';
2
2
 
3
3
  /**
4
4
  * @fileoverview OpenAI Provider Type Definitions
@@ -1,4 +1,4 @@
1
- import { g as Provider } from '../provider-x4RocsnK.js';
1
+ import { e as Provider } from '../provider-6-mJYOOl.js';
2
2
 
3
3
  /**
4
4
  * OpenRouter-specific types for the Unified Provider Protocol.
@@ -1471,4 +1471,4 @@ type ImageProvider<TParams = unknown, TOptions = unknown> = Provider<TOptions> &
1471
1471
  readonly __params?: TParams;
1472
1472
  };
1473
1473
 
1474
- export { type ImageCapabilities as $, type AssistantContent as A, type BoundEmbeddingModel as B, type ContentBlock as C, type RetryStrategy as D, type EmbeddingInput as E, type EmbeddingProvider as F, type ImageProvider as G, type EmbeddingRequest as H, type ImageOptions as I, type EmbeddingResponse as J, type KeyStrategy as K, type LLMProvider as L, type ModelReference as M, type EmbeddingVector as N, type ImageInput as O, type ProviderIdentity as P, type ImageEditInput as Q, type ReasoningBlock as R, type ImageGenerateOptions as S, type TextBlock as T, type UserContent as U, type VideoBlock as V, type GeneratedImage as W, type ImageUsage as X, type ImageResult as Y, type ImageStreamEvent as Z, type ImageStreamResult as _, type ProviderConfig as a, type ImageRequest as a0, type ImageEditRequest as a1, type ImageResponse as a2, type ImageProviderStreamResult as a3, type BoundImageModel as a4, type ImageHandler$1 as a5, type ImageModelInput as a6, type EmbeddingUsage as b, type ImageInstance as c, type LLMHandler as d, type EmbeddingHandler as e, type ImageHandler as f, type Provider as g, Image as h, UPPError as i, ErrorCode as j, ModalityType as k, type Modality as l, type ImageBlock as m, type AudioBlock as n, type BinaryBlock as o, type ImageSource as p, ContentBlockType as q, ImageSourceType as r, reasoning as s, text as t, isTextBlock as u, isReasoningBlock as v, isImageBlock as w, isAudioBlock as x, isVideoBlock as y, isBinaryBlock as z };
1474
+ export { type ImageCapabilities as $, type AssistantContent as A, type BinaryBlock as B, type ContentBlock as C, type BoundEmbeddingModel as D, type EmbeddingHandler as E, type EmbeddingRequest as F, type EmbeddingResponse as G, type EmbeddingVector as H, type ImageOptions as I, type EmbeddingUsage as J, type KeyStrategy as K, type LLMProvider as L, type ModelReference as M, type EmbeddingInput as N, type ImageInput as O, type ProviderIdentity as P, type ImageEditInput as Q, type ReasoningBlock as R, type ImageGenerateOptions as S, type TextBlock as T, type UserContent as U, type VideoBlock as V, type GeneratedImage as W, type ImageUsage as X, type ImageResult as Y, type ImageStreamEvent as Z, type ImageStreamResult as _, type ProviderConfig as a, type ImageRequest as a0, type ImageEditRequest as a1, type ImageResponse as a2, type ImageProviderStreamResult as a3, type BoundImageModel as a4, type ImageHandler$1 as a5, type ImageModelInput as a6, type ImageInstance as b, type LLMHandler as c, type ImageHandler as d, type Provider as e, Image as f, UPPError as g, ErrorCode as h, ModalityType as i, type Modality as j, type ImageBlock as k, type AudioBlock as l, type ImageSource as m, ContentBlockType as n, ImageSourceType as o, isTextBlock as p, isReasoningBlock as q, reasoning as r, isImageBlock as s, text as t, isAudioBlock as u, isVideoBlock as v, isBinaryBlock as w, type RetryStrategy as x, type EmbeddingProvider as y, type ImageProvider as z };
@@ -1,5 +1,5 @@
1
- import { g as Provider, M as ModelReference } from '../provider-x4RocsnK.js';
2
- import { M as Message, b as MessageJSON, T as Turn, I as TurnJSON, f as StreamEvent, S as StreamResult, J as JSONSchema, k as ToolMetadata, c as Tool } from '../stream-ITNFNnO4.js';
1
+ import { _ as ImageStreamResult, a3 as ImageProviderStreamResult, Y as ImageResult, f as Image, N as EmbeddingInput, e as Provider, M as ModelReference } from '../provider-6-mJYOOl.js';
2
+ import { M as Message, b as MessageJSON, T as Turn, V as TurnJSON, f as StreamEvent, O as EmbeddingResult, S as StreamResult, J as JSONSchema, l as ToolMetadata, c as Tool } from '../embedding-CK5oa38O.js';
3
3
 
4
4
  /**
5
5
  * @fileoverview Proxy provider types.
@@ -19,6 +19,26 @@ interface ProxyLLMParams {
19
19
  /** Parameters are passed through to the backend */
20
20
  [key: string]: unknown;
21
21
  }
22
+ /**
23
+ * Proxy-specific embedding parameters.
24
+ *
25
+ * These parameters are passed through to the backend server.
26
+ * The server decides how to interpret them based on its own provider.
27
+ */
28
+ interface ProxyEmbeddingParams {
29
+ /** Parameters are passed through to the backend */
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * Proxy-specific image parameters.
34
+ *
35
+ * These parameters are passed through to the backend server.
36
+ * The server decides how to interpret them based on its own provider.
37
+ */
38
+ interface ProxyImageParams {
39
+ /** Parameters are passed through to the backend */
40
+ [key: string]: unknown;
41
+ }
22
42
  /**
23
43
  * Configuration options for creating a proxy provider.
24
44
  */
@@ -72,6 +92,14 @@ declare function serializeStreamEvent(event: StreamEvent): StreamEvent;
72
92
  */
73
93
  declare function deserializeStreamEvent(event: StreamEvent): StreamEvent;
74
94
 
95
+ /**
96
+ * @fileoverview Image stream helpers for proxy server adapters.
97
+ *
98
+ * @module providers/proxy/server/image-stream
99
+ */
100
+
101
+ type ImageStreamLike = ImageStreamResult | ImageProviderStreamResult;
102
+
75
103
  /**
76
104
  * @fileoverview H3/Nitro/Nuxt adapter for proxy server.
77
105
  *
@@ -107,6 +135,22 @@ interface H3Event {
107
135
  * ```
108
136
  */
109
137
  declare function sendJSON$2(turn: Turn, event: H3Event): unknown;
138
+ /**
139
+ * Send an EmbeddingResult as JSON response.
140
+ *
141
+ * @param result - The embedding result
142
+ * @param event - H3 event object
143
+ * @returns Serialized result data
144
+ */
145
+ declare function sendEmbeddingJSON$2(result: EmbeddingResult, event: H3Event): unknown;
146
+ /**
147
+ * Send an ImageResult as JSON response.
148
+ *
149
+ * @param result - The image result
150
+ * @param event - H3 event object
151
+ * @returns Serialized image result data
152
+ */
153
+ declare function sendImageJSON$2(result: ImageResult, event: H3Event): unknown;
110
154
  /**
111
155
  * Stream a StreamResult as Server-Sent Events.
112
156
  *
@@ -120,6 +164,13 @@ declare function sendJSON$2(turn: Turn, event: H3Event): unknown;
120
164
  * ```
121
165
  */
122
166
  declare function streamSSE$2(stream: StreamResult, event: H3Event): void;
167
+ /**
168
+ * Stream an ImageStreamResult as Server-Sent Events.
169
+ *
170
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
171
+ * @param event - H3 event object
172
+ */
173
+ declare function streamImageSSE$2(stream: ImageStreamLike, event: H3Event): void;
123
174
  /**
124
175
  * Create a ReadableStream for H3's sendStream utility.
125
176
  *
@@ -133,6 +184,13 @@ declare function streamSSE$2(stream: StreamResult, event: H3Event): void;
133
184
  * @returns A ReadableStream of SSE data
134
185
  */
135
186
  declare function createSSEStream(stream: StreamResult): ReadableStream<Uint8Array>;
187
+ /**
188
+ * Create a ReadableStream for image SSE data.
189
+ *
190
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
191
+ * @returns A ReadableStream of SSE data
192
+ */
193
+ declare function createImageSSEStream(stream: ImageStreamLike): ReadableStream<Uint8Array>;
136
194
  /**
137
195
  * Send an error response.
138
196
  *
@@ -216,8 +274,12 @@ declare function sendError$2(message: string, status: number, event: H3Event): {
216
274
  */
217
275
  declare const h3: {
218
276
  sendJSON: typeof sendJSON$2;
277
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$2;
278
+ sendImageJSON: typeof sendImageJSON$2;
219
279
  streamSSE: typeof streamSSE$2;
280
+ streamImageSSE: typeof streamImageSSE$2;
220
281
  createSSEStream: typeof createSSEStream;
282
+ createImageSSEStream: typeof createImageSSEStream;
221
283
  sendError: typeof sendError$2;
222
284
  };
223
285
 
@@ -255,6 +317,20 @@ interface FastifyReply {
255
317
  * ```
256
318
  */
257
319
  declare function sendJSON$1(turn: Turn, reply: FastifyReply): FastifyReply;
320
+ /**
321
+ * Send an EmbeddingResult as JSON response.
322
+ *
323
+ * @param result - The embedding result
324
+ * @param reply - Fastify reply object
325
+ */
326
+ declare function sendEmbeddingJSON$1(result: EmbeddingResult, reply: FastifyReply): FastifyReply;
327
+ /**
328
+ * Send an ImageResult as JSON response.
329
+ *
330
+ * @param result - The image result
331
+ * @param reply - Fastify reply object
332
+ */
333
+ declare function sendImageJSON$1(result: ImageResult, reply: FastifyReply): FastifyReply;
258
334
  /**
259
335
  * Stream a StreamResult as Server-Sent Events.
260
336
  *
@@ -268,6 +344,13 @@ declare function sendJSON$1(turn: Turn, reply: FastifyReply): FastifyReply;
268
344
  * ```
269
345
  */
270
346
  declare function streamSSE$1(stream: StreamResult, reply: FastifyReply): FastifyReply;
347
+ /**
348
+ * Stream an ImageStreamResult as Server-Sent Events.
349
+ *
350
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
351
+ * @param reply - Fastify reply object
352
+ */
353
+ declare function streamImageSSE$1(stream: ImageStreamLike, reply: FastifyReply): FastifyReply;
271
354
  /**
272
355
  * Send an error response.
273
356
  *
@@ -349,7 +432,10 @@ declare function sendError$1(message: string, status: number, reply: FastifyRepl
349
432
  */
350
433
  declare const fastify: {
351
434
  sendJSON: typeof sendJSON$1;
435
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$1;
436
+ sendImageJSON: typeof sendImageJSON$1;
352
437
  streamSSE: typeof streamSSE$1;
438
+ streamImageSSE: typeof streamImageSSE$1;
353
439
  sendError: typeof sendError$1;
354
440
  };
355
441
 
@@ -385,6 +471,20 @@ interface ExpressResponse {
385
471
  * ```
386
472
  */
387
473
  declare function sendJSON(turn: Turn, res: ExpressResponse): void;
474
+ /**
475
+ * Send an EmbeddingResult as JSON response.
476
+ *
477
+ * @param result - The embedding result
478
+ * @param res - Express response object
479
+ */
480
+ declare function sendEmbeddingJSON(result: EmbeddingResult, res: ExpressResponse): void;
481
+ /**
482
+ * Send an ImageResult as JSON response.
483
+ *
484
+ * @param result - The image result
485
+ * @param res - Express response object
486
+ */
487
+ declare function sendImageJSON(result: ImageResult, res: ExpressResponse): void;
388
488
  /**
389
489
  * Stream a StreamResult as Server-Sent Events.
390
490
  *
@@ -398,6 +498,13 @@ declare function sendJSON(turn: Turn, res: ExpressResponse): void;
398
498
  * ```
399
499
  */
400
500
  declare function streamSSE(stream: StreamResult, res: ExpressResponse): void;
501
+ /**
502
+ * Stream an ImageStreamResult as Server-Sent Events.
503
+ *
504
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
505
+ * @param res - Express response object
506
+ */
507
+ declare function streamImageSSE(stream: ImageStreamLike, res: ExpressResponse): void;
401
508
  /**
402
509
  * Send an error response.
403
510
  *
@@ -480,10 +587,43 @@ declare function sendError(message: string, status: number, res: ExpressResponse
480
587
  */
481
588
  declare const express: {
482
589
  sendJSON: typeof sendJSON;
590
+ sendEmbeddingJSON: typeof sendEmbeddingJSON;
591
+ sendImageJSON: typeof sendImageJSON;
483
592
  streamSSE: typeof streamSSE;
593
+ streamImageSSE: typeof streamImageSSE;
484
594
  sendError: typeof sendError;
485
595
  };
486
596
 
597
+ /**
598
+ * @fileoverview Media serialization utilities for proxy transport.
599
+ *
600
+ * Handles converting embedding inputs and image results/events to/from JSON
601
+ * for HTTP transport. These are pure functions with no side effects.
602
+ *
603
+ * @module providers/proxy/serialization.media
604
+ */
605
+
606
+ type SerializedImageSource = {
607
+ type: 'base64';
608
+ data: string;
609
+ } | {
610
+ type: 'url';
611
+ url: string;
612
+ } | {
613
+ type: 'bytes';
614
+ data: number[] | string;
615
+ };
616
+ interface SerializedImage {
617
+ source: SerializedImageSource;
618
+ mimeType: string;
619
+ width?: number;
620
+ height?: number;
621
+ }
622
+ /**
623
+ * Deserialize an Image from JSON transport.
624
+ */
625
+ declare function deserializeImage(image: SerializedImage): Image;
626
+
487
627
  /**
488
628
  * @fileoverview Web API adapter for proxy server.
489
629
  *
@@ -504,6 +644,7 @@ interface ParsedRequest {
504
644
  messages: Message[];
505
645
  system?: string | unknown[];
506
646
  params?: Record<string, unknown>;
647
+ model?: string;
507
648
  tools?: Array<{
508
649
  name: string;
509
650
  description: string;
@@ -512,6 +653,24 @@ interface ParsedRequest {
512
653
  }>;
513
654
  structure?: JSONSchema;
514
655
  }
656
+ /**
657
+ * Parsed request body for embedding endpoints.
658
+ */
659
+ interface ParsedEmbeddingRequest {
660
+ inputs: EmbeddingInput[];
661
+ params?: Record<string, unknown>;
662
+ model?: string;
663
+ }
664
+ /**
665
+ * Parsed request body for image endpoints.
666
+ */
667
+ interface ParsedImageRequest {
668
+ prompt: string;
669
+ params?: Record<string, unknown>;
670
+ model?: string;
671
+ image?: ReturnType<typeof deserializeImage>;
672
+ mask?: ReturnType<typeof deserializeImage>;
673
+ }
515
674
  /**
516
675
  * Parse an HTTP request body into PP types.
517
676
  *
@@ -528,6 +687,20 @@ interface ParsedRequest {
528
687
  * ```
529
688
  */
530
689
  declare function parseBody(body: unknown): ParsedRequest;
690
+ /**
691
+ * Parse an HTTP request body into embedding inputs.
692
+ *
693
+ * @param body - The JSON-parsed request body
694
+ * @returns Parsed embedding request data
695
+ */
696
+ declare function parseEmbeddingBody(body: unknown): ParsedEmbeddingRequest;
697
+ /**
698
+ * Parse an HTTP request body into image request data.
699
+ *
700
+ * @param body - The JSON-parsed request body
701
+ * @returns Parsed image request data
702
+ */
703
+ declare function parseImageBody(body: unknown): ParsedImageRequest;
531
704
  /**
532
705
  * Create a JSON Response from a Turn.
533
706
  *
@@ -541,6 +714,20 @@ declare function parseBody(body: unknown): ParsedRequest;
541
714
  * ```
542
715
  */
543
716
  declare function toJSON(turn: Turn): Response;
717
+ /**
718
+ * Create a JSON Response from an embedding result.
719
+ *
720
+ * @param result - The embedding result
721
+ * @returns HTTP Response with JSON body
722
+ */
723
+ declare function toEmbeddingJSON(result: EmbeddingResult): Response;
724
+ /**
725
+ * Create a JSON Response from an image result.
726
+ *
727
+ * @param result - The image result
728
+ * @returns HTTP Response with JSON body
729
+ */
730
+ declare function toImageJSON(result: ImageResult): Response;
544
731
  /**
545
732
  * Create an SSE Response from a StreamResult.
546
733
  *
@@ -556,6 +743,15 @@ declare function toJSON(turn: Turn): Response;
556
743
  * ```
557
744
  */
558
745
  declare function toSSE(stream: StreamResult): Response;
746
+ /**
747
+ * Create an SSE Response from an ImageStreamResult.
748
+ *
749
+ * Streams image events as SSE, then sends the final image result.
750
+ *
751
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
752
+ * @returns HTTP Response with SSE body
753
+ */
754
+ declare function toImageSSE(stream: ImageStreamLike): Response;
559
755
  /**
560
756
  * Create an error Response.
561
757
  *
@@ -659,8 +855,13 @@ declare function bindTools(schemas: ParsedRequest['tools'], implementations: Rec
659
855
  */
660
856
  declare const webapi: {
661
857
  parseBody: typeof parseBody;
858
+ parseEmbeddingBody: typeof parseEmbeddingBody;
859
+ parseImageBody: typeof parseImageBody;
662
860
  toJSON: typeof toJSON;
861
+ toEmbeddingJSON: typeof toEmbeddingJSON;
862
+ toImageJSON: typeof toImageJSON;
663
863
  toSSE: typeof toSSE;
864
+ toImageSSE: typeof toImageSSE;
664
865
  toError: typeof toError;
665
866
  bindTools: typeof bindTools;
666
867
  };
@@ -678,6 +879,7 @@ interface ParsedBody {
678
879
  messages: Message[];
679
880
  system?: string | unknown[];
680
881
  params?: Record<string, unknown>;
882
+ model?: string;
681
883
  tools?: Array<{
682
884
  name: string;
683
885
  description: string;
@@ -760,28 +962,43 @@ declare const server: {
760
962
  /** Web API adapter (Bun, Deno, Next.js, Workers) */
761
963
  webapi: {
762
964
  parseBody: typeof parseBody;
965
+ parseEmbeddingBody: typeof parseEmbeddingBody;
966
+ parseImageBody: typeof parseImageBody;
763
967
  toJSON: typeof toJSON;
968
+ toEmbeddingJSON: typeof toEmbeddingJSON;
969
+ toImageJSON: typeof toImageJSON;
764
970
  toSSE: typeof toSSE;
971
+ toImageSSE: typeof toImageSSE;
765
972
  toError: typeof toError;
766
973
  bindTools: typeof bindTools;
767
974
  };
768
975
  /** Express/Connect adapter */
769
976
  express: {
770
977
  sendJSON: typeof sendJSON;
978
+ sendEmbeddingJSON: typeof sendEmbeddingJSON;
979
+ sendImageJSON: typeof sendImageJSON;
771
980
  streamSSE: typeof streamSSE;
981
+ streamImageSSE: typeof streamImageSSE;
772
982
  sendError: typeof sendError;
773
983
  };
774
984
  /** Fastify adapter */
775
985
  fastify: {
776
986
  sendJSON: typeof sendJSON$1;
987
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$1;
988
+ sendImageJSON: typeof sendImageJSON$1;
777
989
  streamSSE: typeof streamSSE$1;
990
+ streamImageSSE: typeof streamImageSSE$1;
778
991
  sendError: typeof sendError$1;
779
992
  };
780
993
  /** H3/Nitro/Nuxt adapter */
781
994
  h3: {
782
995
  sendJSON: typeof sendJSON$2;
996
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$2;
997
+ sendImageJSON: typeof sendImageJSON$2;
783
998
  streamSSE: typeof streamSSE$2;
999
+ streamImageSSE: typeof streamImageSSE$2;
784
1000
  createSSEStream: typeof createSSEStream;
1001
+ createImageSSEStream: typeof createImageSSEStream;
785
1002
  sendError: typeof sendError$2;
786
1003
  };
787
1004
  };
@@ -831,4 +1048,4 @@ declare function proxy(options: ProxyProviderOptions): Provider<ProxyRequestOpti
831
1048
  */
832
1049
  declare function proxyModel(endpoint: string): ModelReference<ProxyRequestOptions>;
833
1050
 
834
- export { type AdapterOptions, type ParsedBody, type ParsedRequest, type ProxyHandler, type ProxyLLMParams, type ProxyProviderOptions, type ProxyRequestOptions, type RequestMeta, TurnJSON, bindTools, deserializeMessage, deserializeStreamEvent, express, fastify, h3, parseBody, proxy, proxyModel, serializeMessage, serializeStreamEvent, serializeTurn, server, toError, toJSON, toSSE, webapi };
1051
+ export { type AdapterOptions, type ParsedBody, type ParsedEmbeddingRequest, type ParsedImageRequest, type ParsedRequest, type ProxyEmbeddingParams, type ProxyHandler, type ProxyImageParams, type ProxyLLMParams, type ProxyProviderOptions, type ProxyRequestOptions, type RequestMeta, TurnJSON, bindTools, deserializeMessage, deserializeStreamEvent, express, fastify, h3, parseBody, parseEmbeddingBody, parseImageBody, proxy, proxyModel, serializeMessage, serializeStreamEvent, serializeTurn, server, toEmbeddingJSON, toError, toImageJSON, toImageSSE, toJSON, toSSE, webapi };