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