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