@umituz/web-ai 1.0.5 → 1.0.7

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.
@@ -438,4 +438,73 @@ declare class PrunaProvider implements IMediaProvider {
438
438
  }
439
439
  declare function createPrunaProvider(config: PrunaConfig): PrunaProvider;
440
440
 
441
- export { API_ENDPOINTS, AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, type AppContainer, AuthenticationError, BaseProvider as BaseAIProvider, BaseProvider, type BaseProviderConfig, CostEstimateRequest, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerateOptions, GenerationFailedError, GenerationStage, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqConfigStore, GroqGenerationConfig, GroqHttpClient, type GroqHttpClientDeps, GroqHttpTransport, GroqMessage, GroqMessageRole, GroqProvider, GroqProviderConfig, GroqReasoningEffort, IGroqHttpClient, IMediaProvider, ITextProvider, ProviderError, PrunaInput, PrunaModelId, PrunaPredictionResponse, type PrunaProgressStage, PrunaProvider, type PrunaRequest, PrunaResult, StreamRequestOptions$1 as StreamRequestOptions, type StructuredJsonRequest, TIMEOUTS, TextGenerationService, TextToVideoInput, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAssistantMessage, createFalProvider, createGeminiProvider, createGroqProvider, createMessage, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
441
+ interface EmbeddingsRequest {
442
+ readonly externalModelId: string;
443
+ readonly input: ReadonlyArray<string>;
444
+ }
445
+ interface EmbeddingsResult {
446
+ readonly vectors: number[][];
447
+ readonly inputTokens: number | null;
448
+ }
449
+ interface EmbeddingsAdapter {
450
+ embed(req: EmbeddingsRequest): Promise<EmbeddingsResult>;
451
+ }
452
+ interface OpenAiCompatibleConfig {
453
+ readonly baseUrl: string;
454
+ readonly apiKey: string;
455
+ readonly timeoutMs?: number;
456
+ }
457
+ declare function createOpenAiEmbeddingsAdapter(config: OpenAiCompatibleConfig): EmbeddingsAdapter;
458
+
459
+ interface AudioTranscriptionRequest {
460
+ readonly externalModelId: string;
461
+ readonly audio: Uint8Array;
462
+ readonly mimeType: string;
463
+ readonly name: string;
464
+ }
465
+ interface AudioTranscriptionResult {
466
+ readonly text: string;
467
+ }
468
+ interface AudioTranscriptionAdapter {
469
+ transcribe(req: AudioTranscriptionRequest): Promise<AudioTranscriptionResult>;
470
+ }
471
+ declare function createOpenAiAudioTranscriptionAdapter(config: OpenAiCompatibleConfig): AudioTranscriptionAdapter;
472
+
473
+ declare const SPEECH_VOICES: readonly ["tara", "leah", "jess", "julian", "annie", "steve", "zac", "bella"];
474
+ type SpeechVoice = (typeof SPEECH_VOICES)[number];
475
+ declare const SPEECH_INPUT_MAX = 4000;
476
+ interface SpeechRequest {
477
+ readonly externalModelId: string;
478
+ readonly input: string;
479
+ readonly voice: SpeechVoice;
480
+ }
481
+ interface SpeechResult {
482
+ readonly audio: Uint8Array;
483
+ readonly mimeType: string;
484
+ }
485
+ interface SpeechAdapter {
486
+ speak(req: SpeechRequest): Promise<SpeechResult>;
487
+ }
488
+ declare function createOpenAiSpeechAdapter(config: OpenAiCompatibleConfig): SpeechAdapter;
489
+
490
+ interface ImageRequest {
491
+ readonly externalModelId: string;
492
+ readonly prompt: string;
493
+ readonly size: string;
494
+ readonly quality: string;
495
+ }
496
+ interface ImageResult {
497
+ readonly images: ReadonlyArray<string>;
498
+ readonly usage: TokenUsage | null;
499
+ }
500
+ interface ImageAdapter {
501
+ generate(req: ImageRequest): Promise<ImageResult>;
502
+ }
503
+ declare const IMAGE_SIZES: readonly ["1024x1024", "1536x1024", "1024x1536"];
504
+ declare const IMAGE_QUALITIES: readonly ["auto", "low", "medium", "high", "xhigh", "max"];
505
+ type ImageSize = (typeof IMAGE_SIZES)[number];
506
+ type ImageQuality = (typeof IMAGE_QUALITIES)[number];
507
+ declare const IMAGE_B64_LIMIT = 12000000;
508
+ declare function createOpenAiImageAdapter(config: OpenAiCompatibleConfig): ImageAdapter;
509
+
510
+ export { API_ENDPOINTS, AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, type AppContainer, type AudioTranscriptionAdapter, type AudioTranscriptionRequest, type AudioTranscriptionResult, AuthenticationError, BaseProvider as BaseAIProvider, BaseProvider, type BaseProviderConfig, CostEstimateRequest, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, type EmbeddingsAdapter, type EmbeddingsRequest, type EmbeddingsResult, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerateOptions, GenerationFailedError, GenerationStage, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqConfigStore, GroqGenerationConfig, GroqHttpClient, type GroqHttpClientDeps, GroqHttpTransport, GroqMessage, GroqMessageRole, GroqProvider, GroqProviderConfig, GroqReasoningEffort, IGroqHttpClient, IMAGE_B64_LIMIT, IMAGE_QUALITIES, IMAGE_SIZES, IMediaProvider, ITextProvider, type ImageAdapter, type ImageQuality, type ImageRequest, type ImageResult, type ImageSize, type OpenAiCompatibleConfig, ProviderError, PrunaInput, PrunaModelId, PrunaPredictionResponse, type PrunaProgressStage, PrunaProvider, type PrunaRequest, PrunaResult, SPEECH_INPUT_MAX, SPEECH_VOICES, type SpeechAdapter, type SpeechRequest, type SpeechResult, type SpeechVoice, StreamRequestOptions$1 as StreamRequestOptions, type StructuredJsonRequest, TIMEOUTS, TextGenerationService, TextToVideoInput, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAssistantMessage, createFalProvider, createGeminiProvider, createGroqProvider, createMessage, createOpenAiAudioTranscriptionAdapter, createOpenAiEmbeddingsAdapter, createOpenAiImageAdapter, createOpenAiSpeechAdapter, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
@@ -438,4 +438,73 @@ declare class PrunaProvider implements IMediaProvider {
438
438
  }
439
439
  declare function createPrunaProvider(config: PrunaConfig): PrunaProvider;
440
440
 
441
- export { API_ENDPOINTS, AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, type AppContainer, AuthenticationError, BaseProvider as BaseAIProvider, BaseProvider, type BaseProviderConfig, CostEstimateRequest, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerateOptions, GenerationFailedError, GenerationStage, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqConfigStore, GroqGenerationConfig, GroqHttpClient, type GroqHttpClientDeps, GroqHttpTransport, GroqMessage, GroqMessageRole, GroqProvider, GroqProviderConfig, GroqReasoningEffort, IGroqHttpClient, IMediaProvider, ITextProvider, ProviderError, PrunaInput, PrunaModelId, PrunaPredictionResponse, type PrunaProgressStage, PrunaProvider, type PrunaRequest, PrunaResult, StreamRequestOptions$1 as StreamRequestOptions, type StructuredJsonRequest, TIMEOUTS, TextGenerationService, TextToVideoInput, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAssistantMessage, createFalProvider, createGeminiProvider, createGroqProvider, createMessage, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
441
+ interface EmbeddingsRequest {
442
+ readonly externalModelId: string;
443
+ readonly input: ReadonlyArray<string>;
444
+ }
445
+ interface EmbeddingsResult {
446
+ readonly vectors: number[][];
447
+ readonly inputTokens: number | null;
448
+ }
449
+ interface EmbeddingsAdapter {
450
+ embed(req: EmbeddingsRequest): Promise<EmbeddingsResult>;
451
+ }
452
+ interface OpenAiCompatibleConfig {
453
+ readonly baseUrl: string;
454
+ readonly apiKey: string;
455
+ readonly timeoutMs?: number;
456
+ }
457
+ declare function createOpenAiEmbeddingsAdapter(config: OpenAiCompatibleConfig): EmbeddingsAdapter;
458
+
459
+ interface AudioTranscriptionRequest {
460
+ readonly externalModelId: string;
461
+ readonly audio: Uint8Array;
462
+ readonly mimeType: string;
463
+ readonly name: string;
464
+ }
465
+ interface AudioTranscriptionResult {
466
+ readonly text: string;
467
+ }
468
+ interface AudioTranscriptionAdapter {
469
+ transcribe(req: AudioTranscriptionRequest): Promise<AudioTranscriptionResult>;
470
+ }
471
+ declare function createOpenAiAudioTranscriptionAdapter(config: OpenAiCompatibleConfig): AudioTranscriptionAdapter;
472
+
473
+ declare const SPEECH_VOICES: readonly ["tara", "leah", "jess", "julian", "annie", "steve", "zac", "bella"];
474
+ type SpeechVoice = (typeof SPEECH_VOICES)[number];
475
+ declare const SPEECH_INPUT_MAX = 4000;
476
+ interface SpeechRequest {
477
+ readonly externalModelId: string;
478
+ readonly input: string;
479
+ readonly voice: SpeechVoice;
480
+ }
481
+ interface SpeechResult {
482
+ readonly audio: Uint8Array;
483
+ readonly mimeType: string;
484
+ }
485
+ interface SpeechAdapter {
486
+ speak(req: SpeechRequest): Promise<SpeechResult>;
487
+ }
488
+ declare function createOpenAiSpeechAdapter(config: OpenAiCompatibleConfig): SpeechAdapter;
489
+
490
+ interface ImageRequest {
491
+ readonly externalModelId: string;
492
+ readonly prompt: string;
493
+ readonly size: string;
494
+ readonly quality: string;
495
+ }
496
+ interface ImageResult {
497
+ readonly images: ReadonlyArray<string>;
498
+ readonly usage: TokenUsage | null;
499
+ }
500
+ interface ImageAdapter {
501
+ generate(req: ImageRequest): Promise<ImageResult>;
502
+ }
503
+ declare const IMAGE_SIZES: readonly ["1024x1024", "1536x1024", "1024x1536"];
504
+ declare const IMAGE_QUALITIES: readonly ["auto", "low", "medium", "high", "xhigh", "max"];
505
+ type ImageSize = (typeof IMAGE_SIZES)[number];
506
+ type ImageQuality = (typeof IMAGE_QUALITIES)[number];
507
+ declare const IMAGE_B64_LIMIT = 12000000;
508
+ declare function createOpenAiImageAdapter(config: OpenAiCompatibleConfig): ImageAdapter;
509
+
510
+ export { API_ENDPOINTS, AnthropicEffort, AnthropicHttpTransport, AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicProvider, AnthropicProviderConfig, AnthropicRequestBuilder, AnthropicStopReason, type AppContainer, type AudioTranscriptionAdapter, type AudioTranscriptionRequest, type AudioTranscriptionResult, AuthenticationError, BaseProvider as BaseAIProvider, BaseProvider, type BaseProviderConfig, CostEstimateRequest, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, type EmbeddingsAdapter, type EmbeddingsRequest, type EmbeddingsResult, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerateOptions, GenerationFailedError, GenerationStage, GroqChatRequest, GroqChatRequestBuilder, GroqChatResponse, GroqConfigStore, GroqGenerationConfig, GroqHttpClient, type GroqHttpClientDeps, GroqHttpTransport, GroqMessage, GroqMessageRole, GroqProvider, GroqProviderConfig, GroqReasoningEffort, IGroqHttpClient, IMAGE_B64_LIMIT, IMAGE_QUALITIES, IMAGE_SIZES, IMediaProvider, ITextProvider, type ImageAdapter, type ImageQuality, type ImageRequest, type ImageResult, type ImageSize, type OpenAiCompatibleConfig, ProviderError, PrunaInput, PrunaModelId, PrunaPredictionResponse, type PrunaProgressStage, PrunaProvider, type PrunaRequest, PrunaResult, SPEECH_INPUT_MAX, SPEECH_VOICES, type SpeechAdapter, type SpeechRequest, type SpeechResult, type SpeechVoice, StreamRequestOptions$1 as StreamRequestOptions, type StructuredJsonRequest, TIMEOUTS, TextGenerationService, TextToVideoInput, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAssistantMessage, createFalProvider, createGeminiProvider, createGroqProvider, createMessage, createOpenAiAudioTranscriptionAdapter, createOpenAiEmbeddingsAdapter, createOpenAiImageAdapter, createOpenAiSpeechAdapter, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
@@ -3974,6 +3974,193 @@ function resetProvider() {
3974
3974
  container = null;
3975
3975
  }
3976
3976
 
3977
- export { ANTHROPIC_API_VERSION, ANTHROPIC_DEFAULT_MAX_TOKENS, ANTHROPIC_MODELS, ANTHROPIC_TIERS, API_ENDPOINTS, AnthropicHttpTransport, AnthropicProvider, AnthropicRequestBuilder, AuthenticationError, BaseProvider as BaseAIProvider, BaseProvider, CancellationError, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerationFailedError, GroqChatRequestBuilder, GroqConfigStore, GroqHttpClient, GroqHttpTransport, GroqProvider, ProviderError, ProviderFactory, PrunaProvider, TIMEOUTS, TextGenerationService, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAI, createAssistantMessage, createFalProvider, createGeminiProvider, createGroqProvider, createMessage, createProviderFactory, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, isMediaProvider, isTextProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
3977
+ // src/providers/embeddings/openai-embeddings.ts
3978
+ var DEFAULT_EMBED_TIMEOUT_MS = 6e4;
3979
+ function createOpenAiEmbeddingsAdapter(config) {
3980
+ return {
3981
+ async embed(req) {
3982
+ const response = await fetch(`${config.baseUrl}/embeddings`, {
3983
+ method: "POST",
3984
+ headers: {
3985
+ Authorization: `Bearer ${config.apiKey}`,
3986
+ "Content-Type": "application/json"
3987
+ },
3988
+ body: JSON.stringify({ model: req.externalModelId, input: req.input }),
3989
+ signal: AbortSignal.timeout(config.timeoutMs ?? DEFAULT_EMBED_TIMEOUT_MS)
3990
+ });
3991
+ if (!response.ok) {
3992
+ let detail;
3993
+ try {
3994
+ const parsed2 = await response.json();
3995
+ detail = typeof parsed2.error?.message === "string" ? parsed2.error.message : void 0;
3996
+ } catch {
3997
+ detail = void 0;
3998
+ }
3999
+ throw new Error(detail ?? `Embeddings upstream failed with HTTP ${response.status}`);
4000
+ }
4001
+ const parsed = await response.json();
4002
+ const items = Array.isArray(parsed.data) ? parsed.data : [];
4003
+ const byIndex = /* @__PURE__ */ new Map();
4004
+ for (const item of items) {
4005
+ if (typeof item.index !== "number" || !Array.isArray(item.embedding)) continue;
4006
+ byIndex.set(item.index, item.embedding);
4007
+ }
4008
+ const vectors = [];
4009
+ for (let i = 0; i < req.input.length; i += 1) {
4010
+ const vector = byIndex.get(i);
4011
+ if (!vector) throw new Error("Provider returned an incomplete embeddings batch");
4012
+ vectors.push(vector);
4013
+ }
4014
+ const inputTokens = typeof parsed.usage?.prompt_tokens === "number" ? parsed.usage.prompt_tokens : null;
4015
+ return { vectors, inputTokens };
4016
+ }
4017
+ };
4018
+ }
4019
+
4020
+ // src/providers/audio/audio-transcription.ts
4021
+ function createOpenAiAudioTranscriptionAdapter(config) {
4022
+ return {
4023
+ async transcribe(req) {
4024
+ const form = new FormData();
4025
+ form.append("file", new Blob([req.audio], { type: req.mimeType }), req.name);
4026
+ form.append("model", req.externalModelId);
4027
+ form.append("response_format", "json");
4028
+ const response = await fetch(`${config.baseUrl}/audio/transcriptions`, {
4029
+ method: "POST",
4030
+ headers: { Authorization: `Bearer ${config.apiKey}` },
4031
+ body: form,
4032
+ signal: AbortSignal.timeout(config.timeoutMs ?? 6e4)
4033
+ });
4034
+ if (!response.ok) {
4035
+ let detail;
4036
+ try {
4037
+ const body2 = await response.json();
4038
+ detail = body2.error?.message;
4039
+ } catch {
4040
+ detail = void 0;
4041
+ }
4042
+ throw new Error(detail ?? `Audio transcription failed with HTTP ${response.status}`);
4043
+ }
4044
+ let body;
4045
+ try {
4046
+ body = await response.json();
4047
+ } catch {
4048
+ throw new Error("Transcription response was not valid JSON");
4049
+ }
4050
+ const text = (body.text ?? "").trim();
4051
+ if (text.length === 0) throw new Error("Transcription returned no text");
4052
+ return { text };
4053
+ }
4054
+ };
4055
+ }
4056
+
4057
+ // src/providers/audio/speech-synthesis.ts
4058
+ var SPEECH_VOICES = [
4059
+ "tara",
4060
+ "leah",
4061
+ "jess",
4062
+ "julian",
4063
+ "annie",
4064
+ "steve",
4065
+ "zac",
4066
+ "bella"
4067
+ ];
4068
+ var SPEECH_INPUT_MAX = 4e3;
4069
+ function createOpenAiSpeechAdapter(config) {
4070
+ return {
4071
+ async speak(req) {
4072
+ const response = await fetch(`${config.baseUrl}/audio/speech`, {
4073
+ method: "POST",
4074
+ headers: {
4075
+ Authorization: `Bearer ${config.apiKey}`,
4076
+ "Content-Type": "application/json"
4077
+ },
4078
+ body: JSON.stringify({
4079
+ model: req.externalModelId,
4080
+ input: req.input,
4081
+ voice: req.voice,
4082
+ response_format: "wav"
4083
+ }),
4084
+ signal: AbortSignal.timeout(config.timeoutMs ?? 6e4)
4085
+ });
4086
+ if (!response.ok) {
4087
+ let detail;
4088
+ try {
4089
+ const body = await response.json();
4090
+ detail = body.error?.message;
4091
+ } catch {
4092
+ detail = void 0;
4093
+ }
4094
+ throw new Error(detail ?? `Speech synthesis failed with HTTP ${response.status}`);
4095
+ }
4096
+ const audio = new Uint8Array(await response.arrayBuffer());
4097
+ if (audio.length === 0) throw new Error("Speech synthesis returned no audio");
4098
+ return {
4099
+ audio,
4100
+ mimeType: response.headers.get("content-type")?.split(";")[0] ?? "audio/wav"
4101
+ };
4102
+ }
4103
+ };
4104
+ }
4105
+
4106
+ // src/providers/images/openai-images.ts
4107
+ var IMAGE_SIZES = ["1024x1024", "1536x1024", "1024x1536"];
4108
+ var IMAGE_QUALITIES = ["auto", "low", "medium", "high", "xhigh", "max"];
4109
+ var IMAGE_B64_LIMIT = 12e6;
4110
+ function createOpenAiImageAdapter(config) {
4111
+ return {
4112
+ async generate(req) {
4113
+ const response = await fetch(`${config.baseUrl}/images/generations`, {
4114
+ method: "POST",
4115
+ headers: {
4116
+ Authorization: `Bearer ${config.apiKey}`,
4117
+ "Content-Type": "application/json"
4118
+ },
4119
+ body: JSON.stringify({
4120
+ model: req.externalModelId,
4121
+ prompt: req.prompt,
4122
+ n: 1,
4123
+ size: req.size,
4124
+ quality: req.quality
4125
+ }),
4126
+ signal: AbortSignal.timeout(config.timeoutMs ?? 6e4)
4127
+ });
4128
+ if (!response.ok) {
4129
+ let detail;
4130
+ try {
4131
+ const body = await response.json();
4132
+ detail = body.error?.message;
4133
+ } catch {
4134
+ detail = void 0;
4135
+ }
4136
+ throw new Error(detail ?? `Image provider failed with HTTP ${response.status}`);
4137
+ }
4138
+ let payload;
4139
+ try {
4140
+ payload = await response.json();
4141
+ } catch {
4142
+ throw new Error("The image provider returned an unreadable response.");
4143
+ }
4144
+ const images = (payload.data ?? []).map((item) => item.b64_json).filter((value) => typeof value === "string" && value.length > 0);
4145
+ if (images.length === 0) {
4146
+ throw new Error("The image provider returned no image data.");
4147
+ }
4148
+ if (images.some((value) => value.length > IMAGE_B64_LIMIT)) {
4149
+ throw new Error("The generated image exceeds the storage limit.");
4150
+ }
4151
+ const usage = payload.usage;
4152
+ return {
4153
+ images,
4154
+ usage: usage ? {
4155
+ inputTokens: usage.input_tokens ?? 0,
4156
+ outputTokens: usage.output_tokens ?? 0,
4157
+ totalTokens: (usage.input_tokens ?? 0) + (usage.output_tokens ?? 0)
4158
+ } : null
4159
+ };
4160
+ }
4161
+ };
4162
+ }
4163
+
4164
+ export { ANTHROPIC_API_VERSION, ANTHROPIC_DEFAULT_MAX_TOKENS, ANTHROPIC_MODELS, ANTHROPIC_TIERS, API_ENDPOINTS, AnthropicHttpTransport, AnthropicProvider, AnthropicRequestBuilder, AuthenticationError, BaseProvider as BaseAIProvider, BaseProvider, CancellationError, DEFAULT_BASE_URL, DEFAULT_GENERATION_CONFIG, DEFAULT_MODELS, FalProvider, GEMINI_TIERS, GROQ_MODELS, GROQ_TIERS, GeminiProvider, GenerationFailedError, GroqChatRequestBuilder, GroqConfigStore, GroqHttpClient, GroqHttpTransport, GroqProvider, IMAGE_B64_LIMIT, IMAGE_QUALITIES, IMAGE_SIZES, ProviderError, ProviderFactory, PrunaProvider, SPEECH_INPUT_MAX, SPEECH_VOICES, TIMEOUTS, TextGenerationService, TimeoutError, ValidationError, configureProvider, consumeAnthropicStream, consumeGroqStream, createAI, createAssistantMessage, createFalProvider, createGeminiProvider, createGroqProvider, createMessage, createOpenAiAudioTranscriptionAdapter, createOpenAiEmbeddingsAdapter, createOpenAiImageAdapter, createOpenAiSpeechAdapter, createProviderFactory, createPrunaProvider, createSystemMessage, createUserMessage, defaultEffortForModel, extractContentFromSsePayload, extractTextFromMessages, formatMessagesForDisplay, generateImageThenVideo, generate as generatePruna, generateWithPruna, getProvider, isMediaProvider, isTextProvider, mapAnthropicStopReason, pollForResult, promptToMessages, requestStructuredJson, resetProvider, submitPrediction, toGroqMessages, uploadImage };
3978
4165
  //# sourceMappingURL=index.js.map
3979
4166
  //# sourceMappingURL=index.js.map