Skip to content

OpenAIChatLanguageModel

Namespace: Vercel.AI.OpenAI

public sealed class OpenAIChatLanguageModel : ILanguageModel

OpenAI Chat Completions language model.

Inheritance: object

Implements: ILanguageModel

View source

OpenAIChatLanguageModel(AzureOpenAIProvider, string, AzureOpenAILanguageModelSettings?)

Section titled “OpenAIChatLanguageModel(AzureOpenAIProvider, string, AzureOpenAILanguageModelSettings?)”
public OpenAIChatLanguageModel(AzureOpenAIProvider provider, string deploymentId, AzureOpenAILanguageModelSettings? settings)

Creates an Azure OpenAI Chat Completions model for a deployment. ModelId reports <code class=“paramref”>settings</code>.ModelId when set and drives capability detection. Requests always use <code class=“paramref”>deploymentId</code>.

Parameters

Name Type Description
provider AzureOpenAIProvider
deploymentId string
settings AzureOpenAILanguageModelSettings

View source

OpenAIChatLanguageModel(OpenAIProvider, string)

Section titled “OpenAIChatLanguageModel(OpenAIProvider, string)”
public OpenAIChatLanguageModel(OpenAIProvider provider, string modelId)

Creates a Chat Completions model.

Parameters

Name Type Description
provider OpenAIProvider
modelId string

View source

public string ModelId { get; }

Model id.

Value: string

View source

public string Provider { get; }

Provider id, such as openai.

Value: string

View source

public string SpecificationVersion { get; }

Always V4.

Value: string

View source

DoGenerateAsync(LanguageModelCallOptions, CancellationToken)

Section titled “DoGenerateAsync(LanguageModelCallOptions, CancellationToken)”
public Task<LanguageModelGenerateResult> DoGenerateAsync(LanguageModelCallOptions options, CancellationToken cancellationToken)

Generates a complete result.

Parameters

Name Type Description
options LanguageModelCallOptions
cancellationToken CancellationToken

Returns: Task<LanguageModelGenerateResult>

View source

DoStreamAsync(LanguageModelCallOptions, CancellationToken)

Section titled “DoStreamAsync(LanguageModelCallOptions, CancellationToken)”
public Task<LanguageModelStreamResult> DoStreamAsync(LanguageModelCallOptions options, CancellationToken cancellationToken)

Streams partial results. The result carries the stream with the request and response info.

Parameters

Name Type Description
options LanguageModelCallOptions
cancellationToken CancellationToken

Returns: Task<LanguageModelStreamResult>

View source

public static OpenAIChatPreparedRequest Prepare(string modelId, LanguageModelCallOptions options)

Builds the Chat Completions body for <code class=“paramref”>modelId</code>.

Parameters

Name Type Description
modelId string
options LanguageModelCallOptions

Returns: OpenAIChatPreparedRequest

View source

Prepare(string, LanguageModelCallOptions, string?)

Section titled “Prepare(string, LanguageModelCallOptions, string?)”
public static OpenAIChatPreparedRequest Prepare(string modelId, LanguageModelCallOptions options, string? requestModelId)

Builds the Chat Completions body. <code class=“paramref”>modelId</code> drives capability detection and <code class=“paramref”>requestModelId</code>, when set, is sent as the request model.

Parameters

Name Type Description
modelId string
options LanguageModelCallOptions
requestModelId string

Returns: OpenAIChatPreparedRequest

View source

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