AnthropicProvider
Namespace: Vercel.AI.Anthropic
public class AnthropicProvider : ProviderBase, IBatchProvider, IDecisionProvider, IEvaluationProviderAnthropic Messages provider.
Inheritance: object → ProviderBase
Implements: IBatchProvider, IDecisionProvider, IEvaluationProvider
Derived: AnthropicAwsProvider, GoogleVertexAnthropicProvider
Constructors
Section titled “Constructors”AnthropicProvider(HttpClient, AnthropicOptions?)
Section titled “AnthropicProvider(HttpClient, AnthropicOptions?)”public AnthropicProvider(HttpClient httpClient, AnthropicOptions? options = null)Creates a provider.
Parameters
| Name | Type | Description |
|---|---|---|
httpClient |
HttpClient | |
options |
AnthropicOptions |
Fields
Section titled “Fields”ProviderName
Section titled “ProviderName”public const string ProviderName = "anthropic"Provider id used for dependency injection.
Value: string
UserAgent
Section titled “UserAgent”public static readonly string UserAgentUser agent for the Messages API.
Value: string
Properties
Section titled “Properties”protected bool Aws { get; set; }True for Claude Platform on AWS.
Value: bool
ExplicitBaseUrl
Section titled “ExplicitBaseUrl”protected bool ExplicitBaseUrl { get; set; }True when the caller supplied a base URL other than the public Anthropic host.
Value: bool
public ProviderHttp Http { get; }HTTP helper.
Value: ProviderHttp
ModelProvider
Section titled “ModelProvider”public string ModelProvider { get; }Provider id reported by language models.
Value: string
Options
Section titled “Options”public AnthropicOptions Options { get; }Options.
Value: AnthropicOptions
SupportedUrls
Section titled “SupportedUrls”protected virtual IReadOnlyDictionary<string, string> SupportedUrls { get; }URL patterns that models of this provider accept for images and PDFs.
Value: IReadOnlyDictionary<string, string>
SupportsNativeStructuredOutput
Section titled “SupportsNativeStructuredOutput”protected virtual bool SupportsNativeStructuredOutput { get; }False when the host does not accept the native output format. Structured output then uses the JSON tool.
Value: bool
SupportsStrictTools
Section titled “SupportsStrictTools”protected virtual bool SupportsStrictTools { get; }False when the host does not accept strict on tool definitions.
Value: bool
public static IReadOnlyList<string> Tools { get; }Provider tool ids, such as anthropic.web_search_20250305. Pass one as a provider tool id.
Value: IReadOnlyList<string>
Methods
Section titled “Methods”Create(AnthropicOptions?, HttpMessageHandler?)
Section titled “Create(AnthropicOptions?, HttpMessageHandler?)”public static AnthropicProvider Create(AnthropicOptions? options = null, HttpMessageHandler? handler = null)Creates a provider.
Parameters
| Name | Type | Description |
|---|---|---|
options |
AnthropicOptions | |
handler |
HttpMessageHandler |
Returns: AnthropicProvider
CreateHeaders(IReadOnlyList<string>, IReadOnlyDictionary<string, string?>?)
Section titled “CreateHeaders(IReadOnlyList<string>, IReadOnlyDictionary<string, string?>?)”public Dictionary<string, string?> CreateHeaders(IReadOnlyList<string> betas, IReadOnlyDictionary<string, string?>? callHeaders)Headers for a Messages call that already has an API key or auth token.
Parameters
| Name | Type | Description |
|---|---|---|
betas |
IReadOnlyList<string> | |
callHeaders |
IReadOnlyDictionary<string, string> |
Returns: Dictionary<string, string>
CreateHeadersAsync(IReadOnlyList<string>, IReadOnlyDictionary<string, string?>?, string?, CancellationToken)
Section titled “CreateHeadersAsync(IReadOnlyList<string>, IReadOnlyDictionary<string, string?>?, string?, CancellationToken)”public virtual Task<Dictionary<string, string?>> CreateHeadersAsync(IReadOnlyList<string> betas, IReadOnlyDictionary<string, string?>? callHeaders, string? body, CancellationToken cancellationToken)Headers for a Messages call. Signs the body when AWS credentials are used.
Parameters
| Name | Type | Description |
|---|---|---|
betas |
IReadOnlyList<string> | |
callHeaders |
IReadOnlyDictionary<string, string> | |
body |
string | |
cancellationToken |
CancellationToken |
Returns: Task<Dictionary<string, string>>
DecisionModel(string)
Section titled “DecisionModel(string)”public DecisionLanguageModel DecisionModel(string modelId)Decision model. Wraps the Messages language model with structured output. The provider id is anthropic.decision.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: DecisionLanguageModel
EmbeddingModel(string)
Section titled “EmbeddingModel(string)”public override IEmbeddingModel EmbeddingModel(string modelId)Returns an embedding model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: IEmbeddingModel
EvaluationModel(string)
Section titled “EvaluationModel(string)”[Obsolete("Use DecisionModel instead.")]public DecisionLanguageModel EvaluationModel(string modelId)Deprecated alias of DecisionModel(string). Maps to evaluationModel.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: DecisionLanguageModel
ExperimentalBatch()
Section titled “ExperimentalBatch()”public IBatchApi? ExperimentalBatch()Message Batches API. Downloads batch results.
Returns: IBatchApi
Files()
Section titled “Files()”public AnthropicFiles Files()Files API client.
Returns: AnthropicFiles
ImageModel(string)
Section titled “ImageModel(string)”public override IImageModel ImageModel(string modelId)Returns an image model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: IImageModel
LanguageModel(string)
Section titled “LanguageModel(string)”public override ILanguageModel LanguageModel(string modelId)Returns a language model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: ILanguageModel
MessagesUri()
Section titled “MessagesUri()”public Uri MessagesUri()Messages URL for the resolved base.
Returns: Uri
New(string)
Section titled “New(string)”public ILanguageModel New(string modelId)Throws because the JavaScript provider function rejects new.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: ILanguageModel
NormalizedBase()
Section titled “NormalizedBase()”public string NormalizedBase()Resolved API origin, including /v1 when the host is the public Anthropic API or a regional AWS host.
Returns: string
RequestUri(string, bool)
Section titled “RequestUri(string, bool)”protected virtual Uri RequestUri(string modelId, bool streaming)URL for one model call. Defaults to MessagesUri().
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string | |
streaming |
bool |
Returns: Uri
RubricModel(string)
Section titled “RubricModel(string)”public override IRubricModel RubricModel(string modelId)Returns a model that scores a candidate against a rubric.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: IRubricModel
Skills()
Section titled “Skills()”public AnthropicSkills Skills()Skills API client.
Returns: AnthropicSkills
TransformRequestBody(JsonObject, IReadOnlyList<string>)
Section titled “TransformRequestBody(JsonObject, IReadOnlyList<string>)”protected virtual JsonObject TransformRequestBody(JsonObject body, IReadOnlyList<string> betas)Rewrites the Messages body just before it is sent. Defaults to TransformRequestBody.
Parameters
| Name | Type | Description |
|---|---|---|
body |
JsonObject | |
betas |
IReadOnlyList<string> |
Returns: JsonObject
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product