Skip to content

AiClient

Namespace: Vercel.AI

public sealed class AiClient : IAiClient

Default IAiClient. String model ids are resolved by the AI Gateway.

Inheritance: object

Implements: IAiClient

View source

public AiClient(GatewayProvider gateway, IAiTelemetry? telemetry = null)

Creates a client.

Parameters

Name Type Description
gateway GatewayProvider
telemetry IAiTelemetry

View source

EmbedAsync(EmbedOptions, CancellationToken)

Section titled “EmbedAsync(EmbedOptions, CancellationToken)”
public Task<float[]> EmbedAsync(EmbedOptions options, CancellationToken cancellationToken = default)

Embeds one value. Maps to embed.

Parameters

Name Type Description
options EmbedOptions
cancellationToken CancellationToken

Returns: Task<float[]>

View source

EmbedManyAsync(EmbedOptions, CancellationToken)

Section titled “EmbedManyAsync(EmbedOptions, CancellationToken)”
public Task<EmbeddingResult> EmbedManyAsync(EmbedOptions options, CancellationToken cancellationToken = default)

Embeds many values. Maps to embedMany.

Parameters

Name Type Description
options EmbedOptions
cancellationToken CancellationToken

Returns: Task<EmbeddingResult>

View source

EvaluateAsync(EvaluateOptions, CancellationToken)

Section titled “EvaluateAsync(EvaluateOptions, CancellationToken)”
public Task<RubricResult> EvaluateAsync(EvaluateOptions options, CancellationToken cancellationToken = default)

Scores a candidate against a rubric. Uses RubricModel or a language model.

Parameters

Name Type Description
options EvaluateOptions
cancellationToken CancellationToken

Returns: Task<RubricResult>

View source

GenerateImageAsync(GenerateImageOptions, CancellationToken)

Section titled “GenerateImageAsync(GenerateImageOptions, CancellationToken)”
public Task<ImageGenerationResult> GenerateImageAsync(GenerateImageOptions options, CancellationToken cancellationToken = default)

Generates images. Maps to generateImage.

Parameters

Name Type Description
options GenerateImageOptions
cancellationToken CancellationToken

Returns: Task<ImageGenerationResult>

View source

GenerateSpeechAsync(GenerateSpeechOptions, CancellationToken)

Section titled “GenerateSpeechAsync(GenerateSpeechOptions, CancellationToken)”
public Task<SpeechResult> GenerateSpeechAsync(GenerateSpeechOptions options, CancellationToken cancellationToken = default)

Generates speech. Maps to generateSpeech.

Parameters

Name Type Description
options GenerateSpeechOptions
cancellationToken CancellationToken

Returns: Task<SpeechResult>

View source

GenerateTextAsync(GenerateTextOptions, CancellationToken)

Section titled “GenerateTextAsync(GenerateTextOptions, CancellationToken)”
public Task<GenerateTextResult> GenerateTextAsync(GenerateTextOptions options, CancellationToken cancellationToken = default)

Generates text and runs tools. Maps to generateText.

Parameters

Name Type Description
options GenerateTextOptions
cancellationToken CancellationToken

Returns: Task<GenerateTextResult>

View source

GenerateVideoAsync(GenerateVideoOptions, CancellationToken)

Section titled “GenerateVideoAsync(GenerateVideoOptions, CancellationToken)”
public Task<VideoResult> GenerateVideoAsync(GenerateVideoOptions options, CancellationToken cancellationToken = default)

Generates video. Maps to generateVideo.

Parameters

Name Type Description
options GenerateVideoOptions
cancellationToken CancellationToken

Returns: Task<VideoResult>

View source

RerankAsync(RerankOptions, CancellationToken)

Section titled “RerankAsync(RerankOptions, CancellationToken)”
public Task<RerankResult> RerankAsync(RerankOptions options, CancellationToken cancellationToken = default)

Reranks documents. Maps to rerank.

Parameters

Name Type Description
options RerankOptions
cancellationToken CancellationToken

Returns: Task<RerankResult>

View source

StreamTextAsync(StreamTextOptions, CancellationToken)

Section titled “StreamTextAsync(StreamTextOptions, CancellationToken)”
public StreamTextResult StreamTextAsync(StreamTextOptions options, CancellationToken cancellationToken = default)

Streams text and runs tools. Maps to streamText.

Parameters

Name Type Description
options StreamTextOptions
cancellationToken CancellationToken

Returns: StreamTextResult

View source

TranscribeAsync(TranscribeOptions, CancellationToken)

Section titled “TranscribeAsync(TranscribeOptions, CancellationToken)”
public Task<TranscriptionResult> TranscribeAsync(TranscribeOptions options, CancellationToken cancellationToken = default)

Transcribes audio. Maps to transcribe.

Parameters

Name Type Description
options TranscribeOptions
cancellationToken CancellationToken

Returns: Task<TranscriptionResult>

View source

TranslateAsync(TranslateOptions, CancellationToken)

Section titled “TranslateAsync(TranslateOptions, CancellationToken)”
public Task<TranscriptionResult> TranslateAsync(TranslateOptions options, CancellationToken cancellationToken = default)

Translates speech to text. Maps to translate.

Parameters

Name Type Description
options TranslateOptions
cancellationToken CancellationToken

Returns: Task<TranscriptionResult>

View source

UploadFileAsync(IFileStore, string, byte[], string, CancellationToken)

Section titled “UploadFileAsync(IFileStore, string, byte[], string, CancellationToken)”
public Task<UploadedFile> UploadFileAsync(IFileStore store, string fileName, byte[] data, string mediaType, CancellationToken cancellationToken = default)

Uploads a file through <code class=“paramref”>store</code>.

Parameters

Name Type Description
store IFileStore
fileName string
data byte[]
mediaType string
cancellationToken CancellationToken

Returns: Task<UploadedFile>

View source

UploadSkillAsync(ISkillStore, string, string, CancellationToken)

Section titled “UploadSkillAsync(ISkillStore, string, string, CancellationToken)”
public Task<UploadedSkill> UploadSkillAsync(ISkillStore store, string name, string instructions, CancellationToken cancellationToken = default)

Uploads a skill through <code class=“paramref”>store</code>.

Parameters

Name Type Description
store ISkillStore
name string
instructions string
cancellationToken CancellationToken

Returns: Task<UploadedSkill>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product