Skip to content

OpenAICompatibleLanguageModel

Namespace: Vercel.AI.OpenAICompatible

public sealed class OpenAICompatibleLanguageModel : ILanguageModel

Chat Completions language model.

Inheritance: object

Implements: ILanguageModel

View source

OpenAICompatibleLanguageModel(OpenAICompatibleProvider, string)

Section titled “OpenAICompatibleLanguageModel(OpenAICompatibleProvider, string)”
public OpenAICompatibleLanguageModel(OpenAICompatibleProvider provider, string modelId)

Creates a language model.

Parameters

Name Type Description
provider OpenAICompatibleProvider
modelId string

View source

OpenAICompatibleLanguageModel(OpenAICompatibleProvider, string, string?)

Section titled “OpenAICompatibleLanguageModel(OpenAICompatibleProvider, string, string?)”
public OpenAICompatibleLanguageModel(OpenAICompatibleProvider provider, string modelId, string? providerId)

Creates a language model with an explicit provider id such as anthropic.beta.

Parameters

Name Type Description
provider OpenAICompatibleProvider
modelId string
providerId string

View source

public Uri? Endpoint { get; set; }

When set, chat calls use this URL instead of the provider chat route.

Value: Uri

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 ProviderOptionsName { get; }

Provider-options key. The segment before the first dot of Provider.

Value: string

View source

public string SpecificationVersion { get; }

Always V4.

Value: string

View source

public bool SupportsStructuredOutputs { get; set; }

When true, JSON schema responses use json_schema.

Value: bool

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

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