Skip to content

AnthropicLanguageModel

Namespace: Vercel.AI.Anthropic

public class AnthropicLanguageModel : ILanguageModel

Anthropic Messages language model.

Inheritance: object

Implements: ILanguageModel

Derived: MiniMaxChatLanguageModel

View source

AnthropicLanguageModel(AnthropicProvider, string)

Section titled “AnthropicLanguageModel(AnthropicProvider, string)”
public AnthropicLanguageModel(AnthropicProvider provider, string modelId)

Creates a model.

Parameters

Name Type Description
provider AnthropicProvider
modelId string

View source

AnthropicLanguageModel(AnthropicProvider, string, AnthropicModelSettings?)

Section titled “AnthropicLanguageModel(AnthropicProvider, string, AnthropicModelSettings?)”
public AnthropicLanguageModel(AnthropicProvider provider, string modelId, AnthropicModelSettings? settings)

Creates a model for a Messages-compatible provider that adjusts the adapter with <code class=“paramref”>settings</code>.

Parameters

Name Type Description
provider AnthropicProvider
modelId string
settings AnthropicModelSettings

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

public virtual IReadOnlyDictionary<string, string> SupportedUrls { get; }

URL patterns the model accepts for images and PDFs.

Value: IReadOnlyDictionary<string, string>

View source

DoGenerateAsync(LanguageModelCallOptions, CancellationToken)

Section titled “DoGenerateAsync(LanguageModelCallOptions, CancellationToken)”
public virtual 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 virtual 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

PrepareCallOptions(LanguageModelCallOptions, IList<AnthropicWarning>)

Section titled “PrepareCallOptions(LanguageModelCallOptions, IList<AnthropicWarning>)”
protected virtual LanguageModelCallOptions PrepareCallOptions(LanguageModelCallOptions options, IList<AnthropicWarning> warnings)

Lets a compatible provider rewrite the call options before the request is built. Warnings added to <code class=“paramref”>warnings</code> are reported after the request’s own warnings.

Parameters

Name Type Description
options LanguageModelCallOptions
warnings IList<AnthropicWarning>

Returns: LanguageModelCallOptions

View source

public bool SupportsUrl(string mediaType, string url)

True when <code class=“paramref”>url</code> is an http or https URL for a supported media type.

Parameters

Name Type Description
mediaType string
url string

Returns: bool

View source

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