@ai-sdk/provider 4.0.9 → 4.0.11
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/CHANGELOG.md +13 -0
- package/dist/index.d.ts +1939 -1674
- package/package.json +1 -1
- package/src/batch/v4/batch-v4-request.ts +15 -0
- package/src/batch/v4/batch-v4.ts +78 -29
- package/src/batch/v4/index.ts +6 -1
- package/src/batch/v4/text-batch-v4-request.ts +27 -0
- package/src/files/v4/files-v4-delete-file-call-options.ts +30 -0
- package/src/files/v4/files-v4-delete-file-result.ts +32 -0
- package/src/files/v4/files-v4-download-file-call-options.ts +30 -0
- package/src/files/v4/files-v4-download-file-result.ts +30 -0
- package/src/files/v4/files-v4-get-file-metadata-call-options.ts +30 -0
- package/src/files/v4/files-v4-get-file-metadata-result.ts +53 -0
- package/src/files/v4/files-v4-upload-file-call-options.ts +26 -1
- package/src/files/v4/files-v4-upload-file-result.ts +18 -0
- package/src/files/v4/files-v4.ts +34 -0
- package/src/files/v4/index.ts +10 -1
- package/src/image-model/v4/image-model-v4-result.ts +6 -0
- package/src/language-model/v4/index.ts +0 -4
- package/src/language-model/v4/language-model-v4-batch.ts +0 -42
package/dist/index.d.ts
CHANGED
|
@@ -332,1094 +332,1150 @@ type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue>>;
|
|
|
332
332
|
type SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>;
|
|
333
333
|
|
|
334
334
|
/**
|
|
335
|
-
*
|
|
336
|
-
|
|
337
|
-
type BatchV4Error = {
|
|
338
|
-
readonly message: string;
|
|
339
|
-
readonly type?: string;
|
|
340
|
-
readonly code?: string;
|
|
341
|
-
readonly statusCode?: number;
|
|
342
|
-
};
|
|
343
|
-
/**
|
|
344
|
-
* Normalized lifecycle status for a batch.
|
|
345
|
-
*/
|
|
346
|
-
type BatchV4Status = {
|
|
347
|
-
readonly status: 'pending' | 'completed' | 'failed';
|
|
348
|
-
readonly rawStatus?: string;
|
|
349
|
-
readonly requestCounts?: {
|
|
350
|
-
readonly total: number;
|
|
351
|
-
readonly pending: number;
|
|
352
|
-
readonly completed: number;
|
|
353
|
-
readonly failed: number;
|
|
354
|
-
};
|
|
355
|
-
readonly error?: BatchV4Error;
|
|
356
|
-
readonly createdAt?: string;
|
|
357
|
-
readonly expiresAt?: string;
|
|
358
|
-
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* Options for starting a batch.
|
|
335
|
+
* A provider-specific content block that does not map to another standardized
|
|
336
|
+
* content part type.
|
|
362
337
|
*/
|
|
363
|
-
type
|
|
364
|
-
|
|
365
|
-
readonly providerOptions?: SharedV4ProviderOptions;
|
|
366
|
-
readonly abortSignal?: AbortSignal;
|
|
367
|
-
readonly headers?: Record<string, string | undefined>;
|
|
338
|
+
type LanguageModelV4CustomContent = {
|
|
339
|
+
type: 'custom';
|
|
368
340
|
/**
|
|
369
|
-
*
|
|
370
|
-
* Providers that do not support completion webhooks should return an
|
|
371
|
-
* unsupported warning.
|
|
341
|
+
* The kind of custom content, in the format `{provider}.{provider-type}`.
|
|
372
342
|
*/
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
readonly warnings: Array<{
|
|
381
|
-
readonly requestId?: string;
|
|
382
|
-
readonly warning: SharedV4Warning;
|
|
383
|
-
}>;
|
|
384
|
-
};
|
|
385
|
-
/**
|
|
386
|
-
* Options for a batch status or results operation.
|
|
387
|
-
*/
|
|
388
|
-
type BatchV4OperationOptions = {
|
|
389
|
-
readonly batchId: string;
|
|
390
|
-
readonly providerOptions?: SharedV4ProviderOptions;
|
|
391
|
-
readonly abortSignal?: AbortSignal;
|
|
392
|
-
readonly headers?: Record<string, string | undefined>;
|
|
393
|
-
};
|
|
394
|
-
/**
|
|
395
|
-
* A complete terminal result for one request in a batch.
|
|
396
|
-
*/
|
|
397
|
-
type BatchV4ItemResult<RESULT> = {
|
|
398
|
-
readonly id: string;
|
|
399
|
-
readonly status: 'succeeded';
|
|
400
|
-
readonly result: RESULT;
|
|
401
|
-
} | {
|
|
402
|
-
readonly id: string;
|
|
403
|
-
readonly status: 'failed';
|
|
404
|
-
readonly error: BatchV4Error;
|
|
405
|
-
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
406
|
-
} | {
|
|
407
|
-
readonly id: string;
|
|
408
|
-
readonly status: 'cancelled' | 'expired';
|
|
409
|
-
readonly error?: BatchV4Error;
|
|
410
|
-
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
343
|
+
kind: `${string}.${string}`;
|
|
344
|
+
/**
|
|
345
|
+
* Additional provider-specific options. They are passed through
|
|
346
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
347
|
+
* functionality that can be fully encapsulated in the provider.
|
|
348
|
+
*/
|
|
349
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
411
350
|
};
|
|
351
|
+
|
|
412
352
|
/**
|
|
413
|
-
*
|
|
414
|
-
*
|
|
353
|
+
* A file that has been generated by the model.
|
|
354
|
+
* Generated files as base64 encoded strings or binary data.
|
|
355
|
+
* The files should be returned without any unnecessary conversion.
|
|
415
356
|
*/
|
|
416
|
-
type
|
|
417
|
-
|
|
418
|
-
experimental_doGetBatchStatus(options: BatchV4OperationOptions): PromiseLike<BatchV4Status>;
|
|
419
|
-
experimental_doGetBatchResults(options: BatchV4OperationOptions): PromiseLike<ReadableStream<BatchV4ItemResult<RESULT>>>;
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
type EmbeddingModelV4CallOptions = {
|
|
423
|
-
/**
|
|
424
|
-
* List of text values to generate embeddings for.
|
|
425
|
-
*/
|
|
426
|
-
values: Array<string>;
|
|
357
|
+
type LanguageModelV4File = {
|
|
358
|
+
type: 'file';
|
|
427
359
|
/**
|
|
428
|
-
*
|
|
360
|
+
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
361
|
+
*
|
|
362
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
429
363
|
*/
|
|
430
|
-
|
|
364
|
+
mediaType: string;
|
|
431
365
|
/**
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
366
|
+
* Generated file data as a tagged discriminated union:
|
|
367
|
+
*
|
|
368
|
+
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
369
|
+
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
370
|
+
*
|
|
371
|
+
* The file data should be returned without any unnecessary conversion.
|
|
372
|
+
* If the API returns base64 encoded strings, the file data should be returned
|
|
373
|
+
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
374
|
+
* be returned as binary data.
|
|
435
375
|
*/
|
|
436
|
-
|
|
376
|
+
data: SharedV4FileDataData | SharedV4FileDataUrl;
|
|
437
377
|
/**
|
|
438
|
-
*
|
|
439
|
-
* Only applicable for HTTP-based providers.
|
|
378
|
+
* Optional provider-specific metadata for the file part.
|
|
440
379
|
*/
|
|
441
|
-
|
|
380
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
442
381
|
};
|
|
443
382
|
|
|
444
383
|
/**
|
|
445
|
-
*
|
|
446
|
-
* It is e.g. used to represent a text as a vector of word embeddings.
|
|
384
|
+
* Reasoning that the model has generated.
|
|
447
385
|
*/
|
|
448
|
-
type
|
|
386
|
+
type LanguageModelV4Reasoning = {
|
|
387
|
+
type: 'reasoning';
|
|
388
|
+
text: string;
|
|
389
|
+
/**
|
|
390
|
+
* Optional provider-specific metadata for the reasoning part.
|
|
391
|
+
*/
|
|
392
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
393
|
+
};
|
|
449
394
|
|
|
450
395
|
/**
|
|
451
|
-
*
|
|
396
|
+
* A file that has been generated by the model as part of reasoning.
|
|
397
|
+
* Generated files as base64 encoded strings or binary data.
|
|
398
|
+
* The files should be returned without any unnecessary conversion.
|
|
452
399
|
*/
|
|
453
|
-
type
|
|
400
|
+
type LanguageModelV4ReasoningFile = {
|
|
401
|
+
type: 'reasoning-file';
|
|
454
402
|
/**
|
|
455
|
-
*
|
|
403
|
+
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
404
|
+
*
|
|
405
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
456
406
|
*/
|
|
457
|
-
|
|
407
|
+
mediaType: string;
|
|
458
408
|
/**
|
|
459
|
-
*
|
|
409
|
+
* Generated file data as a tagged discriminated union:
|
|
410
|
+
*
|
|
411
|
+
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
412
|
+
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
413
|
+
*
|
|
414
|
+
* The file data should be returned without any unnecessary conversion.
|
|
415
|
+
* If the API returns base64 encoded strings, the file data should be returned
|
|
416
|
+
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
417
|
+
* be returned as binary data.
|
|
460
418
|
*/
|
|
461
|
-
|
|
462
|
-
tokens: number;
|
|
463
|
-
};
|
|
419
|
+
data: SharedV4FileDataData | SharedV4FileDataUrl;
|
|
464
420
|
/**
|
|
465
|
-
*
|
|
466
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
467
|
-
* results that can be fully encapsulated in the provider.
|
|
421
|
+
* Optional provider-specific metadata for the reasoning file part.
|
|
468
422
|
*/
|
|
469
423
|
providerMetadata?: SharedV4ProviderMetadata;
|
|
470
|
-
/**
|
|
471
|
-
* Optional response information for debugging purposes.
|
|
472
|
-
*/
|
|
473
|
-
response?: {
|
|
474
|
-
/**
|
|
475
|
-
* Response headers.
|
|
476
|
-
*/
|
|
477
|
-
headers?: SharedV4Headers;
|
|
478
|
-
/**
|
|
479
|
-
* The response body.
|
|
480
|
-
*/
|
|
481
|
-
body?: unknown;
|
|
482
|
-
};
|
|
483
|
-
/**
|
|
484
|
-
* Warnings for the call, e.g. unsupported settings.
|
|
485
|
-
*/
|
|
486
|
-
warnings: Array<SharedV4Warning>;
|
|
487
424
|
};
|
|
488
425
|
|
|
489
426
|
/**
|
|
490
|
-
*
|
|
491
|
-
* interface version 4.
|
|
492
|
-
*
|
|
493
|
-
* It is specific to text embeddings.
|
|
427
|
+
* A source that has been used as input to generate the response.
|
|
494
428
|
*/
|
|
495
|
-
type
|
|
429
|
+
type LanguageModelV4Source = {
|
|
430
|
+
type: 'source';
|
|
496
431
|
/**
|
|
497
|
-
* The
|
|
498
|
-
* version it implements. This will allow us to evolve the embedding
|
|
499
|
-
* model interface and retain backwards compatibility. The different
|
|
500
|
-
* implementation versions can be handled as a discriminated union
|
|
501
|
-
* on our side.
|
|
432
|
+
* The type of source - URL sources reference web content.
|
|
502
433
|
*/
|
|
503
|
-
|
|
434
|
+
sourceType: 'url';
|
|
504
435
|
/**
|
|
505
|
-
*
|
|
436
|
+
* The ID of the source.
|
|
506
437
|
*/
|
|
507
|
-
|
|
438
|
+
id: string;
|
|
508
439
|
/**
|
|
509
|
-
*
|
|
440
|
+
* The URL of the source.
|
|
510
441
|
*/
|
|
511
|
-
|
|
442
|
+
url: string;
|
|
512
443
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
* Use Infinity for models that do not have a limit.
|
|
444
|
+
* The title of the source.
|
|
516
445
|
*/
|
|
517
|
-
|
|
446
|
+
title?: string;
|
|
518
447
|
/**
|
|
519
|
-
*
|
|
448
|
+
* Additional provider metadata for the source.
|
|
520
449
|
*/
|
|
521
|
-
|
|
450
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
451
|
+
} | {
|
|
452
|
+
type: 'source';
|
|
522
453
|
/**
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
526
|
-
* by the user.
|
|
454
|
+
* The type of source - document sources reference files/documents.
|
|
527
455
|
*/
|
|
528
|
-
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
type EmbeddingModelV3CallOptions = {
|
|
456
|
+
sourceType: 'document';
|
|
532
457
|
/**
|
|
533
|
-
*
|
|
458
|
+
* The ID of the source.
|
|
534
459
|
*/
|
|
535
|
-
|
|
460
|
+
id: string;
|
|
536
461
|
/**
|
|
537
|
-
*
|
|
462
|
+
* IANA media type of the document (e.g., 'application/pdf').
|
|
538
463
|
*/
|
|
539
|
-
|
|
464
|
+
mediaType: string;
|
|
540
465
|
/**
|
|
541
|
-
*
|
|
542
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
543
|
-
* functionality that can be fully encapsulated in the provider.
|
|
466
|
+
* The title of the document.
|
|
544
467
|
*/
|
|
545
|
-
|
|
468
|
+
title: string;
|
|
546
469
|
/**
|
|
547
|
-
*
|
|
548
|
-
* Only applicable for HTTP-based providers.
|
|
470
|
+
* Optional filename of the document.
|
|
549
471
|
*/
|
|
550
|
-
|
|
472
|
+
filename?: string;
|
|
473
|
+
/**
|
|
474
|
+
* Additional provider metadata for the source.
|
|
475
|
+
*/
|
|
476
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
551
477
|
};
|
|
552
478
|
|
|
553
479
|
/**
|
|
554
|
-
*
|
|
555
|
-
* It is e.g. used to represent a text as a vector of word embeddings.
|
|
556
|
-
*/
|
|
557
|
-
type EmbeddingModelV3Embedding = Array<number>;
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* The result of a embedding model doEmbed call.
|
|
480
|
+
* Text that the model has generated.
|
|
561
481
|
*/
|
|
562
|
-
type
|
|
482
|
+
type LanguageModelV4Text = {
|
|
483
|
+
type: 'text';
|
|
563
484
|
/**
|
|
564
|
-
*
|
|
485
|
+
* The text content.
|
|
565
486
|
*/
|
|
566
|
-
|
|
487
|
+
text: string;
|
|
488
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Tool approval request emitted by a provider for a provider-executed tool call.
|
|
493
|
+
*
|
|
494
|
+
* This is used for flows where the provider executes the tool (e.g. MCP tools)
|
|
495
|
+
* but requires an explicit user approval before continuing.
|
|
496
|
+
*/
|
|
497
|
+
type LanguageModelV4ToolApprovalRequest = {
|
|
498
|
+
type: 'tool-approval-request';
|
|
567
499
|
/**
|
|
568
|
-
*
|
|
500
|
+
* ID of the approval request. This ID is referenced by the subsequent
|
|
501
|
+
* tool-approval-response (tool message) to approve or deny execution.
|
|
569
502
|
*/
|
|
570
|
-
|
|
571
|
-
tokens: number;
|
|
572
|
-
};
|
|
503
|
+
approvalId: string;
|
|
573
504
|
/**
|
|
574
|
-
*
|
|
575
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
576
|
-
* results that can be fully encapsulated in the provider.
|
|
505
|
+
* The tool call ID that this approval request is for.
|
|
577
506
|
*/
|
|
578
|
-
|
|
507
|
+
toolCallId: string;
|
|
579
508
|
/**
|
|
580
|
-
*
|
|
509
|
+
* Additional provider-specific metadata for the approval request.
|
|
581
510
|
*/
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
body?: unknown;
|
|
591
|
-
};
|
|
511
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Tool calls that the model has generated.
|
|
516
|
+
*/
|
|
517
|
+
type LanguageModelV4ToolCall = {
|
|
518
|
+
type: 'tool-call';
|
|
592
519
|
/**
|
|
593
|
-
*
|
|
520
|
+
* The identifier of the tool call. It must be unique across all tool calls.
|
|
594
521
|
*/
|
|
595
|
-
|
|
522
|
+
toolCallId: string;
|
|
523
|
+
/**
|
|
524
|
+
* The name of the tool that should be called.
|
|
525
|
+
*/
|
|
526
|
+
toolName: string;
|
|
527
|
+
/**
|
|
528
|
+
* Stringified JSON object with the tool call arguments. Must match the
|
|
529
|
+
* parameters schema of the tool.
|
|
530
|
+
*/
|
|
531
|
+
input: string;
|
|
532
|
+
/**
|
|
533
|
+
* Whether the tool call will be executed by the provider.
|
|
534
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
535
|
+
*/
|
|
536
|
+
providerExecuted?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* Whether the tool is dynamic, i.e. defined at runtime.
|
|
539
|
+
* For example, MCP (Model Context Protocol) tools that are executed by the provider.
|
|
540
|
+
*/
|
|
541
|
+
dynamic?: boolean;
|
|
542
|
+
/**
|
|
543
|
+
* Additional provider-specific metadata for the tool call.
|
|
544
|
+
*/
|
|
545
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
596
546
|
};
|
|
597
547
|
|
|
548
|
+
declare function isJSONValue(value: unknown): value is JSONValue;
|
|
549
|
+
declare function isJSONArray(value: unknown): value is JSONArray;
|
|
550
|
+
declare function isJSONObject(value: unknown): value is JSONObject;
|
|
551
|
+
|
|
598
552
|
/**
|
|
599
|
-
*
|
|
600
|
-
* interface version 3.
|
|
601
|
-
*
|
|
602
|
-
* It is specific to text embeddings.
|
|
553
|
+
* Result of a tool call that has been executed by the provider.
|
|
603
554
|
*/
|
|
604
|
-
type
|
|
555
|
+
type LanguageModelV4ToolResult = {
|
|
556
|
+
type: 'tool-result';
|
|
605
557
|
/**
|
|
606
|
-
* The
|
|
607
|
-
* version it implements. This will allow us to evolve the embedding
|
|
608
|
-
* model interface and retain backwards compatibility. The different
|
|
609
|
-
* implementation versions can be handled as a discriminated union
|
|
610
|
-
* on our side.
|
|
558
|
+
* The ID of the tool call that this result is associated with.
|
|
611
559
|
*/
|
|
612
|
-
|
|
560
|
+
toolCallId: string;
|
|
613
561
|
/**
|
|
614
|
-
* Name of the
|
|
562
|
+
* Name of the tool that generated this result.
|
|
615
563
|
*/
|
|
616
|
-
|
|
564
|
+
toolName: string;
|
|
617
565
|
/**
|
|
618
|
-
*
|
|
566
|
+
* Result of the tool call. This is a JSON-serializable object.
|
|
619
567
|
*/
|
|
620
|
-
|
|
568
|
+
result: NonNullable<JSONValue>;
|
|
621
569
|
/**
|
|
622
|
-
*
|
|
570
|
+
* Optional flag if the result is an error or an error message.
|
|
571
|
+
*/
|
|
572
|
+
isError?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Whether the tool result is preliminary.
|
|
623
575
|
*
|
|
624
|
-
*
|
|
576
|
+
* Preliminary tool results replace each other, e.g. image previews.
|
|
577
|
+
* There always has to be a final, non-preliminary tool result.
|
|
578
|
+
*
|
|
579
|
+
* If this flag is set to true, the tool result is preliminary.
|
|
580
|
+
* If this flag is not set or is false, the tool result is not preliminary.
|
|
625
581
|
*/
|
|
626
|
-
|
|
582
|
+
preliminary?: boolean;
|
|
627
583
|
/**
|
|
628
|
-
*
|
|
584
|
+
* Whether the tool is dynamic, i.e. defined at runtime.
|
|
585
|
+
* For example, MCP (Model Context Protocol) tools that are executed by the provider.
|
|
629
586
|
*/
|
|
630
|
-
|
|
587
|
+
dynamic?: boolean;
|
|
631
588
|
/**
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
635
|
-
* by the user.
|
|
589
|
+
* Additional provider-specific metadata for the tool result.
|
|
636
590
|
*/
|
|
637
|
-
|
|
591
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
638
592
|
};
|
|
639
593
|
|
|
640
|
-
|
|
641
|
-
* An embedding is a vector, i.e. an array of numbers.
|
|
642
|
-
* It is e.g. used to represent a text as a vector of word embeddings.
|
|
643
|
-
*/
|
|
644
|
-
type EmbeddingModelV2Embedding = Array<number>;
|
|
594
|
+
type LanguageModelV4Content = LanguageModelV4Text | LanguageModelV4Reasoning | LanguageModelV4CustomContent | LanguageModelV4ReasoningFile | LanguageModelV4File | LanguageModelV4ToolApprovalRequest | LanguageModelV4Source | LanguageModelV4ToolCall | LanguageModelV4ToolResult;
|
|
645
595
|
|
|
646
596
|
/**
|
|
647
|
-
*
|
|
648
|
-
* interface version 2.
|
|
597
|
+
* Reason why a language model finished generating a response.
|
|
649
598
|
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
599
|
+
* Contains both a unified finish reason and a raw finish reason from the provider.
|
|
600
|
+
* The unified finish reason is used to provide a consistent finish reason across different providers.
|
|
601
|
+
* The raw finish reason is used to provide the original finish reason from the provider.
|
|
653
602
|
*/
|
|
654
|
-
type
|
|
603
|
+
type LanguageModelV4FinishReason = {
|
|
655
604
|
/**
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
605
|
+
* Unified finish reason. This enables using the same finish reason across different providers.
|
|
606
|
+
*
|
|
607
|
+
* Can be one of the following:
|
|
608
|
+
* - `stop`: model generated stop sequence
|
|
609
|
+
* - `length`: model generated maximum number of tokens
|
|
610
|
+
* - `content-filter`: content filter violation stopped the model
|
|
611
|
+
* - `tool-calls`: model triggered tool calls
|
|
612
|
+
* - `error`: model stopped because of an error
|
|
613
|
+
* - `other`: model stopped for other reasons
|
|
661
614
|
*/
|
|
662
|
-
|
|
615
|
+
unified: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
|
|
663
616
|
/**
|
|
664
|
-
*
|
|
617
|
+
* Raw finish reason from the provider.
|
|
618
|
+
* This is the original finish reason from the provider.
|
|
665
619
|
*/
|
|
666
|
-
|
|
620
|
+
raw: string | undefined;
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
interface LanguageModelV4ResponseMetadata {
|
|
667
624
|
/**
|
|
668
|
-
*
|
|
625
|
+
* ID for the generated response, if the provider sends one.
|
|
669
626
|
*/
|
|
670
|
-
|
|
627
|
+
id?: string;
|
|
671
628
|
/**
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
* Use Infinity for models that do not have a limit.
|
|
629
|
+
* Timestamp for the start of the generated response, if the provider sends one.
|
|
675
630
|
*/
|
|
676
|
-
|
|
631
|
+
timestamp?: Date;
|
|
677
632
|
/**
|
|
678
|
-
*
|
|
633
|
+
* The ID of the response model that was used to generate the response, if the provider sends one.
|
|
679
634
|
*/
|
|
680
|
-
|
|
635
|
+
modelId?: string;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Usage information for a language model call.
|
|
640
|
+
*/
|
|
641
|
+
type LanguageModelV4Usage = {
|
|
681
642
|
/**
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
685
|
-
* by the user.
|
|
643
|
+
* Information about the input tokens.
|
|
686
644
|
*/
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* List of values to embed.
|
|
690
|
-
*/
|
|
691
|
-
values: Array<VALUE>;
|
|
645
|
+
inputTokens: {
|
|
692
646
|
/**
|
|
693
|
-
*
|
|
647
|
+
* The total number of input (prompt) tokens used.
|
|
694
648
|
*/
|
|
695
|
-
|
|
649
|
+
total: number | undefined;
|
|
696
650
|
/**
|
|
697
|
-
*
|
|
698
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
699
|
-
* functionality that can be fully encapsulated in the provider.
|
|
651
|
+
* The number of non-cached input (prompt) tokens used.
|
|
700
652
|
*/
|
|
701
|
-
|
|
653
|
+
noCache: number | undefined;
|
|
702
654
|
/**
|
|
703
|
-
*
|
|
704
|
-
* Only applicable for HTTP-based providers.
|
|
655
|
+
* The number of cached input (prompt) tokens read.
|
|
705
656
|
*/
|
|
706
|
-
|
|
707
|
-
}): PromiseLike<{
|
|
657
|
+
cacheRead: number | undefined;
|
|
708
658
|
/**
|
|
709
|
-
*
|
|
659
|
+
* The number of cached input (prompt) tokens written.
|
|
710
660
|
*/
|
|
711
|
-
|
|
661
|
+
cacheWrite: number | undefined;
|
|
662
|
+
};
|
|
663
|
+
/**
|
|
664
|
+
* Information about the output tokens.
|
|
665
|
+
*/
|
|
666
|
+
outputTokens: {
|
|
712
667
|
/**
|
|
713
|
-
*
|
|
668
|
+
* The total number of output (completion) tokens used.
|
|
714
669
|
*/
|
|
715
|
-
|
|
716
|
-
tokens: number;
|
|
717
|
-
};
|
|
670
|
+
total: number | undefined;
|
|
718
671
|
/**
|
|
719
|
-
*
|
|
720
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
721
|
-
* results that can be fully encapsulated in the provider.
|
|
672
|
+
* The number of text tokens used.
|
|
722
673
|
*/
|
|
723
|
-
|
|
674
|
+
text: number | undefined;
|
|
724
675
|
/**
|
|
725
|
-
*
|
|
676
|
+
* The number of reasoning tokens used.
|
|
726
677
|
*/
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
declare const symbol$e: unique symbol;
|
|
678
|
+
reasoning: number | undefined;
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* Raw usage information from the provider.
|
|
682
|
+
*
|
|
683
|
+
* This is the usage information in the shape that the provider returns.
|
|
684
|
+
* It can include additional information that is not part of the standard usage information.
|
|
685
|
+
*/
|
|
686
|
+
raw?: JSONObject;
|
|
687
|
+
};
|
|
688
|
+
|
|
741
689
|
/**
|
|
742
|
-
*
|
|
743
|
-
* @extends Error
|
|
690
|
+
* The result of a language model doGenerate call.
|
|
744
691
|
*/
|
|
745
|
-
|
|
746
|
-
private readonly [symbol$e];
|
|
692
|
+
type LanguageModelV4GenerateResult = {
|
|
747
693
|
/**
|
|
748
|
-
*
|
|
694
|
+
* Ordered content that the model has generated.
|
|
749
695
|
*/
|
|
750
|
-
|
|
696
|
+
content: Array<LanguageModelV4Content>;
|
|
751
697
|
/**
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
* @param {Object} params - The parameters for creating the error.
|
|
755
|
-
* @param {string} params.name - The name of the error.
|
|
756
|
-
* @param {string} params.message - The error message.
|
|
757
|
-
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
698
|
+
* The finish reason.
|
|
758
699
|
*/
|
|
759
|
-
|
|
760
|
-
name: string;
|
|
761
|
-
message: string;
|
|
762
|
-
cause?: unknown;
|
|
763
|
-
});
|
|
700
|
+
finishReason: LanguageModelV4FinishReason;
|
|
764
701
|
/**
|
|
765
|
-
*
|
|
766
|
-
* @param {unknown} error - The error to check.
|
|
767
|
-
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
702
|
+
* The usage information.
|
|
768
703
|
*/
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
});
|
|
804
|
-
static isInstance(error: unknown): error is EmptyResponseBodyError;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
declare function getErrorMessage(error: unknown | undefined): string;
|
|
704
|
+
usage: LanguageModelV4Usage;
|
|
705
|
+
/**
|
|
706
|
+
* Additional provider-specific metadata. They are passed through
|
|
707
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
708
|
+
* results that can be fully encapsulated in the provider.
|
|
709
|
+
*/
|
|
710
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
711
|
+
/**
|
|
712
|
+
* Optional request information for telemetry and debugging purposes.
|
|
713
|
+
*/
|
|
714
|
+
request?: {
|
|
715
|
+
/**
|
|
716
|
+
* Request HTTP body that was sent to the provider API.
|
|
717
|
+
*/
|
|
718
|
+
body?: unknown;
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Optional response information for telemetry and debugging purposes.
|
|
722
|
+
*/
|
|
723
|
+
response?: LanguageModelV4ResponseMetadata & {
|
|
724
|
+
/**
|
|
725
|
+
* Response headers.
|
|
726
|
+
*/
|
|
727
|
+
headers?: SharedV4Headers;
|
|
728
|
+
/**
|
|
729
|
+
* Response HTTP body.
|
|
730
|
+
*/
|
|
731
|
+
body?: unknown;
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
735
|
+
*/
|
|
736
|
+
warnings: Array<SharedV4Warning>;
|
|
737
|
+
};
|
|
808
738
|
|
|
809
|
-
declare const symbol$b: unique symbol;
|
|
810
739
|
/**
|
|
811
|
-
* A
|
|
740
|
+
* A tool has a name, a description, and a set of parameters.
|
|
741
|
+
*
|
|
742
|
+
* Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
743
|
+
* map the user-facing tool definitions to this format.
|
|
812
744
|
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
745
|
+
type LanguageModelV4FunctionTool = {
|
|
746
|
+
/**
|
|
747
|
+
* The type of the tool (always 'function').
|
|
748
|
+
*/
|
|
749
|
+
type: 'function';
|
|
750
|
+
/**
|
|
751
|
+
* The name of the tool. Unique within this model call.
|
|
752
|
+
*/
|
|
753
|
+
name: string;
|
|
754
|
+
/**
|
|
755
|
+
* A description of the tool. The language model uses this to understand the
|
|
756
|
+
* tool's purpose and to provide better completion suggestions.
|
|
757
|
+
*/
|
|
758
|
+
description?: string;
|
|
759
|
+
/**
|
|
760
|
+
* The parameters that the tool expects. The language model uses this to
|
|
761
|
+
* understand the tool's input requirements and to provide matching suggestions.
|
|
762
|
+
*/
|
|
763
|
+
inputSchema: JSONSchema7;
|
|
764
|
+
/**
|
|
765
|
+
* An optional list of input examples that show the language
|
|
766
|
+
* model what the input should look like.
|
|
767
|
+
*/
|
|
768
|
+
inputExamples?: Array<{
|
|
769
|
+
input: JSONObject;
|
|
770
|
+
}>;
|
|
771
|
+
/**
|
|
772
|
+
* Strict mode setting for the tool.
|
|
773
|
+
*
|
|
774
|
+
* Providers that support strict mode will use this setting to determine
|
|
775
|
+
* how the input should be generated. Strict mode will always produce
|
|
776
|
+
* valid inputs, but it might limit what input schemas are supported.
|
|
777
|
+
*/
|
|
778
|
+
strict?: boolean;
|
|
779
|
+
/**
|
|
780
|
+
* The provider-specific options for the tool.
|
|
781
|
+
*/
|
|
782
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
783
|
+
};
|
|
823
784
|
|
|
824
|
-
declare const symbol$a: unique symbol;
|
|
825
785
|
/**
|
|
826
|
-
* A prompt is
|
|
827
|
-
*
|
|
786
|
+
* A prompt is a list of messages.
|
|
787
|
+
*
|
|
788
|
+
* Note: Not all models and prompt formats support multi-modal inputs and
|
|
789
|
+
* tool calls. The validation happens at runtime.
|
|
790
|
+
*
|
|
791
|
+
* Note: This is not a user-facing prompt. The AI SDK methods will map the
|
|
792
|
+
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
828
793
|
*/
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
794
|
+
type LanguageModelV4Prompt = Array<LanguageModelV4Message>;
|
|
795
|
+
type LanguageModelV4Message = ({
|
|
796
|
+
role: 'system';
|
|
797
|
+
content: string;
|
|
798
|
+
} | {
|
|
799
|
+
role: 'user';
|
|
800
|
+
content: Array<LanguageModelV4TextPart | LanguageModelV4FilePart>;
|
|
801
|
+
} | {
|
|
802
|
+
role: 'assistant';
|
|
803
|
+
content: Array<LanguageModelV4TextPart | LanguageModelV4FilePart | LanguageModelV4CustomPart | LanguageModelV4ReasoningPart | LanguageModelV4ReasoningFilePart | LanguageModelV4ToolCallPart | LanguageModelV4ToolResultPart>;
|
|
804
|
+
} | {
|
|
805
|
+
role: 'tool';
|
|
806
|
+
content: Array<LanguageModelV4ToolResultPart | LanguageModelV4ToolApprovalResponsePart>;
|
|
807
|
+
}) & {
|
|
808
|
+
/**
|
|
809
|
+
* Additional provider-specific options. They are passed through
|
|
810
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
811
|
+
* functionality that can be fully encapsulated in the provider.
|
|
812
|
+
*/
|
|
813
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* Text content part of a prompt. It contains a string of text.
|
|
817
|
+
*/
|
|
818
|
+
interface LanguageModelV4TextPart {
|
|
819
|
+
type: 'text';
|
|
820
|
+
/**
|
|
821
|
+
* The text content.
|
|
822
|
+
*/
|
|
823
|
+
text: string;
|
|
824
|
+
/**
|
|
825
|
+
* Additional provider-specific options. They are passed through
|
|
826
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
827
|
+
* functionality that can be fully encapsulated in the provider.
|
|
828
|
+
*/
|
|
829
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
838
830
|
}
|
|
839
|
-
|
|
840
|
-
declare const symbol$9: unique symbol;
|
|
841
831
|
/**
|
|
842
|
-
*
|
|
843
|
-
* This should be thrown by providers when they cannot parse the response from the API.
|
|
832
|
+
* Reasoning content part of a prompt. It contains a string of reasoning text.
|
|
844
833
|
*/
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
834
|
+
interface LanguageModelV4ReasoningPart {
|
|
835
|
+
type: 'reasoning';
|
|
836
|
+
/**
|
|
837
|
+
* The reasoning text.
|
|
838
|
+
*/
|
|
839
|
+
text: string;
|
|
840
|
+
/**
|
|
841
|
+
* Additional provider-specific options. They are passed through
|
|
842
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
843
|
+
* functionality that can be fully encapsulated in the provider.
|
|
844
|
+
*/
|
|
845
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
853
846
|
}
|
|
854
|
-
|
|
855
|
-
declare const symbol$8: unique symbol;
|
|
856
|
-
declare class JSONParseError extends AISDKError {
|
|
857
|
-
private readonly [symbol$8];
|
|
858
|
-
readonly text: string;
|
|
859
|
-
constructor({ text, cause }: {
|
|
860
|
-
text: string;
|
|
861
|
-
cause: unknown;
|
|
862
|
-
});
|
|
863
|
-
static isInstance(error: unknown): error is JSONParseError;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
declare const symbol$7: unique symbol;
|
|
867
|
-
declare class LoadAPIKeyError extends AISDKError {
|
|
868
|
-
private readonly [symbol$7];
|
|
869
|
-
constructor({ message }: {
|
|
870
|
-
message: string;
|
|
871
|
-
});
|
|
872
|
-
static isInstance(error: unknown): error is LoadAPIKeyError;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
declare const symbol$6: unique symbol;
|
|
876
|
-
declare class LoadSettingError extends AISDKError {
|
|
877
|
-
private readonly [symbol$6];
|
|
878
|
-
constructor({ message }: {
|
|
879
|
-
message: string;
|
|
880
|
-
});
|
|
881
|
-
static isInstance(error: unknown): error is LoadSettingError;
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
declare const symbol$5: unique symbol;
|
|
885
|
-
/**
|
|
886
|
-
* Thrown when the AI provider fails to generate any content.
|
|
887
|
-
*/
|
|
888
|
-
declare class NoContentGeneratedError extends AISDKError {
|
|
889
|
-
private readonly [symbol$5];
|
|
890
|
-
constructor({ message, }?: {
|
|
891
|
-
message?: string;
|
|
892
|
-
});
|
|
893
|
-
static isInstance(error: unknown): error is NoContentGeneratedError;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
declare const symbol$4: unique symbol;
|
|
897
|
-
declare class NoSuchModelError extends AISDKError {
|
|
898
|
-
private readonly [symbol$4];
|
|
899
|
-
readonly modelId: string;
|
|
900
|
-
readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
|
|
901
|
-
constructor({ errorName, modelId, modelType, message, }: {
|
|
902
|
-
errorName?: string;
|
|
903
|
-
modelId: string;
|
|
904
|
-
modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
|
|
905
|
-
message?: string;
|
|
906
|
-
});
|
|
907
|
-
static isInstance(error: unknown): error is NoSuchModelError;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
declare const symbol$3: unique symbol;
|
|
911
847
|
/**
|
|
912
|
-
*
|
|
913
|
-
* provider is not found in the provider reference mapping.
|
|
848
|
+
* Reasoning file content part of a prompt. It contains a file generated as part of reasoning.
|
|
914
849
|
*/
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
readonly provider: string;
|
|
918
|
-
readonly reference: SharedV4ProviderReference;
|
|
919
|
-
constructor({ provider, reference, message, }: {
|
|
920
|
-
provider: string;
|
|
921
|
-
reference: SharedV4ProviderReference;
|
|
922
|
-
message?: string;
|
|
923
|
-
});
|
|
924
|
-
static isInstance(error: unknown): error is NoSuchProviderReferenceError;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
declare const symbol$2: unique symbol;
|
|
928
|
-
declare class TooManyEmbeddingValuesForCallError extends AISDKError {
|
|
929
|
-
private readonly [symbol$2];
|
|
930
|
-
readonly provider: string;
|
|
931
|
-
readonly modelId: string;
|
|
932
|
-
readonly maxEmbeddingsPerCall: number;
|
|
933
|
-
readonly values: Array<unknown>;
|
|
934
|
-
constructor(options: {
|
|
935
|
-
provider: string;
|
|
936
|
-
modelId: string;
|
|
937
|
-
maxEmbeddingsPerCall: number;
|
|
938
|
-
values: Array<unknown>;
|
|
939
|
-
});
|
|
940
|
-
static isInstance(error: unknown): error is TooManyEmbeddingValuesForCallError;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
declare const symbol$1: unique symbol;
|
|
944
|
-
interface TypeValidationContext {
|
|
850
|
+
interface LanguageModelV4ReasoningFilePart {
|
|
851
|
+
type: 'reasoning-file';
|
|
945
852
|
/**
|
|
946
|
-
*
|
|
853
|
+
* File data as a tagged discriminated union:
|
|
854
|
+
*
|
|
855
|
+
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
856
|
+
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
947
857
|
*/
|
|
948
|
-
|
|
858
|
+
data: SharedV4FileDataData | SharedV4FileDataUrl;
|
|
949
859
|
/**
|
|
950
|
-
*
|
|
860
|
+
* IANA media type of the file.
|
|
861
|
+
*
|
|
862
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
951
863
|
*/
|
|
952
|
-
|
|
864
|
+
mediaType: string;
|
|
953
865
|
/**
|
|
954
|
-
*
|
|
866
|
+
* Additional provider-specific options. They are passed through
|
|
867
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
868
|
+
* functionality that can be fully encapsulated in the provider.
|
|
955
869
|
*/
|
|
956
|
-
|
|
870
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
957
871
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
cause: unknown;
|
|
965
|
-
context?: TypeValidationContext;
|
|
966
|
-
});
|
|
967
|
-
static isInstance(error: unknown): error is TypeValidationError;
|
|
872
|
+
/**
|
|
873
|
+
* Provider-specific content part of a prompt. It contains no standardized
|
|
874
|
+
* payload beyond provider-specific options.
|
|
875
|
+
*/
|
|
876
|
+
interface LanguageModelV4CustomPart {
|
|
877
|
+
type: 'custom';
|
|
968
878
|
/**
|
|
969
|
-
*
|
|
970
|
-
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
971
|
-
* Otherwise, it creates a new TypeValidationError.
|
|
972
|
-
*
|
|
973
|
-
* @param {Object} params - The parameters for wrapping the error.
|
|
974
|
-
* @param {unknown} params.value - The value that failed validation.
|
|
975
|
-
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
976
|
-
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
977
|
-
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
879
|
+
* The kind of custom content, in the format `{provider}.{provider-type}`.
|
|
978
880
|
*/
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
declare const symbol: unique symbol;
|
|
987
|
-
declare class UnsupportedFunctionalityError extends AISDKError {
|
|
988
|
-
private readonly [symbol];
|
|
989
|
-
readonly functionality: string;
|
|
990
|
-
constructor({ functionality, message, }: {
|
|
991
|
-
functionality: string;
|
|
992
|
-
message?: string;
|
|
993
|
-
});
|
|
994
|
-
static isInstance(error: unknown): error is UnsupportedFunctionalityError;
|
|
881
|
+
kind: `${string}.${string}`;
|
|
882
|
+
/**
|
|
883
|
+
* Additional provider-specific options. They are passed through
|
|
884
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
885
|
+
* functionality that can be fully encapsulated in the provider.
|
|
886
|
+
*/
|
|
887
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
995
888
|
}
|
|
996
|
-
|
|
997
889
|
/**
|
|
998
|
-
*
|
|
890
|
+
* File content part of a prompt. It contains a file.
|
|
999
891
|
*/
|
|
1000
|
-
|
|
892
|
+
interface LanguageModelV4FilePart {
|
|
893
|
+
type: 'file';
|
|
1001
894
|
/**
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1004
|
-
* - `{ type: 'data', data }`: raw bytes (`Uint8Array`) or a base64-encoded string.
|
|
1005
|
-
* - `{ type: 'text', text }`: inline text (UTF-8).
|
|
895
|
+
* Optional filename of the file.
|
|
1006
896
|
*/
|
|
1007
|
-
|
|
897
|
+
filename?: string;
|
|
1008
898
|
/**
|
|
1009
|
-
*
|
|
899
|
+
* File data as a tagged discriminated union:
|
|
900
|
+
*
|
|
901
|
+
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
902
|
+
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
903
|
+
* - `{ type: 'reference', reference }`: a provider reference (`{ [provider]: id }`).
|
|
904
|
+
* - `{ type: 'text', text }`: inline text content (e.g. an inline text document).
|
|
1010
905
|
*/
|
|
1011
|
-
|
|
906
|
+
data: SharedV4FileData;
|
|
1012
907
|
/**
|
|
1013
|
-
*
|
|
908
|
+
* Either a full IANA media type (`type/subtype`, e.g. `image/png`) or just
|
|
909
|
+
* the top-level IANA segment (e.g. `image`, `audio`, `video`, `text`).
|
|
910
|
+
*
|
|
911
|
+
* `*`-subtype wildcards (e.g. `image/*`) are normalized as equivalent to the
|
|
912
|
+
* top-level segment alone (e.g. `image`). Providers can use the helpers in
|
|
913
|
+
* `@ai-sdk/provider-utils` (`isFullMediaType`, `getTopLevelMediaType`,
|
|
914
|
+
* `detectMediaType`) to resolve the field according to their API
|
|
915
|
+
* requirements.
|
|
916
|
+
*
|
|
917
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
1014
918
|
*/
|
|
1015
|
-
|
|
919
|
+
mediaType: string;
|
|
1016
920
|
/**
|
|
1017
921
|
* Additional provider-specific options. They are passed through
|
|
1018
922
|
* to the provider from the AI SDK and enable provider-specific
|
|
1019
923
|
* functionality that can be fully encapsulated in the provider.
|
|
1020
924
|
*/
|
|
1021
925
|
providerOptions?: SharedV4ProviderOptions;
|
|
1022
|
-
}
|
|
1023
|
-
|
|
926
|
+
}
|
|
1024
927
|
/**
|
|
1025
|
-
*
|
|
928
|
+
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
1026
929
|
*/
|
|
1027
|
-
|
|
930
|
+
interface LanguageModelV4ToolCallPart {
|
|
931
|
+
type: 'tool-call';
|
|
1028
932
|
/**
|
|
1029
|
-
*
|
|
933
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
1030
934
|
*/
|
|
1031
|
-
|
|
935
|
+
toolCallId: string;
|
|
1032
936
|
/**
|
|
1033
|
-
*
|
|
937
|
+
* Name of the tool that is being called.
|
|
1034
938
|
*/
|
|
1035
|
-
|
|
939
|
+
toolName: string;
|
|
1036
940
|
/**
|
|
1037
|
-
*
|
|
941
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
1038
942
|
*/
|
|
1039
|
-
|
|
943
|
+
input: unknown;
|
|
1040
944
|
/**
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
* functionality that can be fully encapsulated in the provider.
|
|
945
|
+
* Whether the tool call will be executed by the provider.
|
|
946
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
1044
947
|
*/
|
|
1045
|
-
|
|
948
|
+
providerExecuted?: boolean;
|
|
1046
949
|
/**
|
|
1047
|
-
*
|
|
950
|
+
* Additional provider-specific options. They are passed through
|
|
951
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
952
|
+
* functionality that can be fully encapsulated in the provider.
|
|
1048
953
|
*/
|
|
1049
|
-
|
|
1050
|
-
}
|
|
1051
|
-
|
|
954
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
955
|
+
}
|
|
1052
956
|
/**
|
|
1053
|
-
*
|
|
957
|
+
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
1054
958
|
*/
|
|
1055
|
-
|
|
959
|
+
interface LanguageModelV4ToolResultPart {
|
|
960
|
+
type: 'tool-result';
|
|
1056
961
|
/**
|
|
1057
|
-
*
|
|
962
|
+
* ID of the tool call that this result is associated with.
|
|
1058
963
|
*/
|
|
1059
|
-
|
|
964
|
+
toolCallId: string;
|
|
1060
965
|
/**
|
|
1061
|
-
*
|
|
966
|
+
* Name of the tool that generated this result.
|
|
1062
967
|
*/
|
|
1063
|
-
|
|
968
|
+
toolName: string;
|
|
1064
969
|
/**
|
|
1065
|
-
*
|
|
1066
|
-
* that can be used in subsequent API calls.
|
|
970
|
+
* Result of the tool call.
|
|
1067
971
|
*/
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
972
|
+
output: LanguageModelV4ToolResultOutput;
|
|
973
|
+
/**
|
|
974
|
+
* Additional provider-specific options. They are passed through
|
|
975
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
976
|
+
* functionality that can be fully encapsulated in the provider.
|
|
977
|
+
*/
|
|
978
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
979
|
+
}
|
|
1071
980
|
/**
|
|
1072
|
-
*
|
|
981
|
+
* Tool approval response content part of a prompt. It contains the user's
|
|
982
|
+
* decision to approve or deny a provider-executed tool call.
|
|
1073
983
|
*/
|
|
1074
|
-
|
|
1075
|
-
type: '
|
|
984
|
+
interface LanguageModelV4ToolApprovalResponsePart {
|
|
985
|
+
type: 'tool-approval-response';
|
|
1076
986
|
/**
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
987
|
+
* ID of the approval request that this response refers to.
|
|
1080
988
|
*/
|
|
1081
|
-
|
|
989
|
+
approvalId: string;
|
|
1082
990
|
/**
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
* The file data should be returned without any unnecessary conversion.
|
|
1086
|
-
* If the API returns base64 encoded strings, the file data should be returned
|
|
1087
|
-
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
1088
|
-
* be returned as binary data.
|
|
991
|
+
* Whether the approval was granted (true) or denied (false).
|
|
1089
992
|
*/
|
|
1090
|
-
|
|
993
|
+
approved: boolean;
|
|
1091
994
|
/**
|
|
1092
|
-
* Optional
|
|
995
|
+
* Optional reason for approval or denial.
|
|
1093
996
|
*/
|
|
1094
|
-
|
|
1095
|
-
} | {
|
|
1096
|
-
type: 'url';
|
|
997
|
+
reason?: string;
|
|
1097
998
|
/**
|
|
1098
|
-
*
|
|
999
|
+
* Additional provider-specific options. They are passed through
|
|
1000
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
1001
|
+
* functionality that can be fully encapsulated in the provider.
|
|
1099
1002
|
*/
|
|
1100
|
-
|
|
1003
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Result of a tool call.
|
|
1007
|
+
*/
|
|
1008
|
+
type LanguageModelV4ToolResultOutput = {
|
|
1101
1009
|
/**
|
|
1102
|
-
*
|
|
1010
|
+
* Text tool output that should be directly sent to the API.
|
|
1103
1011
|
*/
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
type ImageModelV4CallOptions = {
|
|
1012
|
+
type: 'text';
|
|
1013
|
+
value: string;
|
|
1108
1014
|
/**
|
|
1109
|
-
*
|
|
1015
|
+
* Provider-specific options.
|
|
1110
1016
|
*/
|
|
1111
|
-
|
|
1017
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1018
|
+
} | {
|
|
1019
|
+
type: 'json';
|
|
1020
|
+
value: JSONValue;
|
|
1112
1021
|
/**
|
|
1113
|
-
*
|
|
1022
|
+
* Provider-specific options.
|
|
1114
1023
|
*/
|
|
1115
|
-
|
|
1024
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1025
|
+
} | {
|
|
1116
1026
|
/**
|
|
1117
|
-
*
|
|
1118
|
-
* Must have the format `{width}x{height}`.
|
|
1119
|
-
* `undefined` will use the provider's default size.
|
|
1027
|
+
* Type when the user has denied the execution of the tool call.
|
|
1120
1028
|
*/
|
|
1121
|
-
|
|
1029
|
+
type: 'execution-denied';
|
|
1122
1030
|
/**
|
|
1123
|
-
*
|
|
1124
|
-
* Must have the format `{width}:{height}`.
|
|
1125
|
-
* `undefined` will use the provider's default aspect ratio.
|
|
1031
|
+
* Optional reason for the execution denial.
|
|
1126
1032
|
*/
|
|
1127
|
-
|
|
1033
|
+
reason?: string;
|
|
1128
1034
|
/**
|
|
1129
|
-
*
|
|
1130
|
-
* `undefined` will use the provider's default seed.
|
|
1035
|
+
* Provider-specific options.
|
|
1131
1036
|
*/
|
|
1132
|
-
|
|
1037
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1038
|
+
} | {
|
|
1039
|
+
type: 'error-text';
|
|
1040
|
+
value: string;
|
|
1133
1041
|
/**
|
|
1134
|
-
*
|
|
1135
|
-
* The images should be provided as base64 encoded strings or binary data.
|
|
1042
|
+
* Provider-specific options.
|
|
1136
1043
|
*/
|
|
1137
|
-
|
|
1044
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1045
|
+
} | {
|
|
1046
|
+
type: 'error-json';
|
|
1047
|
+
value: JSONValue;
|
|
1138
1048
|
/**
|
|
1139
|
-
*
|
|
1140
|
-
* The mask should be provided as base64 encoded strings or binary data.
|
|
1049
|
+
* Provider-specific options.
|
|
1141
1050
|
*/
|
|
1142
|
-
|
|
1051
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1052
|
+
} | {
|
|
1053
|
+
type: 'content';
|
|
1054
|
+
value: Array<{
|
|
1055
|
+
type: 'text';
|
|
1056
|
+
/**
|
|
1057
|
+
* Text content.
|
|
1058
|
+
*/
|
|
1059
|
+
text: string;
|
|
1060
|
+
/**
|
|
1061
|
+
* Provider-specific options.
|
|
1062
|
+
*/
|
|
1063
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1064
|
+
} | {
|
|
1065
|
+
type: 'file';
|
|
1066
|
+
/**
|
|
1067
|
+
* File data as a tagged discriminated union:
|
|
1068
|
+
*
|
|
1069
|
+
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
1070
|
+
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
1071
|
+
* - `{ type: 'reference', reference }`: a provider reference (`{ [provider]: id }`).
|
|
1072
|
+
* - `{ type: 'text', text }`: inline text content (e.g. an inline text document).
|
|
1073
|
+
*/
|
|
1074
|
+
data: SharedV4FileData;
|
|
1075
|
+
/**
|
|
1076
|
+
* Either a full IANA media type (`type/subtype`, e.g. `image/png`) or just
|
|
1077
|
+
* the top-level IANA segment (e.g. `image`, `audio`, `video`, `text`).
|
|
1078
|
+
*
|
|
1079
|
+
* `*`-subtype wildcards (e.g. `image/*`) are normalized as equivalent to the
|
|
1080
|
+
* top-level segment alone (e.g. `image`). Providers can use the helpers in
|
|
1081
|
+
* `@ai-sdk/provider-utils` (`isFullMediaType`, `getTopLevelMediaType`,
|
|
1082
|
+
* `detectMediaType`) to resolve the field according to their API
|
|
1083
|
+
* requirements.
|
|
1084
|
+
*
|
|
1085
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
1086
|
+
*/
|
|
1087
|
+
mediaType: string;
|
|
1088
|
+
/**
|
|
1089
|
+
* Optional filename of the file.
|
|
1090
|
+
*/
|
|
1091
|
+
filename?: string;
|
|
1092
|
+
/**
|
|
1093
|
+
* Provider-specific options.
|
|
1094
|
+
*/
|
|
1095
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1096
|
+
} | {
|
|
1097
|
+
/**
|
|
1098
|
+
* Custom content part. This can be used to implement
|
|
1099
|
+
* provider-specific content parts.
|
|
1100
|
+
*/
|
|
1101
|
+
type: 'custom';
|
|
1102
|
+
/**
|
|
1103
|
+
* Provider-specific options.
|
|
1104
|
+
*/
|
|
1105
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1106
|
+
}>;
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* The configuration of a provider tool.
|
|
1111
|
+
*
|
|
1112
|
+
* Provider tools are tools that are specific to a certain provider.
|
|
1113
|
+
* The input and output schemas are defined be the provider, and
|
|
1114
|
+
* some of the tools are also executed on the provider systems.
|
|
1115
|
+
*/
|
|
1116
|
+
type LanguageModelV4ProviderTool = {
|
|
1143
1117
|
/**
|
|
1144
|
-
*
|
|
1145
|
-
* as body parameters.
|
|
1146
|
-
*
|
|
1147
|
-
* The outer record is keyed by the provider name, and the inner
|
|
1148
|
-
* record is keyed by the provider-specific metadata key.
|
|
1149
|
-
*
|
|
1150
|
-
* ```ts
|
|
1151
|
-
* {
|
|
1152
|
-
* "openai": {
|
|
1153
|
-
* "style": "vivid"
|
|
1154
|
-
* }
|
|
1155
|
-
* }
|
|
1156
|
-
* ```
|
|
1118
|
+
* The type of the tool (always 'provider').
|
|
1157
1119
|
*/
|
|
1158
|
-
|
|
1120
|
+
type: 'provider';
|
|
1159
1121
|
/**
|
|
1160
|
-
*
|
|
1122
|
+
* The ID of the tool. Should follow the format `<provider-id>.<unique-tool-name>`.
|
|
1161
1123
|
*/
|
|
1162
|
-
|
|
1124
|
+
id: `${string}.${string}`;
|
|
1163
1125
|
/**
|
|
1164
|
-
*
|
|
1165
|
-
* Only applicable for HTTP-based providers.
|
|
1126
|
+
* The name of the tool. Unique within this model call.
|
|
1166
1127
|
*/
|
|
1167
|
-
|
|
1128
|
+
name: string;
|
|
1129
|
+
/**
|
|
1130
|
+
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
1131
|
+
*/
|
|
1132
|
+
args: Record<string, unknown>;
|
|
1168
1133
|
};
|
|
1169
1134
|
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1135
|
+
type LanguageModelV4ToolChoice = {
|
|
1136
|
+
type: 'auto';
|
|
1137
|
+
} | {
|
|
1138
|
+
type: 'none';
|
|
1139
|
+
} | {
|
|
1140
|
+
type: 'required';
|
|
1141
|
+
} | {
|
|
1142
|
+
type: 'tool';
|
|
1143
|
+
toolName: string;
|
|
1144
|
+
};
|
|
1173
1145
|
|
|
1174
|
-
|
|
1175
|
-
* Usage information for an image model call.
|
|
1176
|
-
*/
|
|
1177
|
-
type ImageModelV4Usage = {
|
|
1146
|
+
type LanguageModelV4CallOptions = {
|
|
1178
1147
|
/**
|
|
1179
|
-
*
|
|
1148
|
+
* A language mode prompt is a standardized prompt type.
|
|
1149
|
+
*
|
|
1150
|
+
* Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
1151
|
+
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
1152
|
+
* That approach allows us to evolve the user facing prompts without breaking
|
|
1153
|
+
* the language model interface.
|
|
1180
1154
|
*/
|
|
1181
|
-
|
|
1155
|
+
prompt: LanguageModelV4Prompt;
|
|
1182
1156
|
/**
|
|
1183
|
-
*
|
|
1157
|
+
* Maximum number of tokens to generate.
|
|
1184
1158
|
*/
|
|
1185
|
-
|
|
1159
|
+
maxOutputTokens?: number;
|
|
1186
1160
|
/**
|
|
1187
|
-
*
|
|
1161
|
+
* Temperature setting. The range depends on the provider and model.
|
|
1188
1162
|
*/
|
|
1189
|
-
|
|
1190
|
-
};
|
|
1191
|
-
|
|
1192
|
-
type ImageModelV4ProviderMetadata = Record<string, {
|
|
1193
|
-
images: JSONArray;
|
|
1194
|
-
} & JSONValue>;
|
|
1195
|
-
/**
|
|
1196
|
-
* The result of an image model doGenerate call.
|
|
1197
|
-
*/
|
|
1198
|
-
type ImageModelV4Result = {
|
|
1163
|
+
temperature?: number;
|
|
1199
1164
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
* as base64 encoded strings. If the API returns binary data, the images should
|
|
1204
|
-
* be returned as binary data.
|
|
1165
|
+
* Stop sequences.
|
|
1166
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
1167
|
+
* Providers may have limits on the number of stop sequences.
|
|
1205
1168
|
*/
|
|
1206
|
-
|
|
1169
|
+
stopSequences?: string[];
|
|
1207
1170
|
/**
|
|
1208
|
-
*
|
|
1171
|
+
* Nucleus sampling.
|
|
1209
1172
|
*/
|
|
1210
|
-
|
|
1173
|
+
topP?: number;
|
|
1211
1174
|
/**
|
|
1212
|
-
*
|
|
1213
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
1214
|
-
* results that can be fully encapsulated in the provider.
|
|
1215
|
-
*
|
|
1216
|
-
* The outer record is keyed by the provider name, and the inner
|
|
1217
|
-
* record is provider-specific metadata. It always includes an
|
|
1218
|
-
* `images` key with image-specific metadata
|
|
1175
|
+
* Only sample from the top K options for each subsequent token.
|
|
1219
1176
|
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
* "openai": {
|
|
1223
|
-
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
1224
|
-
* }
|
|
1225
|
-
* }
|
|
1226
|
-
* ```
|
|
1177
|
+
* Used to remove "long tail" low probability responses.
|
|
1178
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
1227
1179
|
*/
|
|
1228
|
-
|
|
1180
|
+
topK?: number;
|
|
1229
1181
|
/**
|
|
1230
|
-
*
|
|
1182
|
+
* Presence penalty setting. It affects the likelihood of the model to
|
|
1183
|
+
* repeat information that is already in the prompt.
|
|
1231
1184
|
*/
|
|
1232
|
-
|
|
1185
|
+
presencePenalty?: number;
|
|
1186
|
+
/**
|
|
1187
|
+
* Frequency penalty setting. It affects the likelihood of the model
|
|
1188
|
+
* to repeatedly use the same words or phrases.
|
|
1189
|
+
*/
|
|
1190
|
+
frequencyPenalty?: number;
|
|
1191
|
+
/**
|
|
1192
|
+
* Response format. The output can either be text or JSON. Default is text.
|
|
1193
|
+
*
|
|
1194
|
+
* If JSON is selected, a schema can optionally be provided to guide the LLM.
|
|
1195
|
+
*/
|
|
1196
|
+
responseFormat?: {
|
|
1197
|
+
type: 'text';
|
|
1198
|
+
} | {
|
|
1199
|
+
type: 'json';
|
|
1233
1200
|
/**
|
|
1234
|
-
*
|
|
1201
|
+
* JSON schema that the generated output should conform to.
|
|
1235
1202
|
*/
|
|
1236
|
-
|
|
1203
|
+
schema?: JSONSchema7;
|
|
1237
1204
|
/**
|
|
1238
|
-
*
|
|
1205
|
+
* Name of output that should be generated. Used by some providers for additional LLM guidance.
|
|
1239
1206
|
*/
|
|
1240
|
-
|
|
1207
|
+
name?: string;
|
|
1241
1208
|
/**
|
|
1242
|
-
*
|
|
1209
|
+
* Description of the output that should be generated. Used by some providers for additional LLM guidance.
|
|
1243
1210
|
*/
|
|
1244
|
-
|
|
1211
|
+
description?: string;
|
|
1245
1212
|
};
|
|
1246
1213
|
/**
|
|
1247
|
-
*
|
|
1214
|
+
* The seed (integer) to use for random sampling. If set and supported
|
|
1215
|
+
* by the model, calls will generate deterministic results.
|
|
1248
1216
|
*/
|
|
1249
|
-
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
|
-
type GetMaxImagesPerCallFunction$2 = (options: {
|
|
1253
|
-
modelId: string;
|
|
1254
|
-
}) => PromiseLike<number | undefined> | number | undefined;
|
|
1255
|
-
/**
|
|
1256
|
-
* Image generation model specification version 4.
|
|
1257
|
-
*/
|
|
1258
|
-
type ImageModelV4 = {
|
|
1217
|
+
seed?: number;
|
|
1259
1218
|
/**
|
|
1260
|
-
* The
|
|
1261
|
-
* version it implements. This will allow us to evolve the image
|
|
1262
|
-
* model interface and retain backwards compatibility. The different
|
|
1263
|
-
* implementation versions can be handled as a discriminated union
|
|
1264
|
-
* on our side.
|
|
1219
|
+
* The tools that are available for the model.
|
|
1265
1220
|
*/
|
|
1266
|
-
|
|
1221
|
+
tools?: Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool>;
|
|
1267
1222
|
/**
|
|
1268
|
-
*
|
|
1223
|
+
* Specifies how the tool should be selected. Defaults to 'auto'.
|
|
1269
1224
|
*/
|
|
1270
|
-
|
|
1225
|
+
toolChoice?: LanguageModelV4ToolChoice;
|
|
1271
1226
|
/**
|
|
1272
|
-
*
|
|
1227
|
+
* Include raw chunks in the stream. Only applicable for streaming calls.
|
|
1273
1228
|
*/
|
|
1274
|
-
|
|
1229
|
+
includeRawChunks?: boolean;
|
|
1275
1230
|
/**
|
|
1276
|
-
*
|
|
1277
|
-
* Can be set to a number for a fixed limit, to undefined to use
|
|
1278
|
-
* the global limit, or a function that returns a number or undefined,
|
|
1279
|
-
* optionally as a promise.
|
|
1231
|
+
* Abort signal for cancelling the operation.
|
|
1280
1232
|
*/
|
|
1281
|
-
|
|
1233
|
+
abortSignal?: AbortSignal;
|
|
1282
1234
|
/**
|
|
1283
|
-
*
|
|
1235
|
+
* Additional HTTP headers to be sent with the request.
|
|
1236
|
+
* Only applicable for HTTP-based providers.
|
|
1284
1237
|
*/
|
|
1285
|
-
|
|
1238
|
+
headers?: Record<string, string | undefined>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Reasoning effort level for the model. Controls how much reasoning
|
|
1241
|
+
* the model performs before generating a response. Defaults to 'provider-default'.
|
|
1242
|
+
*/
|
|
1243
|
+
reasoning?: 'provider-default' | 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
1244
|
+
/**
|
|
1245
|
+
* Additional provider-specific options. They are passed through
|
|
1246
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
1247
|
+
* functionality that can be fully encapsulated in the provider.
|
|
1248
|
+
*/
|
|
1249
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1286
1250
|
};
|
|
1287
1251
|
|
|
1288
1252
|
/**
|
|
1289
|
-
*
|
|
1253
|
+
* Fields shared by every request in a batch.
|
|
1290
1254
|
*/
|
|
1291
|
-
type
|
|
1292
|
-
/**
|
|
1293
|
-
* The number of input (prompt) tokens used.
|
|
1294
|
-
*/
|
|
1295
|
-
inputTokens: number | undefined;
|
|
1255
|
+
type BatchV4RequestBase<ModelId extends string = string> = {
|
|
1296
1256
|
/**
|
|
1297
|
-
*
|
|
1257
|
+
* Application-provided identifier used to correlate the request with its
|
|
1258
|
+
* result.
|
|
1298
1259
|
*/
|
|
1299
|
-
|
|
1260
|
+
readonly id: string;
|
|
1300
1261
|
/**
|
|
1301
|
-
*
|
|
1262
|
+
* Provider-specific model ID for this request.
|
|
1302
1263
|
*/
|
|
1303
|
-
|
|
1264
|
+
readonly modelId: ModelId;
|
|
1304
1265
|
};
|
|
1305
1266
|
|
|
1306
1267
|
/**
|
|
1307
|
-
*
|
|
1268
|
+
* A normalized text generation request within a batch.
|
|
1308
1269
|
*/
|
|
1309
|
-
type
|
|
1310
|
-
type: '
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1270
|
+
type TextBatchV4Request<ModelId extends string = string> = BatchV4RequestBase<ModelId> & {
|
|
1271
|
+
readonly type: 'text';
|
|
1272
|
+
readonly options: Pick<LanguageModelV4CallOptions, 'prompt' | 'maxOutputTokens' | 'temperature' | 'stopSequences' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'seed' | 'reasoning' | 'responseFormat' | 'toolChoice' | 'tools' | 'providerOptions'>;
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Model IDs accepted by each batch modality.
|
|
1277
|
+
*
|
|
1278
|
+
* Additional modality-specific model ID types can be added to this mapping.
|
|
1279
|
+
*/
|
|
1280
|
+
type BatchV4ModelIds = {
|
|
1281
|
+
readonly text: string;
|
|
1282
|
+
};
|
|
1283
|
+
type BatchV4CallOptions = {
|
|
1284
|
+
readonly providerOptions?: SharedV4ProviderOptions;
|
|
1285
|
+
readonly abortSignal?: AbortSignal;
|
|
1286
|
+
readonly headers?: Record<string, string | undefined>;
|
|
1287
|
+
};
|
|
1288
|
+
type BatchV4StartCallOptions = BatchV4CallOptions & {
|
|
1317
1289
|
/**
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1320
|
-
*
|
|
1321
|
-
* If the API returns base64 encoded strings, the file data should be returned
|
|
1322
|
-
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
1323
|
-
* be returned as binary data.
|
|
1290
|
+
* URL the provider notifies when the batch reaches a terminal state.
|
|
1291
|
+
* Providers that do not support completion webhooks should return an
|
|
1292
|
+
* unsupported warning.
|
|
1324
1293
|
*/
|
|
1325
|
-
|
|
1294
|
+
readonly webhookUrl?: string;
|
|
1295
|
+
};
|
|
1296
|
+
/**
|
|
1297
|
+
* Serializable error information for a batch or batch item.
|
|
1298
|
+
*/
|
|
1299
|
+
type BatchV4Error = {
|
|
1300
|
+
readonly message: string;
|
|
1301
|
+
readonly type?: string;
|
|
1302
|
+
readonly code?: string;
|
|
1303
|
+
readonly statusCode?: number;
|
|
1304
|
+
};
|
|
1305
|
+
/**
|
|
1306
|
+
* Normalized lifecycle status for a batch.
|
|
1307
|
+
*/
|
|
1308
|
+
type BatchV4Status = {
|
|
1309
|
+
readonly status: 'pending' | 'completed' | 'failed';
|
|
1310
|
+
readonly rawStatus?: string;
|
|
1311
|
+
readonly requestCounts?: {
|
|
1312
|
+
readonly total: number;
|
|
1313
|
+
readonly pending: number;
|
|
1314
|
+
readonly completed: number;
|
|
1315
|
+
readonly failed: number;
|
|
1316
|
+
};
|
|
1317
|
+
readonly error?: BatchV4Error;
|
|
1318
|
+
readonly createdAt?: string;
|
|
1319
|
+
readonly expiresAt?: string;
|
|
1320
|
+
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
1321
|
+
};
|
|
1322
|
+
type BatchV4Request<ModelIds extends BatchV4ModelIds = BatchV4ModelIds> = TextBatchV4Request<ModelIds['text']>;
|
|
1323
|
+
/**
|
|
1324
|
+
* Options for starting a batch of requests discriminated by modality.
|
|
1325
|
+
*
|
|
1326
|
+
* Additional modality-specific request variants can be added to
|
|
1327
|
+
* `BatchV4Request`.
|
|
1328
|
+
*/
|
|
1329
|
+
type BatchV4StartOptions<ModelIds extends BatchV4ModelIds = BatchV4ModelIds> = BatchV4StartCallOptions & {
|
|
1330
|
+
readonly requests: ReadonlyArray<BatchV4Request<ModelIds>>;
|
|
1331
|
+
};
|
|
1332
|
+
/**
|
|
1333
|
+
* Result of starting a batch.
|
|
1334
|
+
*/
|
|
1335
|
+
type BatchV4StartResult = BatchV4Status & {
|
|
1336
|
+
readonly batchId: string;
|
|
1337
|
+
readonly warnings: Array<{
|
|
1338
|
+
readonly requestId?: string;
|
|
1339
|
+
readonly warning: SharedV4Warning;
|
|
1340
|
+
}>;
|
|
1341
|
+
};
|
|
1342
|
+
/**
|
|
1343
|
+
* Options for a batch status or results operation.
|
|
1344
|
+
*/
|
|
1345
|
+
type BatchV4OperationOptions = {
|
|
1346
|
+
readonly batchId: string;
|
|
1347
|
+
} & BatchV4CallOptions;
|
|
1348
|
+
type BatchV4ItemResultBase<RESULT> = {
|
|
1349
|
+
readonly id: string;
|
|
1350
|
+
readonly status: 'succeeded';
|
|
1351
|
+
readonly result: RESULT;
|
|
1352
|
+
} | {
|
|
1353
|
+
readonly id: string;
|
|
1354
|
+
readonly status: 'failed';
|
|
1355
|
+
readonly error: BatchV4Error;
|
|
1356
|
+
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
1357
|
+
} | {
|
|
1358
|
+
readonly id: string;
|
|
1359
|
+
readonly status: 'cancelled' | 'expired';
|
|
1360
|
+
readonly error?: BatchV4Error;
|
|
1361
|
+
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
1362
|
+
};
|
|
1363
|
+
/**
|
|
1364
|
+
* A complete terminal result for one request in a text batch.
|
|
1365
|
+
*/
|
|
1366
|
+
type TextBatchV4ItemResult = {
|
|
1367
|
+
readonly type: 'text';
|
|
1368
|
+
} & BatchV4ItemResultBase<LanguageModelV4GenerateResult>;
|
|
1369
|
+
/**
|
|
1370
|
+
* A complete terminal result for one request in a batch, discriminated by
|
|
1371
|
+
* modality.
|
|
1372
|
+
*
|
|
1373
|
+
* Additional modality-specific item results can be added to this union.
|
|
1374
|
+
*/
|
|
1375
|
+
type BatchV4ItemResult = TextBatchV4ItemResult;
|
|
1376
|
+
/**
|
|
1377
|
+
* Specification for a batch interface that implements batch interface version 4.
|
|
1378
|
+
*/
|
|
1379
|
+
type BatchV4<ModelIds extends BatchV4ModelIds = BatchV4ModelIds> = {
|
|
1326
1380
|
/**
|
|
1327
|
-
*
|
|
1381
|
+
* The batch interface must specify which batch interface version it implements.
|
|
1328
1382
|
*/
|
|
1329
|
-
|
|
1330
|
-
} | {
|
|
1331
|
-
type: 'url';
|
|
1383
|
+
readonly specificationVersion: 'v4';
|
|
1332
1384
|
/**
|
|
1333
|
-
*
|
|
1385
|
+
* Provider ID.
|
|
1334
1386
|
*/
|
|
1335
|
-
|
|
1387
|
+
readonly provider: string;
|
|
1336
1388
|
/**
|
|
1337
|
-
*
|
|
1389
|
+
* Supported URL patterns by media type for requests in this batch interface.
|
|
1338
1390
|
*/
|
|
1339
|
-
|
|
1391
|
+
readonly supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
1392
|
+
doStartBatch(options: BatchV4StartOptions<ModelIds>): PromiseLike<BatchV4StartResult>;
|
|
1393
|
+
doGetBatchStatus(options: BatchV4OperationOptions): PromiseLike<BatchV4Status>;
|
|
1394
|
+
doGetBatchResults(options: BatchV4OperationOptions): PromiseLike<ReadableStream<BatchV4ItemResult>>;
|
|
1340
1395
|
};
|
|
1341
1396
|
|
|
1342
|
-
type
|
|
1397
|
+
type EmbeddingModelV4CallOptions = {
|
|
1343
1398
|
/**
|
|
1344
|
-
*
|
|
1399
|
+
* List of text values to generate embeddings for.
|
|
1345
1400
|
*/
|
|
1346
|
-
|
|
1401
|
+
values: Array<string>;
|
|
1347
1402
|
/**
|
|
1348
|
-
*
|
|
1403
|
+
* Abort signal for cancelling the operation.
|
|
1349
1404
|
*/
|
|
1350
|
-
|
|
1405
|
+
abortSignal?: AbortSignal;
|
|
1351
1406
|
/**
|
|
1352
|
-
*
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1407
|
+
* Additional provider-specific options. They are passed through
|
|
1408
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
1409
|
+
* functionality that can be fully encapsulated in the provider.
|
|
1355
1410
|
*/
|
|
1356
|
-
|
|
1411
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
1357
1412
|
/**
|
|
1358
|
-
*
|
|
1359
|
-
*
|
|
1360
|
-
* `undefined` will use the provider's default aspect ratio.
|
|
1413
|
+
* Additional HTTP headers to be sent with the request.
|
|
1414
|
+
* Only applicable for HTTP-based providers.
|
|
1361
1415
|
*/
|
|
1362
|
-
|
|
1416
|
+
headers?: SharedV4Headers;
|
|
1417
|
+
};
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* An embedding is a vector, i.e. an array of numbers.
|
|
1421
|
+
* It is e.g. used to represent a text as a vector of word embeddings.
|
|
1422
|
+
*/
|
|
1423
|
+
type EmbeddingModelV4Embedding = Array<number>;
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* The result of a embedding model doEmbed call.
|
|
1427
|
+
*/
|
|
1428
|
+
type EmbeddingModelV4Result = {
|
|
1363
1429
|
/**
|
|
1364
|
-
*
|
|
1365
|
-
* `undefined` will use the provider's default seed.
|
|
1430
|
+
* Generated embeddings. They are in the same order as the input values.
|
|
1366
1431
|
*/
|
|
1367
|
-
|
|
1432
|
+
embeddings: Array<EmbeddingModelV4Embedding>;
|
|
1368
1433
|
/**
|
|
1369
|
-
*
|
|
1370
|
-
* The images should be provided as base64 encoded strings or binary data.
|
|
1434
|
+
* Token usage. We only have input tokens for embeddings.
|
|
1371
1435
|
*/
|
|
1372
|
-
|
|
1436
|
+
usage?: {
|
|
1437
|
+
tokens: number;
|
|
1438
|
+
};
|
|
1373
1439
|
/**
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
|
|
1377
|
-
mask: ImageModelV3File | undefined;
|
|
1378
|
-
/**
|
|
1379
|
-
* Additional provider-specific options that are passed through to the provider
|
|
1380
|
-
* as body parameters.
|
|
1381
|
-
*
|
|
1382
|
-
* The outer record is keyed by the provider name, and the inner
|
|
1383
|
-
* record is keyed by the provider-specific metadata key.
|
|
1384
|
-
*
|
|
1385
|
-
* ```ts
|
|
1386
|
-
* {
|
|
1387
|
-
* "openai": {
|
|
1388
|
-
* "style": "vivid"
|
|
1389
|
-
* }
|
|
1390
|
-
* }
|
|
1391
|
-
* ```
|
|
1440
|
+
* Additional provider-specific metadata. They are passed through
|
|
1441
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
1442
|
+
* results that can be fully encapsulated in the provider.
|
|
1392
1443
|
*/
|
|
1393
|
-
|
|
1444
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
1394
1445
|
/**
|
|
1395
|
-
*
|
|
1446
|
+
* Optional response information for debugging purposes.
|
|
1396
1447
|
*/
|
|
1397
|
-
|
|
1448
|
+
response?: {
|
|
1449
|
+
/**
|
|
1450
|
+
* Response headers.
|
|
1451
|
+
*/
|
|
1452
|
+
headers?: SharedV4Headers;
|
|
1453
|
+
/**
|
|
1454
|
+
* The response body.
|
|
1455
|
+
*/
|
|
1456
|
+
body?: unknown;
|
|
1457
|
+
};
|
|
1398
1458
|
/**
|
|
1399
|
-
*
|
|
1400
|
-
* Only applicable for HTTP-based providers.
|
|
1459
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
1401
1460
|
*/
|
|
1402
|
-
|
|
1461
|
+
warnings: Array<SharedV4Warning>;
|
|
1403
1462
|
};
|
|
1404
1463
|
|
|
1405
|
-
type ImageModelV3ProviderMetadata = Record<string, {
|
|
1406
|
-
images: JSONArray;
|
|
1407
|
-
} & JSONValue>;
|
|
1408
|
-
type GetMaxImagesPerCallFunction$1 = (options: {
|
|
1409
|
-
modelId: string;
|
|
1410
|
-
}) => PromiseLike<number | undefined> | number | undefined;
|
|
1411
1464
|
/**
|
|
1412
|
-
*
|
|
1465
|
+
* Specification for an embedding model that implements the embedding model
|
|
1466
|
+
* interface version 4.
|
|
1467
|
+
*
|
|
1468
|
+
* It is specific to text embeddings.
|
|
1413
1469
|
*/
|
|
1414
|
-
type
|
|
1470
|
+
type EmbeddingModelV4 = {
|
|
1415
1471
|
/**
|
|
1416
|
-
* The
|
|
1417
|
-
* version it implements. This will allow us to evolve the
|
|
1472
|
+
* The embedding model must specify which embedding model interface
|
|
1473
|
+
* version it implements. This will allow us to evolve the embedding
|
|
1418
1474
|
* model interface and retain backwards compatibility. The different
|
|
1419
1475
|
* implementation versions can be handled as a discriminated union
|
|
1420
1476
|
* on our side.
|
|
1421
1477
|
*/
|
|
1422
|
-
readonly specificationVersion: '
|
|
1478
|
+
readonly specificationVersion: 'v4';
|
|
1423
1479
|
/**
|
|
1424
1480
|
* Name of the provider for logging purposes.
|
|
1425
1481
|
*/
|
|
@@ -1429,153 +1485,106 @@ type ImageModelV3 = {
|
|
|
1429
1485
|
*/
|
|
1430
1486
|
readonly modelId: string;
|
|
1431
1487
|
/**
|
|
1432
|
-
* Limit of how many
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1435
|
-
* optionally as a promise.
|
|
1488
|
+
* Limit of how many embeddings can be generated in a single API call.
|
|
1489
|
+
*
|
|
1490
|
+
* Use Infinity for models that do not have a limit.
|
|
1436
1491
|
*/
|
|
1437
|
-
readonly
|
|
1492
|
+
readonly maxEmbeddingsPerCall: PromiseLike<number | undefined> | number | undefined;
|
|
1438
1493
|
/**
|
|
1439
|
-
*
|
|
1494
|
+
* True if the model can handle multiple embedding calls in parallel.
|
|
1440
1495
|
*/
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
images: Array<string> | Array<Uint8Array>;
|
|
1450
|
-
/**
|
|
1451
|
-
* Warnings for the call, e.g. unsupported features.
|
|
1452
|
-
*/
|
|
1453
|
-
warnings: Array<SharedV3Warning>;
|
|
1454
|
-
/**
|
|
1455
|
-
* Additional provider-specific metadata. They are passed through
|
|
1456
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
1457
|
-
* results that can be fully encapsulated in the provider.
|
|
1458
|
-
*
|
|
1459
|
-
* The outer record is keyed by the provider name, and the inner
|
|
1460
|
-
* record is provider-specific metadata. It always includes an
|
|
1461
|
-
* `images` key with image-specific metadata
|
|
1462
|
-
*
|
|
1463
|
-
* ```ts
|
|
1464
|
-
* {
|
|
1465
|
-
* "openai": {
|
|
1466
|
-
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
1467
|
-
* }
|
|
1468
|
-
* }
|
|
1469
|
-
* ```
|
|
1470
|
-
*/
|
|
1471
|
-
providerMetadata?: ImageModelV3ProviderMetadata;
|
|
1472
|
-
/**
|
|
1473
|
-
* Response information for telemetry and debugging purposes.
|
|
1474
|
-
*/
|
|
1475
|
-
response: {
|
|
1476
|
-
/**
|
|
1477
|
-
* Timestamp for the start of the generated response.
|
|
1478
|
-
*/
|
|
1479
|
-
timestamp: Date;
|
|
1480
|
-
/**
|
|
1481
|
-
* The ID of the response model that was used to generate the response.
|
|
1482
|
-
*/
|
|
1483
|
-
modelId: string;
|
|
1484
|
-
/**
|
|
1485
|
-
* Response headers.
|
|
1486
|
-
*/
|
|
1487
|
-
headers: Record<string, string> | undefined;
|
|
1488
|
-
};
|
|
1489
|
-
/**
|
|
1490
|
-
* Optional token usage for the image generation call (if the provider reports it).
|
|
1491
|
-
*/
|
|
1492
|
-
usage?: ImageModelV3Usage;
|
|
1493
|
-
}>;
|
|
1496
|
+
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
|
1497
|
+
/**
|
|
1498
|
+
* Generates a list of embeddings for the given input text.
|
|
1499
|
+
*
|
|
1500
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
1501
|
+
* by the user.
|
|
1502
|
+
*/
|
|
1503
|
+
doEmbed(options: EmbeddingModelV4CallOptions): PromiseLike<EmbeddingModelV4Result>;
|
|
1494
1504
|
};
|
|
1495
1505
|
|
|
1496
|
-
type
|
|
1506
|
+
type EmbeddingModelV3CallOptions = {
|
|
1497
1507
|
/**
|
|
1498
|
-
*
|
|
1508
|
+
* List of text values to generate embeddings for.
|
|
1499
1509
|
*/
|
|
1500
|
-
|
|
1510
|
+
values: Array<string>;
|
|
1501
1511
|
/**
|
|
1502
|
-
*
|
|
1512
|
+
* Abort signal for cancelling the operation.
|
|
1503
1513
|
*/
|
|
1504
|
-
|
|
1514
|
+
abortSignal?: AbortSignal;
|
|
1505
1515
|
/**
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1516
|
+
* Additional provider-specific options. They are passed through
|
|
1517
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
1518
|
+
* functionality that can be fully encapsulated in the provider.
|
|
1509
1519
|
*/
|
|
1510
|
-
|
|
1520
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
1511
1521
|
/**
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
1514
|
-
* `undefined` will use the provider's default aspect ratio.
|
|
1522
|
+
* Additional HTTP headers to be sent with the request.
|
|
1523
|
+
* Only applicable for HTTP-based providers.
|
|
1515
1524
|
*/
|
|
1516
|
-
|
|
1525
|
+
headers?: SharedV3Headers;
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
/**
|
|
1529
|
+
* An embedding is a vector, i.e. an array of numbers.
|
|
1530
|
+
* It is e.g. used to represent a text as a vector of word embeddings.
|
|
1531
|
+
*/
|
|
1532
|
+
type EmbeddingModelV3Embedding = Array<number>;
|
|
1533
|
+
|
|
1534
|
+
/**
|
|
1535
|
+
* The result of a embedding model doEmbed call.
|
|
1536
|
+
*/
|
|
1537
|
+
type EmbeddingModelV3Result = {
|
|
1517
1538
|
/**
|
|
1518
|
-
*
|
|
1519
|
-
* `undefined` will use the provider's default seed.
|
|
1539
|
+
* Generated embeddings. They are in the same order as the input values.
|
|
1520
1540
|
*/
|
|
1521
|
-
|
|
1541
|
+
embeddings: Array<EmbeddingModelV3Embedding>;
|
|
1522
1542
|
/**
|
|
1523
|
-
*
|
|
1524
|
-
* as body parameters.
|
|
1525
|
-
*
|
|
1526
|
-
* The outer record is keyed by the provider name, and the inner
|
|
1527
|
-
* record is keyed by the provider-specific metadata key.
|
|
1528
|
-
* ```ts
|
|
1529
|
-
* {
|
|
1530
|
-
* "openai": {
|
|
1531
|
-
* "style": "vivid"
|
|
1532
|
-
* }
|
|
1533
|
-
* }
|
|
1534
|
-
* ```
|
|
1543
|
+
* Token usage. We only have input tokens for embeddings.
|
|
1535
1544
|
*/
|
|
1536
|
-
|
|
1545
|
+
usage?: {
|
|
1546
|
+
tokens: number;
|
|
1547
|
+
};
|
|
1537
1548
|
/**
|
|
1538
|
-
*
|
|
1549
|
+
* Additional provider-specific metadata. They are passed through
|
|
1550
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
1551
|
+
* results that can be fully encapsulated in the provider.
|
|
1539
1552
|
*/
|
|
1540
|
-
|
|
1553
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
1541
1554
|
/**
|
|
1542
|
-
*
|
|
1543
|
-
* Only applicable for HTTP-based providers.
|
|
1555
|
+
* Optional response information for debugging purposes.
|
|
1544
1556
|
*/
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1557
|
+
response?: {
|
|
1558
|
+
/**
|
|
1559
|
+
* Response headers.
|
|
1560
|
+
*/
|
|
1561
|
+
headers?: SharedV3Headers;
|
|
1562
|
+
/**
|
|
1563
|
+
* The response body.
|
|
1564
|
+
*/
|
|
1565
|
+
body?: unknown;
|
|
1566
|
+
};
|
|
1567
|
+
/**
|
|
1568
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
1569
|
+
*/
|
|
1570
|
+
warnings: Array<SharedV3Warning>;
|
|
1559
1571
|
};
|
|
1560
1572
|
|
|
1561
|
-
type ImageModelV2ProviderMetadata = Record<string, {
|
|
1562
|
-
images: JSONArray;
|
|
1563
|
-
} & JSONValue>;
|
|
1564
|
-
type GetMaxImagesPerCallFunction = (options: {
|
|
1565
|
-
modelId: string;
|
|
1566
|
-
}) => PromiseLike<number | undefined> | number | undefined;
|
|
1567
1573
|
/**
|
|
1568
|
-
*
|
|
1574
|
+
* Specification for an embedding model that implements the embedding model
|
|
1575
|
+
* interface version 3.
|
|
1576
|
+
*
|
|
1577
|
+
* It is specific to text embeddings.
|
|
1569
1578
|
*/
|
|
1570
|
-
type
|
|
1579
|
+
type EmbeddingModelV3 = {
|
|
1571
1580
|
/**
|
|
1572
|
-
* The
|
|
1573
|
-
* version it implements. This will allow us to evolve the
|
|
1581
|
+
* The embedding model must specify which embedding model interface
|
|
1582
|
+
* version it implements. This will allow us to evolve the embedding
|
|
1574
1583
|
* model interface and retain backwards compatibility. The different
|
|
1575
1584
|
* implementation versions can be handled as a discriminated union
|
|
1576
1585
|
* on our side.
|
|
1577
1586
|
*/
|
|
1578
|
-
readonly specificationVersion: '
|
|
1587
|
+
readonly specificationVersion: 'v3';
|
|
1579
1588
|
/**
|
|
1580
1589
|
* Name of the provider for logging purposes.
|
|
1581
1590
|
*/
|
|
@@ -1585,251 +1594,398 @@ type ImageModelV2 = {
|
|
|
1585
1594
|
*/
|
|
1586
1595
|
readonly modelId: string;
|
|
1587
1596
|
/**
|
|
1588
|
-
* Limit of how many
|
|
1589
|
-
*
|
|
1590
|
-
*
|
|
1591
|
-
* optionally as a promise.
|
|
1597
|
+
* Limit of how many embeddings can be generated in a single API call.
|
|
1598
|
+
*
|
|
1599
|
+
* Use Infinity for models that do not have a limit.
|
|
1592
1600
|
*/
|
|
1593
|
-
readonly
|
|
1601
|
+
readonly maxEmbeddingsPerCall: PromiseLike<number | undefined> | number | undefined;
|
|
1594
1602
|
/**
|
|
1595
|
-
*
|
|
1603
|
+
* True if the model can handle multiple embedding calls in parallel.
|
|
1596
1604
|
*/
|
|
1597
|
-
|
|
1605
|
+
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
|
1606
|
+
/**
|
|
1607
|
+
* Generates a list of embeddings for the given input text.
|
|
1608
|
+
*
|
|
1609
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
1610
|
+
* by the user.
|
|
1611
|
+
*/
|
|
1612
|
+
doEmbed(options: EmbeddingModelV3CallOptions): PromiseLike<EmbeddingModelV3Result>;
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* An embedding is a vector, i.e. an array of numbers.
|
|
1617
|
+
* It is e.g. used to represent a text as a vector of word embeddings.
|
|
1618
|
+
*/
|
|
1619
|
+
type EmbeddingModelV2Embedding = Array<number>;
|
|
1620
|
+
|
|
1621
|
+
/**
|
|
1622
|
+
* Specification for an embedding model that implements the embedding model
|
|
1623
|
+
* interface version 2.
|
|
1624
|
+
*
|
|
1625
|
+
* VALUE is the type of the values that the model can embed.
|
|
1626
|
+
* This will allow us to go beyond text embeddings in the future,
|
|
1627
|
+
* e.g. to support image embeddings
|
|
1628
|
+
*/
|
|
1629
|
+
type EmbeddingModelV2<VALUE> = {
|
|
1630
|
+
/**
|
|
1631
|
+
* The embedding model must specify which embedding model interface
|
|
1632
|
+
* version it implements. This will allow us to evolve the embedding
|
|
1633
|
+
* model interface and retain backwards compatibility. The different
|
|
1634
|
+
* implementation versions can be handled as a discriminated union
|
|
1635
|
+
* on our side.
|
|
1636
|
+
*/
|
|
1637
|
+
readonly specificationVersion: 'v2';
|
|
1638
|
+
/**
|
|
1639
|
+
* Name of the provider for logging purposes.
|
|
1640
|
+
*/
|
|
1641
|
+
readonly provider: string;
|
|
1642
|
+
/**
|
|
1643
|
+
* Provider-specific model ID for logging purposes.
|
|
1644
|
+
*/
|
|
1645
|
+
readonly modelId: string;
|
|
1646
|
+
/**
|
|
1647
|
+
* Limit of how many embeddings can be generated in a single API call.
|
|
1648
|
+
*
|
|
1649
|
+
* Use Infinity for models that do not have a limit.
|
|
1650
|
+
*/
|
|
1651
|
+
readonly maxEmbeddingsPerCall: PromiseLike<number | undefined> | number | undefined;
|
|
1652
|
+
/**
|
|
1653
|
+
* True if the model can handle multiple embedding calls in parallel.
|
|
1654
|
+
*/
|
|
1655
|
+
readonly supportsParallelCalls: PromiseLike<boolean> | boolean;
|
|
1656
|
+
/**
|
|
1657
|
+
* Generates a list of embeddings for the given input text.
|
|
1658
|
+
*
|
|
1659
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
1660
|
+
* by the user.
|
|
1661
|
+
*/
|
|
1662
|
+
doEmbed(options: {
|
|
1598
1663
|
/**
|
|
1599
|
-
*
|
|
1600
|
-
* The images should be returned without any unnecessary conversion.
|
|
1601
|
-
* If the API returns base64 encoded strings, the images should be returned
|
|
1602
|
-
* as base64 encoded strings. If the API returns binary data, the images should
|
|
1603
|
-
* be returned as binary data.
|
|
1664
|
+
* List of values to embed.
|
|
1604
1665
|
*/
|
|
1605
|
-
|
|
1666
|
+
values: Array<VALUE>;
|
|
1606
1667
|
/**
|
|
1607
|
-
*
|
|
1668
|
+
* Abort signal for cancelling the operation.
|
|
1608
1669
|
*/
|
|
1609
|
-
|
|
1670
|
+
abortSignal?: AbortSignal;
|
|
1671
|
+
/**
|
|
1672
|
+
* Additional provider-specific options. They are passed through
|
|
1673
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
1674
|
+
* functionality that can be fully encapsulated in the provider.
|
|
1675
|
+
*/
|
|
1676
|
+
providerOptions?: SharedV2ProviderOptions;
|
|
1677
|
+
/**
|
|
1678
|
+
* Additional HTTP headers to be sent with the request.
|
|
1679
|
+
* Only applicable for HTTP-based providers.
|
|
1680
|
+
*/
|
|
1681
|
+
headers?: Record<string, string | undefined>;
|
|
1682
|
+
}): PromiseLike<{
|
|
1683
|
+
/**
|
|
1684
|
+
* Generated embeddings. They are in the same order as the input values.
|
|
1685
|
+
*/
|
|
1686
|
+
embeddings: Array<EmbeddingModelV2Embedding>;
|
|
1687
|
+
/**
|
|
1688
|
+
* Token usage. We only have input tokens for embeddings.
|
|
1689
|
+
*/
|
|
1690
|
+
usage?: {
|
|
1691
|
+
tokens: number;
|
|
1692
|
+
};
|
|
1610
1693
|
/**
|
|
1611
1694
|
* Additional provider-specific metadata. They are passed through
|
|
1612
1695
|
* from the provider to the AI SDK and enable provider-specific
|
|
1613
1696
|
* results that can be fully encapsulated in the provider.
|
|
1614
|
-
*
|
|
1615
|
-
* The outer record is keyed by the provider name, and the inner
|
|
1616
|
-
* record is provider-specific metadata. It always includes an
|
|
1617
|
-
* `images` key with image-specific metadata
|
|
1618
|
-
*
|
|
1619
|
-
* ```ts
|
|
1620
|
-
* {
|
|
1621
|
-
* "openai": {
|
|
1622
|
-
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
1623
|
-
* }
|
|
1624
|
-
* }
|
|
1625
|
-
* ```
|
|
1626
1697
|
*/
|
|
1627
|
-
providerMetadata?:
|
|
1698
|
+
providerMetadata?: SharedV2ProviderMetadata;
|
|
1628
1699
|
/**
|
|
1629
|
-
*
|
|
1700
|
+
* Optional response information for debugging purposes.
|
|
1630
1701
|
*/
|
|
1631
|
-
response
|
|
1632
|
-
/**
|
|
1633
|
-
* Timestamp for the start of the generated response.
|
|
1634
|
-
*/
|
|
1635
|
-
timestamp: Date;
|
|
1702
|
+
response?: {
|
|
1636
1703
|
/**
|
|
1637
|
-
*
|
|
1704
|
+
* Response headers.
|
|
1638
1705
|
*/
|
|
1639
|
-
|
|
1706
|
+
headers?: SharedV2Headers;
|
|
1640
1707
|
/**
|
|
1641
|
-
*
|
|
1708
|
+
* The response body.
|
|
1642
1709
|
*/
|
|
1643
|
-
|
|
1710
|
+
body?: unknown;
|
|
1644
1711
|
};
|
|
1645
1712
|
}>;
|
|
1646
1713
|
};
|
|
1647
1714
|
|
|
1715
|
+
declare const symbol$e: unique symbol;
|
|
1648
1716
|
/**
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1651
|
-
* the behavior of ImageModelV4 operations.
|
|
1717
|
+
* Custom error class for AI SDK related errors.
|
|
1718
|
+
* @extends Error
|
|
1652
1719
|
*/
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
* Middleware specification version. Use `v4` for the current version.
|
|
1656
|
-
*/
|
|
1657
|
-
readonly specificationVersion: 'v4';
|
|
1658
|
-
/**
|
|
1659
|
-
* Override the provider name if desired.
|
|
1660
|
-
* @param options.model - The image model instance.
|
|
1661
|
-
*/
|
|
1662
|
-
overrideProvider?: (options: {
|
|
1663
|
-
model: ImageModelV4;
|
|
1664
|
-
}) => string;
|
|
1665
|
-
/**
|
|
1666
|
-
* Override the model ID if desired.
|
|
1667
|
-
* @param options.model - The image model instance.
|
|
1668
|
-
*/
|
|
1669
|
-
overrideModelId?: (options: {
|
|
1670
|
-
model: ImageModelV4;
|
|
1671
|
-
}) => string;
|
|
1720
|
+
declare class AISDKError extends Error {
|
|
1721
|
+
private readonly [symbol$e];
|
|
1672
1722
|
/**
|
|
1673
|
-
*
|
|
1674
|
-
* @param options.model - The image model instance.
|
|
1723
|
+
* The underlying cause of the error, if any.
|
|
1675
1724
|
*/
|
|
1676
|
-
|
|
1677
|
-
model: ImageModelV4;
|
|
1678
|
-
}) => ImageModelV4['maxImagesPerCall'];
|
|
1725
|
+
readonly cause?: unknown;
|
|
1679
1726
|
/**
|
|
1680
|
-
*
|
|
1681
|
-
*
|
|
1682
|
-
* @param
|
|
1683
|
-
* @
|
|
1727
|
+
* Creates an AI SDK Error.
|
|
1728
|
+
*
|
|
1729
|
+
* @param {Object} params - The parameters for creating the error.
|
|
1730
|
+
* @param {string} params.name - The name of the error.
|
|
1731
|
+
* @param {string} params.message - The error message.
|
|
1732
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
1684
1733
|
*/
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1734
|
+
constructor({ name, message, cause, }: {
|
|
1735
|
+
name: string;
|
|
1736
|
+
message: string;
|
|
1737
|
+
cause?: unknown;
|
|
1738
|
+
});
|
|
1689
1739
|
/**
|
|
1690
|
-
*
|
|
1691
|
-
*
|
|
1692
|
-
* @
|
|
1693
|
-
* @param options.doGenerate - The original generate function.
|
|
1694
|
-
* @param options.params - The parameters for the generate call. If the
|
|
1695
|
-
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
1696
|
-
* @param options.model - The image model instance.
|
|
1697
|
-
* @returns A promise that resolves to the result of the generate operation.
|
|
1740
|
+
* Checks if the given error is an AI SDK Error.
|
|
1741
|
+
* @param {unknown} error - The error to check.
|
|
1742
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
1698
1743
|
*/
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1744
|
+
static isInstance(error: unknown): error is AISDKError;
|
|
1745
|
+
protected static hasMarker(error: unknown, marker: string): boolean;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
declare const symbol$d: unique symbol;
|
|
1749
|
+
declare class APICallError extends AISDKError {
|
|
1750
|
+
private readonly [symbol$d];
|
|
1751
|
+
readonly url: string;
|
|
1752
|
+
readonly requestBodyValues: unknown;
|
|
1753
|
+
readonly statusCode?: number;
|
|
1754
|
+
readonly responseHeaders?: Record<string, string>;
|
|
1755
|
+
readonly responseBody?: string;
|
|
1756
|
+
readonly isRetryable: boolean;
|
|
1757
|
+
readonly data?: unknown;
|
|
1758
|
+
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable, // server error
|
|
1759
|
+
data, }: {
|
|
1760
|
+
message: string;
|
|
1761
|
+
url: string;
|
|
1762
|
+
requestBodyValues: unknown;
|
|
1763
|
+
statusCode?: number;
|
|
1764
|
+
responseHeaders?: Record<string, string>;
|
|
1765
|
+
responseBody?: string;
|
|
1766
|
+
cause?: unknown;
|
|
1767
|
+
isRetryable?: boolean;
|
|
1768
|
+
data?: unknown;
|
|
1769
|
+
});
|
|
1770
|
+
static isInstance(error: unknown): error is APICallError;
|
|
1771
|
+
}
|
|
1705
1772
|
|
|
1773
|
+
declare const symbol$c: unique symbol;
|
|
1774
|
+
declare class EmptyResponseBodyError extends AISDKError {
|
|
1775
|
+
private readonly [symbol$c];
|
|
1776
|
+
constructor({ message }?: {
|
|
1777
|
+
message?: string;
|
|
1778
|
+
});
|
|
1779
|
+
static isInstance(error: unknown): error is EmptyResponseBodyError;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
declare function getErrorMessage(error: unknown | undefined): string;
|
|
1783
|
+
|
|
1784
|
+
declare const symbol$b: unique symbol;
|
|
1706
1785
|
/**
|
|
1707
|
-
*
|
|
1708
|
-
* This type defines the structure for middleware that can be used to modify
|
|
1709
|
-
* the behavior of ImageModelV3 operations.
|
|
1786
|
+
* A function argument is invalid.
|
|
1710
1787
|
*/
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
model: ImageModelV3;
|
|
1722
|
-
}) => string;
|
|
1723
|
-
/**
|
|
1724
|
-
* Override the model ID if desired.
|
|
1725
|
-
* @param options.model - The image model instance.
|
|
1726
|
-
*/
|
|
1727
|
-
overrideModelId?: (options: {
|
|
1728
|
-
model: ImageModelV3;
|
|
1729
|
-
}) => string;
|
|
1730
|
-
/**
|
|
1731
|
-
* Override the limit of how many images can be generated in a single API call if desired.
|
|
1732
|
-
* @param options.model - The image model instance.
|
|
1733
|
-
*/
|
|
1734
|
-
overrideMaxImagesPerCall?: (options: {
|
|
1735
|
-
model: ImageModelV3;
|
|
1736
|
-
}) => ImageModelV3['maxImagesPerCall'];
|
|
1737
|
-
/**
|
|
1738
|
-
* Transforms the parameters before they are passed to the image model.
|
|
1739
|
-
* @param options - Object containing the parameters.
|
|
1740
|
-
* @param options.params - The original parameters for the image model call.
|
|
1741
|
-
* @returns A promise that resolves to the transformed parameters.
|
|
1742
|
-
*/
|
|
1743
|
-
transformParams?: (options: {
|
|
1744
|
-
params: ImageModelV3CallOptions;
|
|
1745
|
-
model: ImageModelV3;
|
|
1746
|
-
}) => PromiseLike<ImageModelV3CallOptions>;
|
|
1747
|
-
/**
|
|
1748
|
-
* Wraps the generate operation of the image model.
|
|
1749
|
-
*
|
|
1750
|
-
* @param options - Object containing the generate function, parameters, and model.
|
|
1751
|
-
* @param options.doGenerate - The original generate function.
|
|
1752
|
-
* @param options.params - The parameters for the generate call. If the
|
|
1753
|
-
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
1754
|
-
* @param options.model - The image model instance.
|
|
1755
|
-
* @returns A promise that resolves to the result of the generate operation.
|
|
1756
|
-
*/
|
|
1757
|
-
wrapGenerate?: (options: {
|
|
1758
|
-
doGenerate: () => ReturnType<ImageModelV3['doGenerate']>;
|
|
1759
|
-
params: ImageModelV3CallOptions;
|
|
1760
|
-
model: ImageModelV3;
|
|
1761
|
-
}) => Promise<Awaited<ReturnType<ImageModelV3['doGenerate']>>>;
|
|
1762
|
-
};
|
|
1788
|
+
declare class InvalidArgumentError extends AISDKError {
|
|
1789
|
+
private readonly [symbol$b];
|
|
1790
|
+
readonly argument: string;
|
|
1791
|
+
constructor({ message, cause, argument, }: {
|
|
1792
|
+
argument: string;
|
|
1793
|
+
message: string;
|
|
1794
|
+
cause?: unknown;
|
|
1795
|
+
});
|
|
1796
|
+
static isInstance(error: unknown): error is InvalidArgumentError;
|
|
1797
|
+
}
|
|
1763
1798
|
|
|
1799
|
+
declare const symbol$a: unique symbol;
|
|
1764
1800
|
/**
|
|
1765
|
-
* A
|
|
1766
|
-
*
|
|
1767
|
-
* Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
1768
|
-
* map the user-facing tool definitions to this format.
|
|
1801
|
+
* A prompt is invalid. This error should be thrown by providers when they cannot
|
|
1802
|
+
* process a prompt.
|
|
1769
1803
|
*/
|
|
1770
|
-
|
|
1804
|
+
declare class InvalidPromptError extends AISDKError {
|
|
1805
|
+
private readonly [symbol$a];
|
|
1806
|
+
readonly prompt: unknown;
|
|
1807
|
+
constructor({ prompt, message, cause, }: {
|
|
1808
|
+
prompt: unknown;
|
|
1809
|
+
message: string;
|
|
1810
|
+
cause?: unknown;
|
|
1811
|
+
});
|
|
1812
|
+
static isInstance(error: unknown): error is InvalidPromptError;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
declare const symbol$9: unique symbol;
|
|
1816
|
+
/**
|
|
1817
|
+
* Server returned a response with invalid data content.
|
|
1818
|
+
* This should be thrown by providers when they cannot parse the response from the API.
|
|
1819
|
+
*/
|
|
1820
|
+
declare class InvalidResponseDataError extends AISDKError {
|
|
1821
|
+
private readonly [symbol$9];
|
|
1822
|
+
readonly data: unknown;
|
|
1823
|
+
constructor({ data, message, }: {
|
|
1824
|
+
data: unknown;
|
|
1825
|
+
message?: string;
|
|
1826
|
+
});
|
|
1827
|
+
static isInstance(error: unknown): error is InvalidResponseDataError;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
declare const symbol$8: unique symbol;
|
|
1831
|
+
declare class JSONParseError extends AISDKError {
|
|
1832
|
+
private readonly [symbol$8];
|
|
1833
|
+
readonly text: string;
|
|
1834
|
+
constructor({ text, cause }: {
|
|
1835
|
+
text: string;
|
|
1836
|
+
cause: unknown;
|
|
1837
|
+
});
|
|
1838
|
+
static isInstance(error: unknown): error is JSONParseError;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
declare const symbol$7: unique symbol;
|
|
1842
|
+
declare class LoadAPIKeyError extends AISDKError {
|
|
1843
|
+
private readonly [symbol$7];
|
|
1844
|
+
constructor({ message }: {
|
|
1845
|
+
message: string;
|
|
1846
|
+
});
|
|
1847
|
+
static isInstance(error: unknown): error is LoadAPIKeyError;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
declare const symbol$6: unique symbol;
|
|
1851
|
+
declare class LoadSettingError extends AISDKError {
|
|
1852
|
+
private readonly [symbol$6];
|
|
1853
|
+
constructor({ message }: {
|
|
1854
|
+
message: string;
|
|
1855
|
+
});
|
|
1856
|
+
static isInstance(error: unknown): error is LoadSettingError;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
declare const symbol$5: unique symbol;
|
|
1860
|
+
/**
|
|
1861
|
+
* Thrown when the AI provider fails to generate any content.
|
|
1862
|
+
*/
|
|
1863
|
+
declare class NoContentGeneratedError extends AISDKError {
|
|
1864
|
+
private readonly [symbol$5];
|
|
1865
|
+
constructor({ message, }?: {
|
|
1866
|
+
message?: string;
|
|
1867
|
+
});
|
|
1868
|
+
static isInstance(error: unknown): error is NoContentGeneratedError;
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
declare const symbol$4: unique symbol;
|
|
1872
|
+
declare class NoSuchModelError extends AISDKError {
|
|
1873
|
+
private readonly [symbol$4];
|
|
1874
|
+
readonly modelId: string;
|
|
1875
|
+
readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
|
|
1876
|
+
constructor({ errorName, modelId, modelType, message, }: {
|
|
1877
|
+
errorName?: string;
|
|
1878
|
+
modelId: string;
|
|
1879
|
+
modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
|
|
1880
|
+
message?: string;
|
|
1881
|
+
});
|
|
1882
|
+
static isInstance(error: unknown): error is NoSuchModelError;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
declare const symbol$3: unique symbol;
|
|
1886
|
+
/**
|
|
1887
|
+
* Thrown when a provider reference cannot be resolved because the specified
|
|
1888
|
+
* provider is not found in the provider reference mapping.
|
|
1889
|
+
*/
|
|
1890
|
+
declare class NoSuchProviderReferenceError extends AISDKError {
|
|
1891
|
+
private readonly [symbol$3];
|
|
1892
|
+
readonly provider: string;
|
|
1893
|
+
readonly reference: SharedV4ProviderReference;
|
|
1894
|
+
constructor({ provider, reference, message, }: {
|
|
1895
|
+
provider: string;
|
|
1896
|
+
reference: SharedV4ProviderReference;
|
|
1897
|
+
message?: string;
|
|
1898
|
+
});
|
|
1899
|
+
static isInstance(error: unknown): error is NoSuchProviderReferenceError;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
declare const symbol$2: unique symbol;
|
|
1903
|
+
declare class TooManyEmbeddingValuesForCallError extends AISDKError {
|
|
1904
|
+
private readonly [symbol$2];
|
|
1905
|
+
readonly provider: string;
|
|
1906
|
+
readonly modelId: string;
|
|
1907
|
+
readonly maxEmbeddingsPerCall: number;
|
|
1908
|
+
readonly values: Array<unknown>;
|
|
1909
|
+
constructor(options: {
|
|
1910
|
+
provider: string;
|
|
1911
|
+
modelId: string;
|
|
1912
|
+
maxEmbeddingsPerCall: number;
|
|
1913
|
+
values: Array<unknown>;
|
|
1914
|
+
});
|
|
1915
|
+
static isInstance(error: unknown): error is TooManyEmbeddingValuesForCallError;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
declare const symbol$1: unique symbol;
|
|
1919
|
+
interface TypeValidationContext {
|
|
1771
1920
|
/**
|
|
1772
|
-
*
|
|
1921
|
+
* Field path in dot notation (e.g., "message.metadata", "message.parts[3].data")
|
|
1773
1922
|
*/
|
|
1774
|
-
|
|
1923
|
+
field?: string;
|
|
1775
1924
|
/**
|
|
1776
|
-
*
|
|
1925
|
+
* Entity name (e.g., tool name, data type name)
|
|
1777
1926
|
*/
|
|
1778
|
-
|
|
1927
|
+
entityName?: string;
|
|
1779
1928
|
/**
|
|
1780
|
-
*
|
|
1781
|
-
* tool's purpose and to provide better completion suggestions.
|
|
1929
|
+
* Entity identifier (e.g., message ID, tool call ID)
|
|
1782
1930
|
*/
|
|
1783
|
-
|
|
1931
|
+
entityId?: string;
|
|
1932
|
+
}
|
|
1933
|
+
declare class TypeValidationError extends AISDKError {
|
|
1934
|
+
private readonly [symbol$1];
|
|
1935
|
+
readonly value: unknown;
|
|
1936
|
+
readonly context?: TypeValidationContext;
|
|
1937
|
+
constructor({ value, cause, context, }: {
|
|
1938
|
+
value: unknown;
|
|
1939
|
+
cause: unknown;
|
|
1940
|
+
context?: TypeValidationContext;
|
|
1941
|
+
});
|
|
1942
|
+
static isInstance(error: unknown): error is TypeValidationError;
|
|
1784
1943
|
/**
|
|
1785
|
-
*
|
|
1786
|
-
*
|
|
1944
|
+
* Wraps an error into a TypeValidationError.
|
|
1945
|
+
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
1946
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
1947
|
+
*
|
|
1948
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
1949
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
1950
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
1951
|
+
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
1952
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
1787
1953
|
*/
|
|
1788
|
-
|
|
1954
|
+
static wrap({ value, cause, context, }: {
|
|
1955
|
+
value: unknown;
|
|
1956
|
+
cause: unknown;
|
|
1957
|
+
context?: TypeValidationContext;
|
|
1958
|
+
}): TypeValidationError;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
declare const symbol: unique symbol;
|
|
1962
|
+
declare class UnsupportedFunctionalityError extends AISDKError {
|
|
1963
|
+
private readonly [symbol];
|
|
1964
|
+
readonly functionality: string;
|
|
1965
|
+
constructor({ functionality, message, }: {
|
|
1966
|
+
functionality: string;
|
|
1967
|
+
message?: string;
|
|
1968
|
+
});
|
|
1969
|
+
static isInstance(error: unknown): error is UnsupportedFunctionalityError;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
/**
|
|
1973
|
+
* Options for deleting a file via the files interface.
|
|
1974
|
+
*/
|
|
1975
|
+
type FilesV4DeleteFileCallOptions = {
|
|
1789
1976
|
/**
|
|
1790
|
-
*
|
|
1791
|
-
* model what the input should look like.
|
|
1977
|
+
* The provider reference of the file, as returned by `uploadFile`.
|
|
1792
1978
|
*/
|
|
1793
|
-
|
|
1794
|
-
input: JSONObject;
|
|
1795
|
-
}>;
|
|
1979
|
+
file: SharedV4ProviderReference;
|
|
1796
1980
|
/**
|
|
1797
|
-
*
|
|
1798
|
-
*
|
|
1799
|
-
* Providers that support strict mode will use this setting to determine
|
|
1800
|
-
* how the input should be generated. Strict mode will always produce
|
|
1801
|
-
* valid inputs, but it might limit what input schemas are supported.
|
|
1981
|
+
* Abort signal for cancelling the operation.
|
|
1802
1982
|
*/
|
|
1803
|
-
|
|
1983
|
+
abortSignal?: AbortSignal;
|
|
1804
1984
|
/**
|
|
1805
|
-
*
|
|
1985
|
+
* Additional HTTP headers to be sent with the request.
|
|
1986
|
+
* Only applicable for HTTP-based providers.
|
|
1806
1987
|
*/
|
|
1807
|
-
|
|
1808
|
-
};
|
|
1809
|
-
|
|
1810
|
-
/**
|
|
1811
|
-
* A prompt is a list of messages.
|
|
1812
|
-
*
|
|
1813
|
-
* Note: Not all models and prompt formats support multi-modal inputs and
|
|
1814
|
-
* tool calls. The validation happens at runtime.
|
|
1815
|
-
*
|
|
1816
|
-
* Note: This is not a user-facing prompt. The AI SDK methods will map the
|
|
1817
|
-
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
1818
|
-
*/
|
|
1819
|
-
type LanguageModelV4Prompt = Array<LanguageModelV4Message>;
|
|
1820
|
-
type LanguageModelV4Message = ({
|
|
1821
|
-
role: 'system';
|
|
1822
|
-
content: string;
|
|
1823
|
-
} | {
|
|
1824
|
-
role: 'user';
|
|
1825
|
-
content: Array<LanguageModelV4TextPart | LanguageModelV4FilePart>;
|
|
1826
|
-
} | {
|
|
1827
|
-
role: 'assistant';
|
|
1828
|
-
content: Array<LanguageModelV4TextPart | LanguageModelV4FilePart | LanguageModelV4CustomPart | LanguageModelV4ReasoningPart | LanguageModelV4ReasoningFilePart | LanguageModelV4ToolCallPart | LanguageModelV4ToolResultPart>;
|
|
1829
|
-
} | {
|
|
1830
|
-
role: 'tool';
|
|
1831
|
-
content: Array<LanguageModelV4ToolResultPart | LanguageModelV4ToolApprovalResponsePart>;
|
|
1832
|
-
}) & {
|
|
1988
|
+
headers?: Record<string, string | undefined>;
|
|
1833
1989
|
/**
|
|
1834
1990
|
* Additional provider-specific options. They are passed through
|
|
1835
1991
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -1837,421 +1993,366 @@ type LanguageModelV4Message = ({
|
|
|
1837
1993
|
*/
|
|
1838
1994
|
providerOptions?: SharedV4ProviderOptions;
|
|
1839
1995
|
};
|
|
1996
|
+
|
|
1840
1997
|
/**
|
|
1841
|
-
*
|
|
1998
|
+
* Result of deleting a file via the files interface.
|
|
1842
1999
|
*/
|
|
1843
|
-
|
|
1844
|
-
type: 'text';
|
|
1845
|
-
/**
|
|
1846
|
-
* The text content.
|
|
1847
|
-
*/
|
|
1848
|
-
text: string;
|
|
2000
|
+
type FilesV4DeleteFileResult = {
|
|
1849
2001
|
/**
|
|
1850
|
-
*
|
|
1851
|
-
*
|
|
1852
|
-
*
|
|
2002
|
+
* A provider reference mapping provider names to provider-specific file identifiers.
|
|
2003
|
+
* Contains only the operated provider's entry — when working with a merged
|
|
2004
|
+
* multi-provider reference, do not reassign it with this result.
|
|
1853
2005
|
*/
|
|
1854
|
-
|
|
1855
|
-
}
|
|
1856
|
-
/**
|
|
1857
|
-
* Reasoning content part of a prompt. It contains a string of reasoning text.
|
|
1858
|
-
*/
|
|
1859
|
-
interface LanguageModelV4ReasoningPart {
|
|
1860
|
-
type: 'reasoning';
|
|
2006
|
+
providerReference: SharedV4ProviderReference;
|
|
1861
2007
|
/**
|
|
1862
|
-
*
|
|
2008
|
+
* Whether the provider confirmed the deletion.
|
|
1863
2009
|
*/
|
|
1864
|
-
|
|
2010
|
+
deleted: boolean;
|
|
1865
2011
|
/**
|
|
1866
|
-
* Additional provider-specific
|
|
2012
|
+
* Additional provider-specific metadata. They are passed through
|
|
1867
2013
|
* to the provider from the AI SDK and enable provider-specific
|
|
1868
2014
|
* functionality that can be fully encapsulated in the provider.
|
|
1869
2015
|
*/
|
|
1870
|
-
|
|
1871
|
-
|
|
2016
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
2017
|
+
/**
|
|
2018
|
+
* Warnings from the provider.
|
|
2019
|
+
*/
|
|
2020
|
+
warnings: Array<SharedV4Warning>;
|
|
2021
|
+
};
|
|
2022
|
+
|
|
1872
2023
|
/**
|
|
1873
|
-
*
|
|
2024
|
+
* Options for downloading file content via the files interface.
|
|
1874
2025
|
*/
|
|
1875
|
-
|
|
1876
|
-
type: 'reasoning-file';
|
|
2026
|
+
type FilesV4DownloadFileCallOptions = {
|
|
1877
2027
|
/**
|
|
1878
|
-
*
|
|
1879
|
-
*
|
|
1880
|
-
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
1881
|
-
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
2028
|
+
* The provider reference of the file, as returned by `uploadFile`.
|
|
1882
2029
|
*/
|
|
1883
|
-
|
|
2030
|
+
file: SharedV4ProviderReference;
|
|
1884
2031
|
/**
|
|
1885
|
-
*
|
|
1886
|
-
*
|
|
1887
|
-
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2032
|
+
* Abort signal for cancelling the operation.
|
|
1888
2033
|
*/
|
|
1889
|
-
|
|
2034
|
+
abortSignal?: AbortSignal;
|
|
2035
|
+
/**
|
|
2036
|
+
* Additional HTTP headers to be sent with the request.
|
|
2037
|
+
* Only applicable for HTTP-based providers.
|
|
2038
|
+
*/
|
|
2039
|
+
headers?: Record<string, string | undefined>;
|
|
1890
2040
|
/**
|
|
1891
2041
|
* Additional provider-specific options. They are passed through
|
|
1892
2042
|
* to the provider from the AI SDK and enable provider-specific
|
|
1893
2043
|
* functionality that can be fully encapsulated in the provider.
|
|
1894
2044
|
*/
|
|
1895
2045
|
providerOptions?: SharedV4ProviderOptions;
|
|
1896
|
-
}
|
|
2046
|
+
};
|
|
2047
|
+
|
|
1897
2048
|
/**
|
|
1898
|
-
*
|
|
1899
|
-
* payload beyond provider-specific options.
|
|
2049
|
+
* Result of downloading file content via the files interface.
|
|
1900
2050
|
*/
|
|
1901
|
-
|
|
1902
|
-
type: 'custom';
|
|
2051
|
+
type FilesV4DownloadFileResult = {
|
|
1903
2052
|
/**
|
|
1904
|
-
* The
|
|
2053
|
+
* The file content as a byte stream.
|
|
2054
|
+
* The consumer is responsible for draining or cancelling the stream.
|
|
1905
2055
|
*/
|
|
1906
|
-
|
|
2056
|
+
content: ReadableStream<Uint8Array>;
|
|
1907
2057
|
/**
|
|
1908
|
-
*
|
|
2058
|
+
* The IANA media type of the file, if available from the provider.
|
|
2059
|
+
*/
|
|
2060
|
+
mediaType?: string;
|
|
2061
|
+
/**
|
|
2062
|
+
* Additional provider-specific metadata. They are passed through
|
|
1909
2063
|
* to the provider from the AI SDK and enable provider-specific
|
|
1910
2064
|
* functionality that can be fully encapsulated in the provider.
|
|
1911
2065
|
*/
|
|
1912
|
-
|
|
1913
|
-
|
|
2066
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
2067
|
+
/**
|
|
2068
|
+
* Warnings from the provider.
|
|
2069
|
+
*/
|
|
2070
|
+
warnings: Array<SharedV4Warning>;
|
|
2071
|
+
};
|
|
2072
|
+
|
|
1914
2073
|
/**
|
|
1915
|
-
*
|
|
2074
|
+
* Options for retrieving file metadata via the files interface.
|
|
1916
2075
|
*/
|
|
1917
|
-
|
|
1918
|
-
type: 'file';
|
|
2076
|
+
type FilesV4GetFileMetadataCallOptions = {
|
|
1919
2077
|
/**
|
|
1920
|
-
*
|
|
2078
|
+
* The provider reference of the file, as returned by `uploadFile`.
|
|
1921
2079
|
*/
|
|
1922
|
-
|
|
2080
|
+
file: SharedV4ProviderReference;
|
|
1923
2081
|
/**
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
1927
|
-
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
1928
|
-
* - `{ type: 'reference', reference }`: a provider reference (`{ [provider]: id }`).
|
|
1929
|
-
* - `{ type: 'text', text }`: inline text content (e.g. an inline text document).
|
|
2082
|
+
* Abort signal for cancelling the operation.
|
|
1930
2083
|
*/
|
|
1931
|
-
|
|
2084
|
+
abortSignal?: AbortSignal;
|
|
1932
2085
|
/**
|
|
1933
|
-
*
|
|
1934
|
-
*
|
|
1935
|
-
*
|
|
1936
|
-
* `*`-subtype wildcards (e.g. `image/*`) are normalized as equivalent to the
|
|
1937
|
-
* top-level segment alone (e.g. `image`). Providers can use the helpers in
|
|
1938
|
-
* `@ai-sdk/provider-utils` (`isFullMediaType`, `getTopLevelMediaType`,
|
|
1939
|
-
* `detectMediaType`) to resolve the field according to their API
|
|
1940
|
-
* requirements.
|
|
1941
|
-
*
|
|
1942
|
-
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2086
|
+
* Additional HTTP headers to be sent with the request.
|
|
2087
|
+
* Only applicable for HTTP-based providers.
|
|
1943
2088
|
*/
|
|
1944
|
-
|
|
2089
|
+
headers?: Record<string, string | undefined>;
|
|
1945
2090
|
/**
|
|
1946
2091
|
* Additional provider-specific options. They are passed through
|
|
1947
2092
|
* to the provider from the AI SDK and enable provider-specific
|
|
1948
2093
|
* functionality that can be fully encapsulated in the provider.
|
|
1949
2094
|
*/
|
|
1950
2095
|
providerOptions?: SharedV4ProviderOptions;
|
|
1951
|
-
}
|
|
2096
|
+
};
|
|
2097
|
+
|
|
1952
2098
|
/**
|
|
1953
|
-
*
|
|
2099
|
+
* Result of retrieving file metadata via the files interface.
|
|
1954
2100
|
*/
|
|
1955
|
-
|
|
1956
|
-
type: 'tool-call';
|
|
2101
|
+
type FilesV4GetFileMetadataResult = {
|
|
1957
2102
|
/**
|
|
1958
|
-
*
|
|
2103
|
+
* A provider reference mapping provider names to provider-specific file identifiers.
|
|
2104
|
+
* Contains only the operated provider's entry — when working with a merged
|
|
2105
|
+
* multi-provider reference, do not reassign it with this result.
|
|
1959
2106
|
*/
|
|
1960
|
-
|
|
2107
|
+
providerReference: SharedV4ProviderReference;
|
|
1961
2108
|
/**
|
|
1962
|
-
*
|
|
2109
|
+
* The filename of the file, if available from the provider.
|
|
1963
2110
|
*/
|
|
1964
|
-
|
|
2111
|
+
filename?: string;
|
|
1965
2112
|
/**
|
|
1966
|
-
*
|
|
2113
|
+
* The IANA media type of the file, if available from the provider.
|
|
1967
2114
|
*/
|
|
1968
|
-
|
|
2115
|
+
mediaType?: string;
|
|
1969
2116
|
/**
|
|
1970
|
-
*
|
|
1971
|
-
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
2117
|
+
* The size of the file in bytes, if available from the provider.
|
|
1972
2118
|
*/
|
|
1973
|
-
|
|
2119
|
+
byteSize?: number;
|
|
1974
2120
|
/**
|
|
1975
|
-
*
|
|
1976
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
1977
|
-
* functionality that can be fully encapsulated in the provider.
|
|
2121
|
+
* When the file was created, if available from the provider.
|
|
1978
2122
|
*/
|
|
1979
|
-
|
|
1980
|
-
}
|
|
1981
|
-
/**
|
|
1982
|
-
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
1983
|
-
*/
|
|
1984
|
-
interface LanguageModelV4ToolResultPart {
|
|
1985
|
-
type: 'tool-result';
|
|
2123
|
+
createdAt?: Date;
|
|
1986
2124
|
/**
|
|
1987
|
-
*
|
|
2125
|
+
* When the provider will delete the file (retention expiry),
|
|
2126
|
+
* if available from the provider.
|
|
1988
2127
|
*/
|
|
1989
|
-
|
|
2128
|
+
expiresAt?: Date;
|
|
1990
2129
|
/**
|
|
1991
|
-
*
|
|
2130
|
+
* Additional provider-specific metadata. They are passed through
|
|
2131
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
2132
|
+
* functionality that can be fully encapsulated in the provider.
|
|
1992
2133
|
*/
|
|
1993
|
-
|
|
2134
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
2135
|
+
/**
|
|
2136
|
+
* Warnings from the provider.
|
|
2137
|
+
*/
|
|
2138
|
+
warnings: Array<SharedV4Warning>;
|
|
2139
|
+
};
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* File data variant containing a byte stream. Providers that support
|
|
2143
|
+
* streaming uploads send it without buffering the full file in memory.
|
|
2144
|
+
*/
|
|
2145
|
+
interface FilesV4UploadFileStreamData {
|
|
2146
|
+
type: 'stream';
|
|
2147
|
+
stream: ReadableStream<Uint8Array>;
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Options for uploading a file via the files interface.
|
|
2151
|
+
*/
|
|
2152
|
+
type FilesV4UploadFileCallOptions = {
|
|
1994
2153
|
/**
|
|
1995
|
-
*
|
|
2154
|
+
* The file data.
|
|
2155
|
+
*
|
|
2156
|
+
* - `{ type: 'data', data }`: raw bytes (`Uint8Array`) or a base64-encoded string.
|
|
2157
|
+
* - `{ type: 'text', text }`: inline text (UTF-8).
|
|
2158
|
+
* - `{ type: 'stream', stream }`: a byte stream (not buffered by providers
|
|
2159
|
+
* that support streaming uploads).
|
|
1996
2160
|
*/
|
|
1997
|
-
|
|
2161
|
+
data: SharedV4FileDataData | SharedV4FileDataText | FilesV4UploadFileStreamData;
|
|
1998
2162
|
/**
|
|
1999
|
-
*
|
|
2000
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
2001
|
-
* functionality that can be fully encapsulated in the provider.
|
|
2163
|
+
* The IANA media type of the file (e.g. `'application/pdf'`).
|
|
2002
2164
|
*/
|
|
2003
|
-
|
|
2004
|
-
}
|
|
2005
|
-
/**
|
|
2006
|
-
* Tool approval response content part of a prompt. It contains the user's
|
|
2007
|
-
* decision to approve or deny a provider-executed tool call.
|
|
2008
|
-
*/
|
|
2009
|
-
interface LanguageModelV4ToolApprovalResponsePart {
|
|
2010
|
-
type: 'tool-approval-response';
|
|
2165
|
+
mediaType: string;
|
|
2011
2166
|
/**
|
|
2012
|
-
*
|
|
2167
|
+
* The filename of the file.
|
|
2013
2168
|
*/
|
|
2014
|
-
|
|
2169
|
+
filename?: string;
|
|
2015
2170
|
/**
|
|
2016
|
-
*
|
|
2171
|
+
* Abort signal for cancelling the operation.
|
|
2017
2172
|
*/
|
|
2018
|
-
|
|
2173
|
+
abortSignal?: AbortSignal;
|
|
2019
2174
|
/**
|
|
2020
|
-
*
|
|
2175
|
+
* Additional HTTP headers to be sent with the request.
|
|
2176
|
+
* Only applicable for HTTP-based providers.
|
|
2021
2177
|
*/
|
|
2022
|
-
|
|
2178
|
+
headers?: Record<string, string | undefined>;
|
|
2023
2179
|
/**
|
|
2024
2180
|
* Additional provider-specific options. They are passed through
|
|
2025
2181
|
* to the provider from the AI SDK and enable provider-specific
|
|
2026
2182
|
* functionality that can be fully encapsulated in the provider.
|
|
2027
2183
|
*/
|
|
2028
2184
|
providerOptions?: SharedV4ProviderOptions;
|
|
2029
|
-
}
|
|
2185
|
+
};
|
|
2186
|
+
|
|
2030
2187
|
/**
|
|
2031
|
-
* Result of a
|
|
2188
|
+
* Result of uploading a file via the files interface.
|
|
2032
2189
|
*/
|
|
2033
|
-
type
|
|
2190
|
+
type FilesV4UploadFileResult = {
|
|
2034
2191
|
/**
|
|
2035
|
-
*
|
|
2192
|
+
* A provider reference mapping provider names to provider-specific file identifiers.
|
|
2193
|
+
* The key is the canonical provider name (e.g. `openai`) and may differ from
|
|
2194
|
+
* the interface's `provider` id (e.g. `openai.files`).
|
|
2036
2195
|
*/
|
|
2037
|
-
|
|
2038
|
-
value: string;
|
|
2196
|
+
providerReference: SharedV4ProviderReference;
|
|
2039
2197
|
/**
|
|
2040
|
-
*
|
|
2198
|
+
* The IANA media type of the uploaded file, if available from the provider.
|
|
2041
2199
|
*/
|
|
2042
|
-
|
|
2043
|
-
} | {
|
|
2044
|
-
type: 'json';
|
|
2045
|
-
value: JSONValue;
|
|
2200
|
+
mediaType?: string;
|
|
2046
2201
|
/**
|
|
2047
|
-
*
|
|
2202
|
+
* The filename of the uploaded file, if available from the provider.
|
|
2048
2203
|
*/
|
|
2049
|
-
|
|
2050
|
-
} | {
|
|
2204
|
+
filename?: string;
|
|
2051
2205
|
/**
|
|
2052
|
-
*
|
|
2206
|
+
* The size of the uploaded file in bytes, if available from the provider.
|
|
2053
2207
|
*/
|
|
2054
|
-
|
|
2208
|
+
byteSize?: number;
|
|
2055
2209
|
/**
|
|
2056
|
-
*
|
|
2210
|
+
* When the file was created, if available from the provider.
|
|
2057
2211
|
*/
|
|
2058
|
-
|
|
2212
|
+
createdAt?: Date;
|
|
2059
2213
|
/**
|
|
2060
|
-
*
|
|
2214
|
+
* When the provider will delete the file (retention expiry, e.g. from a
|
|
2215
|
+
* requested upload TTL), if available from the provider.
|
|
2061
2216
|
*/
|
|
2062
|
-
|
|
2063
|
-
} | {
|
|
2064
|
-
type: 'error-text';
|
|
2065
|
-
value: string;
|
|
2217
|
+
expiresAt?: Date;
|
|
2066
2218
|
/**
|
|
2067
|
-
*
|
|
2219
|
+
* Additional provider-specific metadata. They are passed through
|
|
2220
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
2221
|
+
* functionality that can be fully encapsulated in the provider.
|
|
2068
2222
|
*/
|
|
2069
|
-
|
|
2070
|
-
} | {
|
|
2071
|
-
type: 'error-json';
|
|
2072
|
-
value: JSONValue;
|
|
2223
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
2073
2224
|
/**
|
|
2074
|
-
*
|
|
2225
|
+
* Warnings from the provider.
|
|
2075
2226
|
*/
|
|
2076
|
-
|
|
2077
|
-
} | {
|
|
2078
|
-
type: 'content';
|
|
2079
|
-
value: Array<{
|
|
2080
|
-
type: 'text';
|
|
2081
|
-
/**
|
|
2082
|
-
* Text content.
|
|
2083
|
-
*/
|
|
2084
|
-
text: string;
|
|
2085
|
-
/**
|
|
2086
|
-
* Provider-specific options.
|
|
2087
|
-
*/
|
|
2088
|
-
providerOptions?: SharedV4ProviderOptions;
|
|
2089
|
-
} | {
|
|
2090
|
-
type: 'file';
|
|
2091
|
-
/**
|
|
2092
|
-
* File data as a tagged discriminated union:
|
|
2093
|
-
*
|
|
2094
|
-
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
2095
|
-
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
2096
|
-
* - `{ type: 'reference', reference }`: a provider reference (`{ [provider]: id }`).
|
|
2097
|
-
* - `{ type: 'text', text }`: inline text content (e.g. an inline text document).
|
|
2098
|
-
*/
|
|
2099
|
-
data: SharedV4FileData;
|
|
2100
|
-
/**
|
|
2101
|
-
* Either a full IANA media type (`type/subtype`, e.g. `image/png`) or just
|
|
2102
|
-
* the top-level IANA segment (e.g. `image`, `audio`, `video`, `text`).
|
|
2103
|
-
*
|
|
2104
|
-
* `*`-subtype wildcards (e.g. `image/*`) are normalized as equivalent to the
|
|
2105
|
-
* top-level segment alone (e.g. `image`). Providers can use the helpers in
|
|
2106
|
-
* `@ai-sdk/provider-utils` (`isFullMediaType`, `getTopLevelMediaType`,
|
|
2107
|
-
* `detectMediaType`) to resolve the field according to their API
|
|
2108
|
-
* requirements.
|
|
2109
|
-
*
|
|
2110
|
-
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2111
|
-
*/
|
|
2112
|
-
mediaType: string;
|
|
2113
|
-
/**
|
|
2114
|
-
* Optional filename of the file.
|
|
2115
|
-
*/
|
|
2116
|
-
filename?: string;
|
|
2117
|
-
/**
|
|
2118
|
-
* Provider-specific options.
|
|
2119
|
-
*/
|
|
2120
|
-
providerOptions?: SharedV4ProviderOptions;
|
|
2121
|
-
} | {
|
|
2122
|
-
/**
|
|
2123
|
-
* Custom content part. This can be used to implement
|
|
2124
|
-
* provider-specific content parts.
|
|
2125
|
-
*/
|
|
2126
|
-
type: 'custom';
|
|
2127
|
-
/**
|
|
2128
|
-
* Provider-specific options.
|
|
2129
|
-
*/
|
|
2130
|
-
providerOptions?: SharedV4ProviderOptions;
|
|
2131
|
-
}>;
|
|
2227
|
+
warnings: Array<SharedV4Warning>;
|
|
2132
2228
|
};
|
|
2133
2229
|
|
|
2134
2230
|
/**
|
|
2135
|
-
*
|
|
2231
|
+
* Specification for a file management interface that implements the files interface version 4.
|
|
2136
2232
|
*
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2139
|
-
*
|
|
2233
|
+
* Only `uploadFile` is required. The other operations are optional
|
|
2234
|
+
* capabilities: their presence signals that the provider supports them
|
|
2235
|
+
* (mirroring the optional-method pattern of `VideoModelV4`).
|
|
2140
2236
|
*/
|
|
2141
|
-
type
|
|
2237
|
+
type FilesV4 = {
|
|
2142
2238
|
/**
|
|
2143
|
-
* The
|
|
2239
|
+
* The files interface must specify which files interface version it implements.
|
|
2144
2240
|
*/
|
|
2145
|
-
|
|
2241
|
+
readonly specificationVersion: 'v4';
|
|
2146
2242
|
/**
|
|
2147
|
-
*
|
|
2243
|
+
* Provider ID.
|
|
2148
2244
|
*/
|
|
2149
|
-
|
|
2245
|
+
readonly provider: string;
|
|
2150
2246
|
/**
|
|
2151
|
-
*
|
|
2247
|
+
* Uploads a file to the provider and returns a provider reference
|
|
2248
|
+
* that can be used in subsequent API calls.
|
|
2152
2249
|
*/
|
|
2153
|
-
|
|
2250
|
+
uploadFile(options: FilesV4UploadFileCallOptions): PromiseLike<FilesV4UploadFileResult>;
|
|
2154
2251
|
/**
|
|
2155
|
-
*
|
|
2252
|
+
* Retrieves metadata for a previously uploaded file.
|
|
2253
|
+
* Optional: presence signals that the provider supports metadata reads.
|
|
2156
2254
|
*/
|
|
2157
|
-
|
|
2158
|
-
};
|
|
2159
|
-
|
|
2160
|
-
type LanguageModelV4ToolChoice = {
|
|
2161
|
-
type: 'auto';
|
|
2162
|
-
} | {
|
|
2163
|
-
type: 'none';
|
|
2164
|
-
} | {
|
|
2165
|
-
type: 'required';
|
|
2166
|
-
} | {
|
|
2167
|
-
type: 'tool';
|
|
2168
|
-
toolName: string;
|
|
2169
|
-
};
|
|
2170
|
-
|
|
2171
|
-
type LanguageModelV4CallOptions = {
|
|
2255
|
+
getFileMetadata?(options: FilesV4GetFileMetadataCallOptions): PromiseLike<FilesV4GetFileMetadataResult>;
|
|
2172
2256
|
/**
|
|
2173
|
-
*
|
|
2174
|
-
*
|
|
2175
|
-
* Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
2176
|
-
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
2177
|
-
* That approach allows us to evolve the user facing prompts without breaking
|
|
2178
|
-
* the language model interface.
|
|
2257
|
+
* Downloads the content of a previously uploaded file as a byte stream.
|
|
2258
|
+
* Optional: presence signals that the provider supports content download.
|
|
2179
2259
|
*/
|
|
2180
|
-
|
|
2260
|
+
downloadFile?(options: FilesV4DownloadFileCallOptions): PromiseLike<FilesV4DownloadFileResult>;
|
|
2181
2261
|
/**
|
|
2182
|
-
*
|
|
2262
|
+
* Deletes a previously uploaded file.
|
|
2263
|
+
* Optional: presence signals that the provider supports deletion.
|
|
2183
2264
|
*/
|
|
2184
|
-
|
|
2265
|
+
deleteFile?(options: FilesV4DeleteFileCallOptions): PromiseLike<FilesV4DeleteFileResult>;
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
/**
|
|
2269
|
+
* An image file that can be used for image editing or variation generation.
|
|
2270
|
+
*/
|
|
2271
|
+
type ImageModelV4File = {
|
|
2272
|
+
type: 'file';
|
|
2185
2273
|
/**
|
|
2186
|
-
*
|
|
2274
|
+
* The IANA media type of the file, e.g. `image/png`. Any string is supported.
|
|
2275
|
+
*
|
|
2276
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2187
2277
|
*/
|
|
2188
|
-
|
|
2278
|
+
mediaType: string;
|
|
2189
2279
|
/**
|
|
2190
|
-
*
|
|
2191
|
-
*
|
|
2192
|
-
*
|
|
2280
|
+
* Generated file data as base64 encoded strings or binary data.
|
|
2281
|
+
*
|
|
2282
|
+
* The file data should be returned without any unnecessary conversion.
|
|
2283
|
+
* If the API returns base64 encoded strings, the file data should be returned
|
|
2284
|
+
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
2285
|
+
* be returned as binary data.
|
|
2193
2286
|
*/
|
|
2194
|
-
|
|
2287
|
+
data: string | Uint8Array;
|
|
2195
2288
|
/**
|
|
2196
|
-
*
|
|
2289
|
+
* Optional provider-specific metadata for the file part.
|
|
2197
2290
|
*/
|
|
2198
|
-
|
|
2291
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
2292
|
+
} | {
|
|
2293
|
+
type: 'url';
|
|
2199
2294
|
/**
|
|
2200
|
-
*
|
|
2201
|
-
*
|
|
2202
|
-
* Used to remove "long tail" low probability responses.
|
|
2203
|
-
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
2295
|
+
* The URL of the image file.
|
|
2204
2296
|
*/
|
|
2205
|
-
|
|
2297
|
+
url: string;
|
|
2206
2298
|
/**
|
|
2207
|
-
*
|
|
2208
|
-
* repeat information that is already in the prompt.
|
|
2299
|
+
* Optional provider-specific metadata for the file part.
|
|
2209
2300
|
*/
|
|
2210
|
-
|
|
2301
|
+
providerOptions?: SharedV4ProviderMetadata;
|
|
2302
|
+
};
|
|
2303
|
+
|
|
2304
|
+
type ImageModelV4CallOptions = {
|
|
2211
2305
|
/**
|
|
2212
|
-
*
|
|
2213
|
-
* to repeatedly use the same words or phrases.
|
|
2306
|
+
* Prompt for the image generation. Some operations, like upscaling, may not require a prompt.
|
|
2214
2307
|
*/
|
|
2215
|
-
|
|
2308
|
+
prompt: string | undefined;
|
|
2216
2309
|
/**
|
|
2217
|
-
*
|
|
2218
|
-
*
|
|
2219
|
-
* If JSON is selected, a schema can optionally be provided to guide the LLM.
|
|
2310
|
+
* Number of images to generate.
|
|
2220
2311
|
*/
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
schema?: JSONSchema7;
|
|
2229
|
-
/**
|
|
2230
|
-
* Name of output that should be generated. Used by some providers for additional LLM guidance.
|
|
2231
|
-
*/
|
|
2232
|
-
name?: string;
|
|
2233
|
-
/**
|
|
2234
|
-
* Description of the output that should be generated. Used by some providers for additional LLM guidance.
|
|
2235
|
-
*/
|
|
2236
|
-
description?: string;
|
|
2237
|
-
};
|
|
2312
|
+
n: number;
|
|
2313
|
+
/**
|
|
2314
|
+
* Size of the images to generate.
|
|
2315
|
+
* Must have the format `{width}x{height}`.
|
|
2316
|
+
* `undefined` will use the provider's default size.
|
|
2317
|
+
*/
|
|
2318
|
+
size: `${number}x${number}` | undefined;
|
|
2238
2319
|
/**
|
|
2239
|
-
*
|
|
2240
|
-
*
|
|
2320
|
+
* Aspect ratio of the images to generate.
|
|
2321
|
+
* Must have the format `{width}:{height}`.
|
|
2322
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
2241
2323
|
*/
|
|
2242
|
-
|
|
2324
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
2243
2325
|
/**
|
|
2244
|
-
*
|
|
2326
|
+
* Seed for the image generation.
|
|
2327
|
+
* `undefined` will use the provider's default seed.
|
|
2245
2328
|
*/
|
|
2246
|
-
|
|
2329
|
+
seed: number | undefined;
|
|
2247
2330
|
/**
|
|
2248
|
-
*
|
|
2331
|
+
* Array of images for image editing or variation generation.
|
|
2332
|
+
* The images should be provided as base64 encoded strings or binary data.
|
|
2249
2333
|
*/
|
|
2250
|
-
|
|
2334
|
+
files: ImageModelV4File[] | undefined;
|
|
2251
2335
|
/**
|
|
2252
|
-
*
|
|
2336
|
+
* Mask image for inpainting operations.
|
|
2337
|
+
* The mask should be provided as base64 encoded strings or binary data.
|
|
2253
2338
|
*/
|
|
2254
|
-
|
|
2339
|
+
mask: ImageModelV4File | undefined;
|
|
2340
|
+
/**
|
|
2341
|
+
* Additional provider-specific options that are passed through to the provider
|
|
2342
|
+
* as body parameters.
|
|
2343
|
+
*
|
|
2344
|
+
* The outer record is keyed by the provider name, and the inner
|
|
2345
|
+
* record is keyed by the provider-specific metadata key.
|
|
2346
|
+
*
|
|
2347
|
+
* ```ts
|
|
2348
|
+
* {
|
|
2349
|
+
* "openai": {
|
|
2350
|
+
* "style": "vivid"
|
|
2351
|
+
* }
|
|
2352
|
+
* }
|
|
2353
|
+
* ```
|
|
2354
|
+
*/
|
|
2355
|
+
providerOptions: SharedV4ProviderOptions;
|
|
2255
2356
|
/**
|
|
2256
2357
|
* Abort signal for cancelling the operation.
|
|
2257
2358
|
*/
|
|
@@ -2261,418 +2362,601 @@ type LanguageModelV4CallOptions = {
|
|
|
2261
2362
|
* Only applicable for HTTP-based providers.
|
|
2262
2363
|
*/
|
|
2263
2364
|
headers?: Record<string, string | undefined>;
|
|
2365
|
+
};
|
|
2366
|
+
|
|
2367
|
+
/**
|
|
2368
|
+
* Usage information for an image model call.
|
|
2369
|
+
*/
|
|
2370
|
+
type ImageModelV4Usage = {
|
|
2264
2371
|
/**
|
|
2265
|
-
*
|
|
2266
|
-
* the model performs before generating a response. Defaults to 'provider-default'.
|
|
2372
|
+
* The number of input (prompt) tokens used.
|
|
2267
2373
|
*/
|
|
2268
|
-
|
|
2374
|
+
inputTokens: number | undefined;
|
|
2269
2375
|
/**
|
|
2270
|
-
*
|
|
2271
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
2272
|
-
* functionality that can be fully encapsulated in the provider.
|
|
2376
|
+
* The number of output tokens used, if reported by the provider.
|
|
2273
2377
|
*/
|
|
2274
|
-
|
|
2378
|
+
outputTokens: number | undefined;
|
|
2379
|
+
/**
|
|
2380
|
+
* The total number of tokens as reported by the provider.
|
|
2381
|
+
*/
|
|
2382
|
+
totalTokens: number | undefined;
|
|
2275
2383
|
};
|
|
2276
2384
|
|
|
2385
|
+
type ImageModelV4ProviderMetadata = Record<string, {
|
|
2386
|
+
images: JSONArray;
|
|
2387
|
+
} & JSONValue>;
|
|
2277
2388
|
/**
|
|
2278
|
-
*
|
|
2279
|
-
* content part type.
|
|
2389
|
+
* The result of an image model doGenerate call.
|
|
2280
2390
|
*/
|
|
2281
|
-
type
|
|
2282
|
-
type: 'custom';
|
|
2391
|
+
type ImageModelV4Result = {
|
|
2283
2392
|
/**
|
|
2284
|
-
*
|
|
2393
|
+
* Generated images as base64 encoded strings or binary data.
|
|
2394
|
+
* The images should be returned without any unnecessary conversion.
|
|
2395
|
+
* If the API returns base64 encoded strings, the images should be returned
|
|
2396
|
+
* as base64 encoded strings. If the API returns binary data, the images should
|
|
2397
|
+
* be returned as binary data.
|
|
2285
2398
|
*/
|
|
2286
|
-
|
|
2399
|
+
images: Array<string> | Array<Uint8Array>;
|
|
2287
2400
|
/**
|
|
2288
|
-
*
|
|
2289
|
-
*
|
|
2290
|
-
* functionality that can be fully encapsulated in the provider.
|
|
2401
|
+
* Whether an unsuccessful result, such as an empty image result, can be
|
|
2402
|
+
* retried. When omitted, the result is unclassified.
|
|
2291
2403
|
*/
|
|
2292
|
-
|
|
2404
|
+
isRetryable?: boolean;
|
|
2405
|
+
/**
|
|
2406
|
+
* Warnings for the call, e.g. unsupported features.
|
|
2407
|
+
*/
|
|
2408
|
+
warnings: Array<SharedV4Warning>;
|
|
2409
|
+
/**
|
|
2410
|
+
* Additional provider-specific metadata. They are passed through
|
|
2411
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
2412
|
+
* results that can be fully encapsulated in the provider.
|
|
2413
|
+
*
|
|
2414
|
+
* The outer record is keyed by the provider name, and the inner
|
|
2415
|
+
* record is provider-specific metadata. It always includes an
|
|
2416
|
+
* `images` key with image-specific metadata
|
|
2417
|
+
*
|
|
2418
|
+
* ```ts
|
|
2419
|
+
* {
|
|
2420
|
+
* "openai": {
|
|
2421
|
+
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
2422
|
+
* }
|
|
2423
|
+
* }
|
|
2424
|
+
* ```
|
|
2425
|
+
*/
|
|
2426
|
+
providerMetadata?: ImageModelV4ProviderMetadata;
|
|
2427
|
+
/**
|
|
2428
|
+
* Response information for telemetry and debugging purposes.
|
|
2429
|
+
*/
|
|
2430
|
+
response: {
|
|
2431
|
+
/**
|
|
2432
|
+
* Timestamp for the start of the generated response.
|
|
2433
|
+
*/
|
|
2434
|
+
timestamp: Date;
|
|
2435
|
+
/**
|
|
2436
|
+
* The ID of the response model that was used to generate the response.
|
|
2437
|
+
*/
|
|
2438
|
+
modelId: string;
|
|
2439
|
+
/**
|
|
2440
|
+
* Response headers.
|
|
2441
|
+
*/
|
|
2442
|
+
headers: Record<string, string> | undefined;
|
|
2443
|
+
};
|
|
2444
|
+
/**
|
|
2445
|
+
* Optional token usage for the image generation call (if the provider reports it).
|
|
2446
|
+
*/
|
|
2447
|
+
usage?: ImageModelV4Usage;
|
|
2293
2448
|
};
|
|
2294
2449
|
|
|
2450
|
+
type GetMaxImagesPerCallFunction$2 = (options: {
|
|
2451
|
+
modelId: string;
|
|
2452
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
2295
2453
|
/**
|
|
2296
|
-
*
|
|
2297
|
-
* Generated files as base64 encoded strings or binary data.
|
|
2298
|
-
* The files should be returned without any unnecessary conversion.
|
|
2454
|
+
* Image generation model specification version 4.
|
|
2299
2455
|
*/
|
|
2300
|
-
type
|
|
2301
|
-
type: 'file';
|
|
2456
|
+
type ImageModelV4 = {
|
|
2302
2457
|
/**
|
|
2303
|
-
* The
|
|
2304
|
-
*
|
|
2305
|
-
*
|
|
2458
|
+
* The image model must specify which image model interface
|
|
2459
|
+
* version it implements. This will allow us to evolve the image
|
|
2460
|
+
* model interface and retain backwards compatibility. The different
|
|
2461
|
+
* implementation versions can be handled as a discriminated union
|
|
2462
|
+
* on our side.
|
|
2306
2463
|
*/
|
|
2307
|
-
|
|
2464
|
+
readonly specificationVersion: 'v4';
|
|
2308
2465
|
/**
|
|
2309
|
-
*
|
|
2310
|
-
*
|
|
2311
|
-
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
2312
|
-
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
2313
|
-
*
|
|
2314
|
-
* The file data should be returned without any unnecessary conversion.
|
|
2315
|
-
* If the API returns base64 encoded strings, the file data should be returned
|
|
2316
|
-
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
2317
|
-
* be returned as binary data.
|
|
2466
|
+
* Name of the provider for logging purposes.
|
|
2318
2467
|
*/
|
|
2319
|
-
|
|
2468
|
+
readonly provider: string;
|
|
2320
2469
|
/**
|
|
2321
|
-
*
|
|
2470
|
+
* Provider-specific model ID for logging purposes.
|
|
2322
2471
|
*/
|
|
2323
|
-
|
|
2472
|
+
readonly modelId: string;
|
|
2473
|
+
/**
|
|
2474
|
+
* Limit of how many images can be generated in a single API call.
|
|
2475
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
2476
|
+
* the global limit, or a function that returns a number or undefined,
|
|
2477
|
+
* optionally as a promise.
|
|
2478
|
+
*/
|
|
2479
|
+
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction$2;
|
|
2480
|
+
/**
|
|
2481
|
+
* Generates an array of images.
|
|
2482
|
+
*/
|
|
2483
|
+
doGenerate(options: ImageModelV4CallOptions): PromiseLike<ImageModelV4Result>;
|
|
2324
2484
|
};
|
|
2325
2485
|
|
|
2326
2486
|
/**
|
|
2327
|
-
*
|
|
2487
|
+
* Usage information for an image model call.
|
|
2328
2488
|
*/
|
|
2329
|
-
type
|
|
2330
|
-
type: 'reasoning';
|
|
2331
|
-
text: string;
|
|
2489
|
+
type ImageModelV3Usage = {
|
|
2332
2490
|
/**
|
|
2333
|
-
*
|
|
2491
|
+
* The number of input (prompt) tokens used.
|
|
2334
2492
|
*/
|
|
2335
|
-
|
|
2493
|
+
inputTokens: number | undefined;
|
|
2494
|
+
/**
|
|
2495
|
+
* The number of output tokens used, if reported by the provider.
|
|
2496
|
+
*/
|
|
2497
|
+
outputTokens: number | undefined;
|
|
2498
|
+
/**
|
|
2499
|
+
* The total number of tokens as reported by the provider.
|
|
2500
|
+
*/
|
|
2501
|
+
totalTokens: number | undefined;
|
|
2336
2502
|
};
|
|
2337
2503
|
|
|
2338
2504
|
/**
|
|
2339
|
-
*
|
|
2340
|
-
* Generated files as base64 encoded strings or binary data.
|
|
2341
|
-
* The files should be returned without any unnecessary conversion.
|
|
2505
|
+
* An image file that can be used for image editing or variation generation.
|
|
2342
2506
|
*/
|
|
2343
|
-
type
|
|
2344
|
-
type: '
|
|
2507
|
+
type ImageModelV3File = {
|
|
2508
|
+
type: 'file';
|
|
2345
2509
|
/**
|
|
2346
|
-
* The IANA media type of the file, e.g. `image/png
|
|
2510
|
+
* The IANA media type of the file, e.g. `image/png`. Any string is supported.
|
|
2347
2511
|
*
|
|
2348
2512
|
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2349
2513
|
*/
|
|
2350
2514
|
mediaType: string;
|
|
2351
2515
|
/**
|
|
2352
|
-
* Generated file data as
|
|
2353
|
-
*
|
|
2354
|
-
* - `{ type: 'data', data }`: raw bytes (Uint8Array) or base64-encoded string.
|
|
2355
|
-
* - `{ type: 'url', url }`: a URL that points to the file.
|
|
2516
|
+
* Generated file data as base64 encoded strings or binary data.
|
|
2356
2517
|
*
|
|
2357
2518
|
* The file data should be returned without any unnecessary conversion.
|
|
2358
2519
|
* If the API returns base64 encoded strings, the file data should be returned
|
|
2359
2520
|
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
2360
2521
|
* be returned as binary data.
|
|
2361
2522
|
*/
|
|
2362
|
-
data:
|
|
2363
|
-
/**
|
|
2364
|
-
* Optional provider-specific metadata for the reasoning file part.
|
|
2365
|
-
*/
|
|
2366
|
-
providerMetadata?: SharedV4ProviderMetadata;
|
|
2367
|
-
};
|
|
2368
|
-
|
|
2369
|
-
/**
|
|
2370
|
-
* A source that has been used as input to generate the response.
|
|
2371
|
-
*/
|
|
2372
|
-
type LanguageModelV4Source = {
|
|
2373
|
-
type: 'source';
|
|
2374
|
-
/**
|
|
2375
|
-
* The type of source - URL sources reference web content.
|
|
2376
|
-
*/
|
|
2377
|
-
sourceType: 'url';
|
|
2523
|
+
data: string | Uint8Array;
|
|
2378
2524
|
/**
|
|
2379
|
-
*
|
|
2525
|
+
* Optional provider-specific metadata for the file part.
|
|
2380
2526
|
*/
|
|
2381
|
-
|
|
2527
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
2528
|
+
} | {
|
|
2529
|
+
type: 'url';
|
|
2382
2530
|
/**
|
|
2383
|
-
* The URL of the
|
|
2531
|
+
* The URL of the image file.
|
|
2384
2532
|
*/
|
|
2385
2533
|
url: string;
|
|
2386
2534
|
/**
|
|
2387
|
-
*
|
|
2388
|
-
*/
|
|
2389
|
-
title?: string;
|
|
2390
|
-
/**
|
|
2391
|
-
* Additional provider metadata for the source.
|
|
2535
|
+
* Optional provider-specific metadata for the file part.
|
|
2392
2536
|
*/
|
|
2393
|
-
|
|
2394
|
-
}
|
|
2395
|
-
|
|
2537
|
+
providerOptions?: SharedV3ProviderMetadata;
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2540
|
+
type ImageModelV3CallOptions = {
|
|
2396
2541
|
/**
|
|
2397
|
-
*
|
|
2542
|
+
* Prompt for the image generation. Some operations, like upscaling, may not require a prompt.
|
|
2398
2543
|
*/
|
|
2399
|
-
|
|
2544
|
+
prompt: string | undefined;
|
|
2400
2545
|
/**
|
|
2401
|
-
*
|
|
2546
|
+
* Number of images to generate.
|
|
2402
2547
|
*/
|
|
2403
|
-
|
|
2548
|
+
n: number;
|
|
2404
2549
|
/**
|
|
2405
|
-
*
|
|
2550
|
+
* Size of the images to generate.
|
|
2551
|
+
* Must have the format `{width}x{height}`.
|
|
2552
|
+
* `undefined` will use the provider's default size.
|
|
2406
2553
|
*/
|
|
2407
|
-
|
|
2554
|
+
size: `${number}x${number}` | undefined;
|
|
2408
2555
|
/**
|
|
2409
|
-
*
|
|
2556
|
+
* Aspect ratio of the images to generate.
|
|
2557
|
+
* Must have the format `{width}:{height}`.
|
|
2558
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
2410
2559
|
*/
|
|
2411
|
-
|
|
2560
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
2412
2561
|
/**
|
|
2413
|
-
*
|
|
2562
|
+
* Seed for the image generation.
|
|
2563
|
+
* `undefined` will use the provider's default seed.
|
|
2414
2564
|
*/
|
|
2415
|
-
|
|
2565
|
+
seed: number | undefined;
|
|
2416
2566
|
/**
|
|
2417
|
-
*
|
|
2567
|
+
* Array of images for image editing or variation generation.
|
|
2568
|
+
* The images should be provided as base64 encoded strings or binary data.
|
|
2418
2569
|
*/
|
|
2419
|
-
|
|
2420
|
-
};
|
|
2421
|
-
|
|
2422
|
-
/**
|
|
2423
|
-
* Text that the model has generated.
|
|
2424
|
-
*/
|
|
2425
|
-
type LanguageModelV4Text = {
|
|
2426
|
-
type: 'text';
|
|
2570
|
+
files: ImageModelV3File[] | undefined;
|
|
2427
2571
|
/**
|
|
2428
|
-
*
|
|
2572
|
+
* Mask image for inpainting operations.
|
|
2573
|
+
* The mask should be provided as base64 encoded strings or binary data.
|
|
2429
2574
|
*/
|
|
2430
|
-
|
|
2431
|
-
providerMetadata?: SharedV4ProviderMetadata;
|
|
2432
|
-
};
|
|
2433
|
-
|
|
2434
|
-
/**
|
|
2435
|
-
* Tool approval request emitted by a provider for a provider-executed tool call.
|
|
2436
|
-
*
|
|
2437
|
-
* This is used for flows where the provider executes the tool (e.g. MCP tools)
|
|
2438
|
-
* but requires an explicit user approval before continuing.
|
|
2439
|
-
*/
|
|
2440
|
-
type LanguageModelV4ToolApprovalRequest = {
|
|
2441
|
-
type: 'tool-approval-request';
|
|
2575
|
+
mask: ImageModelV3File | undefined;
|
|
2442
2576
|
/**
|
|
2443
|
-
*
|
|
2444
|
-
*
|
|
2577
|
+
* Additional provider-specific options that are passed through to the provider
|
|
2578
|
+
* as body parameters.
|
|
2579
|
+
*
|
|
2580
|
+
* The outer record is keyed by the provider name, and the inner
|
|
2581
|
+
* record is keyed by the provider-specific metadata key.
|
|
2582
|
+
*
|
|
2583
|
+
* ```ts
|
|
2584
|
+
* {
|
|
2585
|
+
* "openai": {
|
|
2586
|
+
* "style": "vivid"
|
|
2587
|
+
* }
|
|
2588
|
+
* }
|
|
2589
|
+
* ```
|
|
2445
2590
|
*/
|
|
2446
|
-
|
|
2591
|
+
providerOptions: SharedV3ProviderOptions;
|
|
2447
2592
|
/**
|
|
2448
|
-
*
|
|
2593
|
+
* Abort signal for cancelling the operation.
|
|
2449
2594
|
*/
|
|
2450
|
-
|
|
2595
|
+
abortSignal?: AbortSignal;
|
|
2451
2596
|
/**
|
|
2452
|
-
* Additional
|
|
2597
|
+
* Additional HTTP headers to be sent with the request.
|
|
2598
|
+
* Only applicable for HTTP-based providers.
|
|
2453
2599
|
*/
|
|
2454
|
-
|
|
2600
|
+
headers?: Record<string, string | undefined>;
|
|
2455
2601
|
};
|
|
2456
2602
|
|
|
2603
|
+
type ImageModelV3ProviderMetadata = Record<string, {
|
|
2604
|
+
images: JSONArray;
|
|
2605
|
+
} & JSONValue>;
|
|
2606
|
+
type GetMaxImagesPerCallFunction$1 = (options: {
|
|
2607
|
+
modelId: string;
|
|
2608
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
2457
2609
|
/**
|
|
2458
|
-
*
|
|
2610
|
+
* Image generation model specification version 3.
|
|
2459
2611
|
*/
|
|
2460
|
-
type
|
|
2461
|
-
type: 'tool-call';
|
|
2462
|
-
/**
|
|
2463
|
-
* The identifier of the tool call. It must be unique across all tool calls.
|
|
2464
|
-
*/
|
|
2465
|
-
toolCallId: string;
|
|
2612
|
+
type ImageModelV3 = {
|
|
2466
2613
|
/**
|
|
2467
|
-
* The
|
|
2614
|
+
* The image model must specify which image model interface
|
|
2615
|
+
* version it implements. This will allow us to evolve the image
|
|
2616
|
+
* model interface and retain backwards compatibility. The different
|
|
2617
|
+
* implementation versions can be handled as a discriminated union
|
|
2618
|
+
* on our side.
|
|
2468
2619
|
*/
|
|
2469
|
-
|
|
2620
|
+
readonly specificationVersion: 'v3';
|
|
2470
2621
|
/**
|
|
2471
|
-
*
|
|
2472
|
-
* parameters schema of the tool.
|
|
2622
|
+
* Name of the provider for logging purposes.
|
|
2473
2623
|
*/
|
|
2474
|
-
|
|
2624
|
+
readonly provider: string;
|
|
2475
2625
|
/**
|
|
2476
|
-
*
|
|
2477
|
-
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
2626
|
+
* Provider-specific model ID for logging purposes.
|
|
2478
2627
|
*/
|
|
2479
|
-
|
|
2628
|
+
readonly modelId: string;
|
|
2480
2629
|
/**
|
|
2481
|
-
*
|
|
2482
|
-
*
|
|
2630
|
+
* Limit of how many images can be generated in a single API call.
|
|
2631
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
2632
|
+
* the global limit, or a function that returns a number or undefined,
|
|
2633
|
+
* optionally as a promise.
|
|
2483
2634
|
*/
|
|
2484
|
-
|
|
2635
|
+
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction$1;
|
|
2485
2636
|
/**
|
|
2486
|
-
*
|
|
2637
|
+
* Generates an array of images.
|
|
2487
2638
|
*/
|
|
2488
|
-
|
|
2639
|
+
doGenerate(options: ImageModelV3CallOptions): PromiseLike<{
|
|
2640
|
+
/**
|
|
2641
|
+
* Generated images as base64 encoded strings or binary data.
|
|
2642
|
+
* The images should be returned without any unnecessary conversion.
|
|
2643
|
+
* If the API returns base64 encoded strings, the images should be returned
|
|
2644
|
+
* as base64 encoded strings. If the API returns binary data, the images should
|
|
2645
|
+
* be returned as binary data.
|
|
2646
|
+
*/
|
|
2647
|
+
images: Array<string> | Array<Uint8Array>;
|
|
2648
|
+
/**
|
|
2649
|
+
* Warnings for the call, e.g. unsupported features.
|
|
2650
|
+
*/
|
|
2651
|
+
warnings: Array<SharedV3Warning>;
|
|
2652
|
+
/**
|
|
2653
|
+
* Additional provider-specific metadata. They are passed through
|
|
2654
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
2655
|
+
* results that can be fully encapsulated in the provider.
|
|
2656
|
+
*
|
|
2657
|
+
* The outer record is keyed by the provider name, and the inner
|
|
2658
|
+
* record is provider-specific metadata. It always includes an
|
|
2659
|
+
* `images` key with image-specific metadata
|
|
2660
|
+
*
|
|
2661
|
+
* ```ts
|
|
2662
|
+
* {
|
|
2663
|
+
* "openai": {
|
|
2664
|
+
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
2665
|
+
* }
|
|
2666
|
+
* }
|
|
2667
|
+
* ```
|
|
2668
|
+
*/
|
|
2669
|
+
providerMetadata?: ImageModelV3ProviderMetadata;
|
|
2670
|
+
/**
|
|
2671
|
+
* Response information for telemetry and debugging purposes.
|
|
2672
|
+
*/
|
|
2673
|
+
response: {
|
|
2674
|
+
/**
|
|
2675
|
+
* Timestamp for the start of the generated response.
|
|
2676
|
+
*/
|
|
2677
|
+
timestamp: Date;
|
|
2678
|
+
/**
|
|
2679
|
+
* The ID of the response model that was used to generate the response.
|
|
2680
|
+
*/
|
|
2681
|
+
modelId: string;
|
|
2682
|
+
/**
|
|
2683
|
+
* Response headers.
|
|
2684
|
+
*/
|
|
2685
|
+
headers: Record<string, string> | undefined;
|
|
2686
|
+
};
|
|
2687
|
+
/**
|
|
2688
|
+
* Optional token usage for the image generation call (if the provider reports it).
|
|
2689
|
+
*/
|
|
2690
|
+
usage?: ImageModelV3Usage;
|
|
2691
|
+
}>;
|
|
2489
2692
|
};
|
|
2490
2693
|
|
|
2491
|
-
|
|
2492
|
-
* Result of a tool call that has been executed by the provider.
|
|
2493
|
-
*/
|
|
2494
|
-
type LanguageModelV4ToolResult = {
|
|
2495
|
-
type: 'tool-result';
|
|
2694
|
+
type ImageModelV2CallOptions = {
|
|
2496
2695
|
/**
|
|
2497
|
-
*
|
|
2696
|
+
* Prompt for the image generation.
|
|
2498
2697
|
*/
|
|
2499
|
-
|
|
2698
|
+
prompt: string;
|
|
2500
2699
|
/**
|
|
2501
|
-
*
|
|
2700
|
+
* Number of images to generate.
|
|
2502
2701
|
*/
|
|
2503
|
-
|
|
2702
|
+
n: number;
|
|
2504
2703
|
/**
|
|
2505
|
-
*
|
|
2704
|
+
* Size of the images to generate.
|
|
2705
|
+
* Must have the format `{width}x{height}`.
|
|
2706
|
+
* `undefined` will use the provider's default size.
|
|
2506
2707
|
*/
|
|
2507
|
-
|
|
2708
|
+
size: `${number}x${number}` | undefined;
|
|
2508
2709
|
/**
|
|
2509
|
-
*
|
|
2710
|
+
* Aspect ratio of the images to generate.
|
|
2711
|
+
* Must have the format `{width}:{height}`.
|
|
2712
|
+
* `undefined` will use the provider's default aspect ratio.
|
|
2510
2713
|
*/
|
|
2511
|
-
|
|
2714
|
+
aspectRatio: `${number}:${number}` | undefined;
|
|
2512
2715
|
/**
|
|
2513
|
-
*
|
|
2514
|
-
*
|
|
2515
|
-
|
|
2516
|
-
|
|
2716
|
+
* Seed for the image generation.
|
|
2717
|
+
* `undefined` will use the provider's default seed.
|
|
2718
|
+
*/
|
|
2719
|
+
seed: number | undefined;
|
|
2720
|
+
/**
|
|
2721
|
+
* Additional provider-specific options that are passed through to the provider
|
|
2722
|
+
* as body parameters.
|
|
2517
2723
|
*
|
|
2518
|
-
*
|
|
2519
|
-
*
|
|
2724
|
+
* The outer record is keyed by the provider name, and the inner
|
|
2725
|
+
* record is keyed by the provider-specific metadata key.
|
|
2726
|
+
* ```ts
|
|
2727
|
+
* {
|
|
2728
|
+
* "openai": {
|
|
2729
|
+
* "style": "vivid"
|
|
2730
|
+
* }
|
|
2731
|
+
* }
|
|
2732
|
+
* ```
|
|
2520
2733
|
*/
|
|
2521
|
-
|
|
2734
|
+
providerOptions: SharedV2ProviderOptions;
|
|
2522
2735
|
/**
|
|
2523
|
-
*
|
|
2524
|
-
* For example, MCP (Model Context Protocol) tools that are executed by the provider.
|
|
2736
|
+
* Abort signal for cancelling the operation.
|
|
2525
2737
|
*/
|
|
2526
|
-
|
|
2738
|
+
abortSignal?: AbortSignal;
|
|
2527
2739
|
/**
|
|
2528
|
-
* Additional
|
|
2740
|
+
* Additional HTTP headers to be sent with the request.
|
|
2741
|
+
* Only applicable for HTTP-based providers.
|
|
2529
2742
|
*/
|
|
2530
|
-
|
|
2743
|
+
headers?: Record<string, string | undefined>;
|
|
2531
2744
|
};
|
|
2532
2745
|
|
|
2533
|
-
type LanguageModelV4Content = LanguageModelV4Text | LanguageModelV4Reasoning | LanguageModelV4CustomContent | LanguageModelV4ReasoningFile | LanguageModelV4File | LanguageModelV4ToolApprovalRequest | LanguageModelV4Source | LanguageModelV4ToolCall | LanguageModelV4ToolResult;
|
|
2534
|
-
|
|
2535
2746
|
/**
|
|
2536
|
-
*
|
|
2537
|
-
*
|
|
2538
|
-
* Contains both a unified finish reason and a raw finish reason from the provider.
|
|
2539
|
-
* The unified finish reason is used to provide a consistent finish reason across different providers.
|
|
2540
|
-
* The raw finish reason is used to provide the original finish reason from the provider.
|
|
2747
|
+
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
2748
|
+
* some settings might not be supported, which can lead to suboptimal results.
|
|
2541
2749
|
*/
|
|
2542
|
-
type
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
* - `content-filter`: content filter violation stopped the model
|
|
2550
|
-
* - `tool-calls`: model triggered tool calls
|
|
2551
|
-
* - `error`: model stopped because of an error
|
|
2552
|
-
* - `other`: model stopped for other reasons
|
|
2553
|
-
*/
|
|
2554
|
-
unified: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
|
|
2555
|
-
/**
|
|
2556
|
-
* Raw finish reason from the provider.
|
|
2557
|
-
* This is the original finish reason from the provider.
|
|
2558
|
-
*/
|
|
2559
|
-
raw: string | undefined;
|
|
2750
|
+
type ImageModelV2CallWarning = {
|
|
2751
|
+
type: 'unsupported-setting';
|
|
2752
|
+
setting: keyof ImageModelV2CallOptions;
|
|
2753
|
+
details?: string;
|
|
2754
|
+
} | {
|
|
2755
|
+
type: 'other';
|
|
2756
|
+
message: string;
|
|
2560
2757
|
};
|
|
2561
2758
|
|
|
2562
|
-
|
|
2759
|
+
type ImageModelV2ProviderMetadata = Record<string, {
|
|
2760
|
+
images: JSONArray;
|
|
2761
|
+
} & JSONValue>;
|
|
2762
|
+
type GetMaxImagesPerCallFunction = (options: {
|
|
2763
|
+
modelId: string;
|
|
2764
|
+
}) => PromiseLike<number | undefined> | number | undefined;
|
|
2765
|
+
/**
|
|
2766
|
+
* Image generation model specification version 2.
|
|
2767
|
+
*/
|
|
2768
|
+
type ImageModelV2 = {
|
|
2563
2769
|
/**
|
|
2564
|
-
*
|
|
2770
|
+
* The image model must specify which image model interface
|
|
2771
|
+
* version it implements. This will allow us to evolve the image
|
|
2772
|
+
* model interface and retain backwards compatibility. The different
|
|
2773
|
+
* implementation versions can be handled as a discriminated union
|
|
2774
|
+
* on our side.
|
|
2565
2775
|
*/
|
|
2566
|
-
|
|
2776
|
+
readonly specificationVersion: 'v2';
|
|
2567
2777
|
/**
|
|
2568
|
-
*
|
|
2778
|
+
* Name of the provider for logging purposes.
|
|
2569
2779
|
*/
|
|
2570
|
-
|
|
2780
|
+
readonly provider: string;
|
|
2571
2781
|
/**
|
|
2572
|
-
*
|
|
2782
|
+
* Provider-specific model ID for logging purposes.
|
|
2573
2783
|
*/
|
|
2574
|
-
modelId
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
/**
|
|
2578
|
-
* Usage information for a language model call.
|
|
2579
|
-
*/
|
|
2580
|
-
type LanguageModelV4Usage = {
|
|
2784
|
+
readonly modelId: string;
|
|
2581
2785
|
/**
|
|
2582
|
-
*
|
|
2786
|
+
* Limit of how many images can be generated in a single API call.
|
|
2787
|
+
* Can be set to a number for a fixed limit, to undefined to use
|
|
2788
|
+
* the global limit, or a function that returns a number or undefined,
|
|
2789
|
+
* optionally as a promise.
|
|
2583
2790
|
*/
|
|
2584
|
-
|
|
2791
|
+
readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction;
|
|
2792
|
+
/**
|
|
2793
|
+
* Generates an array of images.
|
|
2794
|
+
*/
|
|
2795
|
+
doGenerate(options: ImageModelV2CallOptions): PromiseLike<{
|
|
2585
2796
|
/**
|
|
2586
|
-
*
|
|
2797
|
+
* Generated images as base64 encoded strings or binary data.
|
|
2798
|
+
* The images should be returned without any unnecessary conversion.
|
|
2799
|
+
* If the API returns base64 encoded strings, the images should be returned
|
|
2800
|
+
* as base64 encoded strings. If the API returns binary data, the images should
|
|
2801
|
+
* be returned as binary data.
|
|
2587
2802
|
*/
|
|
2588
|
-
|
|
2803
|
+
images: Array<string> | Array<Uint8Array>;
|
|
2589
2804
|
/**
|
|
2590
|
-
*
|
|
2805
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
2591
2806
|
*/
|
|
2592
|
-
|
|
2807
|
+
warnings: Array<ImageModelV2CallWarning>;
|
|
2593
2808
|
/**
|
|
2594
|
-
*
|
|
2809
|
+
* Additional provider-specific metadata. They are passed through
|
|
2810
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
2811
|
+
* results that can be fully encapsulated in the provider.
|
|
2812
|
+
*
|
|
2813
|
+
* The outer record is keyed by the provider name, and the inner
|
|
2814
|
+
* record is provider-specific metadata. It always includes an
|
|
2815
|
+
* `images` key with image-specific metadata
|
|
2816
|
+
*
|
|
2817
|
+
* ```ts
|
|
2818
|
+
* {
|
|
2819
|
+
* "openai": {
|
|
2820
|
+
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
2821
|
+
* }
|
|
2822
|
+
* }
|
|
2823
|
+
* ```
|
|
2595
2824
|
*/
|
|
2596
|
-
|
|
2825
|
+
providerMetadata?: ImageModelV2ProviderMetadata;
|
|
2597
2826
|
/**
|
|
2598
|
-
*
|
|
2827
|
+
* Response information for telemetry and debugging purposes.
|
|
2599
2828
|
*/
|
|
2600
|
-
|
|
2601
|
-
|
|
2829
|
+
response: {
|
|
2830
|
+
/**
|
|
2831
|
+
* Timestamp for the start of the generated response.
|
|
2832
|
+
*/
|
|
2833
|
+
timestamp: Date;
|
|
2834
|
+
/**
|
|
2835
|
+
* The ID of the response model that was used to generate the response.
|
|
2836
|
+
*/
|
|
2837
|
+
modelId: string;
|
|
2838
|
+
/**
|
|
2839
|
+
* Response headers.
|
|
2840
|
+
*/
|
|
2841
|
+
headers: Record<string, string> | undefined;
|
|
2842
|
+
};
|
|
2843
|
+
}>;
|
|
2844
|
+
};
|
|
2845
|
+
|
|
2846
|
+
/**
|
|
2847
|
+
* Middleware for ImageModelV4.
|
|
2848
|
+
* This type defines the structure for middleware that can be used to modify
|
|
2849
|
+
* the behavior of ImageModelV4 operations.
|
|
2850
|
+
*/
|
|
2851
|
+
type ImageModelV4Middleware = {
|
|
2602
2852
|
/**
|
|
2603
|
-
*
|
|
2853
|
+
* Middleware specification version. Use `v4` for the current version.
|
|
2604
2854
|
*/
|
|
2605
|
-
|
|
2606
|
-
/**
|
|
2607
|
-
* The total number of output (completion) tokens used.
|
|
2608
|
-
*/
|
|
2609
|
-
total: number | undefined;
|
|
2610
|
-
/**
|
|
2611
|
-
* The number of text tokens used.
|
|
2612
|
-
*/
|
|
2613
|
-
text: number | undefined;
|
|
2614
|
-
/**
|
|
2615
|
-
* The number of reasoning tokens used.
|
|
2616
|
-
*/
|
|
2617
|
-
reasoning: number | undefined;
|
|
2618
|
-
};
|
|
2855
|
+
readonly specificationVersion: 'v4';
|
|
2619
2856
|
/**
|
|
2620
|
-
*
|
|
2857
|
+
* Override the provider name if desired.
|
|
2858
|
+
* @param options.model - The image model instance.
|
|
2859
|
+
*/
|
|
2860
|
+
overrideProvider?: (options: {
|
|
2861
|
+
model: ImageModelV4;
|
|
2862
|
+
}) => string;
|
|
2863
|
+
/**
|
|
2864
|
+
* Override the model ID if desired.
|
|
2865
|
+
* @param options.model - The image model instance.
|
|
2866
|
+
*/
|
|
2867
|
+
overrideModelId?: (options: {
|
|
2868
|
+
model: ImageModelV4;
|
|
2869
|
+
}) => string;
|
|
2870
|
+
/**
|
|
2871
|
+
* Override the limit of how many images can be generated in a single API call if desired.
|
|
2872
|
+
* @param options.model - The image model instance.
|
|
2873
|
+
*/
|
|
2874
|
+
overrideMaxImagesPerCall?: (options: {
|
|
2875
|
+
model: ImageModelV4;
|
|
2876
|
+
}) => ImageModelV4['maxImagesPerCall'];
|
|
2877
|
+
/**
|
|
2878
|
+
* Transforms the parameters before they are passed to the image model.
|
|
2879
|
+
* @param options - Object containing the parameters.
|
|
2880
|
+
* @param options.params - The original parameters for the image model call.
|
|
2881
|
+
* @returns A promise that resolves to the transformed parameters.
|
|
2882
|
+
*/
|
|
2883
|
+
transformParams?: (options: {
|
|
2884
|
+
params: ImageModelV4CallOptions;
|
|
2885
|
+
model: ImageModelV4;
|
|
2886
|
+
}) => PromiseLike<ImageModelV4CallOptions>;
|
|
2887
|
+
/**
|
|
2888
|
+
* Wraps the generate operation of the image model.
|
|
2621
2889
|
*
|
|
2622
|
-
*
|
|
2623
|
-
*
|
|
2890
|
+
* @param options - Object containing the generate function, parameters, and model.
|
|
2891
|
+
* @param options.doGenerate - The original generate function.
|
|
2892
|
+
* @param options.params - The parameters for the generate call. If the
|
|
2893
|
+
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
2894
|
+
* @param options.model - The image model instance.
|
|
2895
|
+
* @returns A promise that resolves to the result of the generate operation.
|
|
2624
2896
|
*/
|
|
2625
|
-
|
|
2897
|
+
wrapGenerate?: (options: {
|
|
2898
|
+
doGenerate: () => ReturnType<ImageModelV4['doGenerate']>;
|
|
2899
|
+
params: ImageModelV4CallOptions;
|
|
2900
|
+
model: ImageModelV4;
|
|
2901
|
+
}) => Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>>;
|
|
2626
2902
|
};
|
|
2627
2903
|
|
|
2628
2904
|
/**
|
|
2629
|
-
*
|
|
2905
|
+
* Middleware for ImageModelV3.
|
|
2906
|
+
* This type defines the structure for middleware that can be used to modify
|
|
2907
|
+
* the behavior of ImageModelV3 operations.
|
|
2630
2908
|
*/
|
|
2631
|
-
type
|
|
2632
|
-
/**
|
|
2633
|
-
* Ordered content that the model has generated.
|
|
2634
|
-
*/
|
|
2635
|
-
content: Array<LanguageModelV4Content>;
|
|
2909
|
+
type ImageModelV3Middleware = {
|
|
2636
2910
|
/**
|
|
2637
|
-
*
|
|
2911
|
+
* Middleware specification version. Use `v3` for the current version.
|
|
2638
2912
|
*/
|
|
2639
|
-
|
|
2913
|
+
readonly specificationVersion: 'v3';
|
|
2640
2914
|
/**
|
|
2641
|
-
*
|
|
2915
|
+
* Override the provider name if desired.
|
|
2916
|
+
* @param options.model - The image model instance.
|
|
2642
2917
|
*/
|
|
2643
|
-
|
|
2918
|
+
overrideProvider?: (options: {
|
|
2919
|
+
model: ImageModelV3;
|
|
2920
|
+
}) => string;
|
|
2644
2921
|
/**
|
|
2645
|
-
*
|
|
2646
|
-
*
|
|
2647
|
-
* results that can be fully encapsulated in the provider.
|
|
2922
|
+
* Override the model ID if desired.
|
|
2923
|
+
* @param options.model - The image model instance.
|
|
2648
2924
|
*/
|
|
2649
|
-
|
|
2925
|
+
overrideModelId?: (options: {
|
|
2926
|
+
model: ImageModelV3;
|
|
2927
|
+
}) => string;
|
|
2650
2928
|
/**
|
|
2651
|
-
*
|
|
2929
|
+
* Override the limit of how many images can be generated in a single API call if desired.
|
|
2930
|
+
* @param options.model - The image model instance.
|
|
2652
2931
|
*/
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
*/
|
|
2657
|
-
body?: unknown;
|
|
2658
|
-
};
|
|
2932
|
+
overrideMaxImagesPerCall?: (options: {
|
|
2933
|
+
model: ImageModelV3;
|
|
2934
|
+
}) => ImageModelV3['maxImagesPerCall'];
|
|
2659
2935
|
/**
|
|
2660
|
-
*
|
|
2936
|
+
* Transforms the parameters before they are passed to the image model.
|
|
2937
|
+
* @param options - Object containing the parameters.
|
|
2938
|
+
* @param options.params - The original parameters for the image model call.
|
|
2939
|
+
* @returns A promise that resolves to the transformed parameters.
|
|
2661
2940
|
*/
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
headers?: SharedV4Headers;
|
|
2667
|
-
/**
|
|
2668
|
-
* Response HTTP body.
|
|
2669
|
-
*/
|
|
2670
|
-
body?: unknown;
|
|
2671
|
-
};
|
|
2941
|
+
transformParams?: (options: {
|
|
2942
|
+
params: ImageModelV3CallOptions;
|
|
2943
|
+
model: ImageModelV3;
|
|
2944
|
+
}) => PromiseLike<ImageModelV3CallOptions>;
|
|
2672
2945
|
/**
|
|
2673
|
-
*
|
|
2946
|
+
* Wraps the generate operation of the image model.
|
|
2947
|
+
*
|
|
2948
|
+
* @param options - Object containing the generate function, parameters, and model.
|
|
2949
|
+
* @param options.doGenerate - The original generate function.
|
|
2950
|
+
* @param options.params - The parameters for the generate call. If the
|
|
2951
|
+
* `transformParams` middleware is used, this will be the transformed parameters.
|
|
2952
|
+
* @param options.model - The image model instance.
|
|
2953
|
+
* @returns A promise that resolves to the result of the generate operation.
|
|
2674
2954
|
*/
|
|
2675
|
-
|
|
2955
|
+
wrapGenerate?: (options: {
|
|
2956
|
+
doGenerate: () => ReturnType<ImageModelV3['doGenerate']>;
|
|
2957
|
+
params: ImageModelV3CallOptions;
|
|
2958
|
+
model: ImageModelV3;
|
|
2959
|
+
}) => Promise<Awaited<ReturnType<ImageModelV3['doGenerate']>>>;
|
|
2676
2960
|
};
|
|
2677
2961
|
|
|
2678
2962
|
type LanguageModelV4StreamPart = {
|
|
@@ -4942,25 +5226,6 @@ type EmbeddingModelV3Middleware = {
|
|
|
4942
5226
|
}) => Promise<Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>>;
|
|
4943
5227
|
};
|
|
4944
5228
|
|
|
4945
|
-
/**
|
|
4946
|
-
* A normalized language model call within a batch.
|
|
4947
|
-
*/
|
|
4948
|
-
type LanguageModelV4BatchRequest = {
|
|
4949
|
-
/**
|
|
4950
|
-
* Application-provided identifier used to correlate the request with its
|
|
4951
|
-
* result.
|
|
4952
|
-
*/
|
|
4953
|
-
readonly id: string;
|
|
4954
|
-
/**
|
|
4955
|
-
* Normalized text-generation options for the request.
|
|
4956
|
-
*/
|
|
4957
|
-
readonly options: Pick<LanguageModelV4CallOptions, 'prompt' | 'maxOutputTokens' | 'temperature' | 'stopSequences' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'seed' | 'reasoning' | 'responseFormat' | 'toolChoice' | 'tools' | 'providerOptions'>;
|
|
4958
|
-
};
|
|
4959
|
-
/**
|
|
4960
|
-
* Language model V4 with durable batch-processing support.
|
|
4961
|
-
*/
|
|
4962
|
-
type BatchLanguageModelV4 = LanguageModelV4 & BatchModelV4<LanguageModelV4BatchRequest, LanguageModelV4GenerateResult>;
|
|
4963
|
-
|
|
4964
5229
|
type RerankingModelV4CallOptions = {
|
|
4965
5230
|
/**
|
|
4966
5231
|
* Documents to rerank.
|
|
@@ -7948,4 +8213,4 @@ type VideoModelV3 = {
|
|
|
7948
8213
|
}>;
|
|
7949
8214
|
};
|
|
7950
8215
|
|
|
7951
|
-
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, type EmbeddingModelV4, type EmbeddingModelV4CallOptions, type EmbeddingModelV4Embedding, type EmbeddingModelV4Middleware, type EmbeddingModelV4Result, EmptyResponseBodyError, type
|
|
8216
|
+
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, type EmbeddingModelV4, type EmbeddingModelV4CallOptions, type EmbeddingModelV4Embedding, type EmbeddingModelV4Middleware, type EmbeddingModelV4Result, EmptyResponseBodyError, type BatchV4 as Experimental_BatchV4, type BatchV4Error as Experimental_BatchV4Error, type BatchV4ItemResult as Experimental_BatchV4ItemResult, type BatchV4ModelIds as Experimental_BatchV4ModelIds, type BatchV4OperationOptions as Experimental_BatchV4OperationOptions, type BatchV4Request as Experimental_BatchV4Request, type BatchV4RequestBase as Experimental_BatchV4RequestBase, type BatchV4StartOptions as Experimental_BatchV4StartOptions, type BatchV4StartResult as Experimental_BatchV4StartResult, type BatchV4Status as Experimental_BatchV4Status, type RealtimeFactoryV4 as Experimental_RealtimeFactoryV4, type RealtimeFactoryV4GetTokenOptions as Experimental_RealtimeFactoryV4GetTokenOptions, type RealtimeFactoryV4GetTokenResult as Experimental_RealtimeFactoryV4GetTokenResult, type RealtimeModelV4 as Experimental_RealtimeModelV4, type RealtimeModelV4AudioMessage as Experimental_RealtimeModelV4AudioMessage, type RealtimeModelV4ClientEvent as Experimental_RealtimeModelV4ClientEvent, type RealtimeModelV4ClientSecretOptions as Experimental_RealtimeModelV4ClientSecretOptions, type RealtimeModelV4ClientSecretResult as Experimental_RealtimeModelV4ClientSecretResult, type RealtimeModelV4ConversationItem as Experimental_RealtimeModelV4ConversationItem, type RealtimeModelV4FunctionCallOutput as Experimental_RealtimeModelV4FunctionCallOutput, type RealtimeModelV4ServerEvent as Experimental_RealtimeModelV4ServerEvent, type RealtimeModelV4SessionConfig as Experimental_RealtimeModelV4SessionConfig, type RealtimeModelV4TextMessage as Experimental_RealtimeModelV4TextMessage, type RealtimeModelV4ToolDefinition as Experimental_RealtimeModelV4ToolDefinition, type SpeechTranslationModelV4 as Experimental_SpeechTranslationModelV4, type SpeechTranslationModelV4StreamOptions as Experimental_SpeechTranslationModelV4StreamOptions, type SpeechTranslationModelV4StreamPart as Experimental_SpeechTranslationModelV4StreamPart, type SpeechTranslationModelV4StreamResult as Experimental_SpeechTranslationModelV4StreamResult, type SpeechTranslationModelV4Usage as Experimental_SpeechTranslationModelV4Usage, type TextBatchV4ItemResult as Experimental_TextBatchV4ItemResult, type TextBatchV4Request as Experimental_TextBatchV4Request, type TranscriptionModelV4StreamOptions as Experimental_TranscriptionModelV4StreamOptions, type TranscriptionModelV4StreamPart as Experimental_TranscriptionModelV4StreamPart, type TranscriptionModelV4StreamResult as Experimental_TranscriptionModelV4StreamResult, type VideoModelV3 as Experimental_VideoModelV3, type VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions, type VideoModelV3File as Experimental_VideoModelV3File, type VideoModelV3FrameImage as Experimental_VideoModelV3FrameImage, type VideoModelV3FrameType as Experimental_VideoModelV3FrameType, type VideoModelV3VideoData as Experimental_VideoModelV3VideoData, type VideoModelV4 as Experimental_VideoModelV4, type VideoModelV4CallOptions as Experimental_VideoModelV4CallOptions, type VideoModelV4File as Experimental_VideoModelV4File, type VideoModelV4FrameImage as Experimental_VideoModelV4FrameImage, type VideoModelV4FrameType as Experimental_VideoModelV4FrameType, type VideoModelV4OperationStartResult as Experimental_VideoModelV4OperationStartResult, type VideoModelV4OperationStatusResult as Experimental_VideoModelV4OperationStatusResult, type VideoModelV4OperationWebhook as Experimental_VideoModelV4OperationWebhook, type VideoModelV4Result as Experimental_VideoModelV4Result, type VideoModelV4VideoData as Experimental_VideoModelV4VideoData, type FilesV4, type FilesV4DeleteFileCallOptions, type FilesV4DeleteFileResult, type FilesV4DownloadFileCallOptions, type FilesV4DownloadFileResult, type FilesV4GetFileMetadataCallOptions, type FilesV4GetFileMetadataResult, type FilesV4UploadFileCallOptions, type FilesV4UploadFileResult, type FilesV4UploadFileStreamData, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3Middleware, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, type ImageModelV4, type ImageModelV4CallOptions, type ImageModelV4File, type ImageModelV4Middleware, type ImageModelV4ProviderMetadata, type ImageModelV4Result, type ImageModelV4Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, type LanguageModelV4, type LanguageModelV4CallOptions, type LanguageModelV4Content, type LanguageModelV4CustomContent, type LanguageModelV4CustomPart, type LanguageModelV4File, type LanguageModelV4FilePart, type LanguageModelV4FinishReason, type LanguageModelV4FunctionTool, type LanguageModelV4GenerateResult, type LanguageModelV4Message, type LanguageModelV4Middleware, type LanguageModelV4Prompt, type LanguageModelV4ProviderTool, type LanguageModelV4Reasoning, type LanguageModelV4ReasoningFile, type LanguageModelV4ReasoningFilePart, type LanguageModelV4ReasoningPart, type LanguageModelV4ResponseMetadata, type LanguageModelV4Source, type LanguageModelV4StreamPart, type LanguageModelV4StreamResult, type LanguageModelV4Text, type LanguageModelV4TextPart, type LanguageModelV4ToolApprovalRequest, type LanguageModelV4ToolApprovalResponsePart, type LanguageModelV4ToolCall, type LanguageModelV4ToolCallPart, type LanguageModelV4ToolChoice, type LanguageModelV4ToolResult, type LanguageModelV4ToolResultOutput, type LanguageModelV4ToolResultPart, type LanguageModelV4Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, NoSuchProviderReferenceError, type ProviderV2, type ProviderV3, type ProviderV4, type RerankingModelV3, type RerankingModelV3CallOptions, type RerankingModelV4, type RerankingModelV4CallOptions, type RerankingModelV4Result, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SharedV4AudioFormat, type SharedV4FileData, type SharedV4FileDataData, type SharedV4FileDataReference, type SharedV4FileDataText, type SharedV4FileDataUrl, type SharedV4Headers, type SharedV4ProviderMetadata, type SharedV4ProviderOptions, type SharedV4ProviderReference, type SharedV4Warning, type SkillsV4, type SkillsV4File, type SkillsV4UploadSkillCallOptions, type SkillsV4UploadSkillResult, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, type SpeechModelV4, type SpeechModelV4CallOptions, type SpeechModelV4Result, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TranscriptionModelV4, type TranscriptionModelV4CallOptions, type TranscriptionModelV4Result, type TypeValidationContext, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|