Skip to content

GoogleVertexAnthropicProvider

Namespace: Vercel.AI.Google

public sealed class GoogleVertexAnthropicProvider : AnthropicProvider, IBatchProvider, IDecisionProvider, IEvaluationProvider

Anthropic on Vertex. Sends the Anthropic Messages body to rawPredict with anthropic_version in the body. Vertex does not accept URL sources, the native output format, or strict tools.

Inheritance: object → ProviderBase → AnthropicProvider

Implements: IBatchProvider, IDecisionProvider, IEvaluationProvider

View source

GoogleVertexAnthropicProvider(HttpClient, GoogleVertexAnthropicOptions?)

Section titled “GoogleVertexAnthropicProvider(HttpClient, GoogleVertexAnthropicOptions?)”
public GoogleVertexAnthropicProvider(HttpClient httpClient, GoogleVertexAnthropicOptions? options = null)

Creates a provider.

Parameters

Name Type Description
httpClient HttpClient
options GoogleVertexAnthropicOptions

View source

public const string ModelProviderName = "googleVertex.anthropic.messages"

Provider id reported by language models.

Value: string

View source

public string BaseUrl { get; }

Publisher base URL.

Value: string

View source

public string? Location { get; }

Location.

Value: string

View source

public string? Project { get; }

Project id.

Value: string

View source

protected override IReadOnlyDictionary<string, string> SupportedUrls { get; }

URL patterns that models of this provider accept for images and PDFs.

Value: IReadOnlyDictionary<string, string>

View source

protected override bool SupportsNativeStructuredOutput { get; }

False when the host does not accept the native output format. Structured output then uses the JSON tool.

Value: bool

View source

protected override bool SupportsStrictTools { get; }

False when the host does not accept strict on tool definitions.

Value: bool

View source

public static IReadOnlyList<string> Tools { get; }

Provider tool ids that Vertex accepts. A subset of the Anthropic tools.

Value: IReadOnlyList<string>

View source

Create(GoogleVertexAnthropicOptions?, HttpMessageHandler?)

Section titled “Create(GoogleVertexAnthropicOptions?, HttpMessageHandler?)”
public static GoogleVertexAnthropicProvider Create(GoogleVertexAnthropicOptions? options = null, HttpMessageHandler? handler = null)

Creates a provider. Pass a handler from tests.

Parameters

Name Type Description
options GoogleVertexAnthropicOptions
handler HttpMessageHandler

Returns: GoogleVertexAnthropicProvider

View source

CreateHeadersAsync(IReadOnlyList<string>, IReadOnlyDictionary<string, string?>?, string?, CancellationToken)

Section titled “CreateHeadersAsync(IReadOnlyList<string>, IReadOnlyDictionary<string, string?>?, string?, CancellationToken)”
public override Task<Dictionary<string, string?>> CreateHeadersAsync(IReadOnlyList<string> betas, IReadOnlyDictionary<string, string?>? callHeaders, string? body, CancellationToken cancellationToken)

Generated bearer token, then configured headers, call headers, and beta flags.

Parameters

Name Type Description
betas IReadOnlyList<string>
callHeaders IReadOnlyDictionary<string, string>
body string
cancellationToken CancellationToken

Returns: Task<Dictionary<string, string>>

View source

public override IEmbeddingModel EmbeddingModel(string modelId)

Embedding models are not available on this provider.

Parameters

Name Type Description
modelId string

Returns: IEmbeddingModel

View source

public string PredictUrl(string modelId, bool streaming)

rawPredict or streamRawPredict URL for a model.

Parameters

Name Type Description
modelId string
streaming bool

Returns: string

View source

protected override Uri RequestUri(string modelId, bool streaming)

URL for one model call. Defaults to MessagesUri().

Parameters

Name Type Description
modelId string
streaming bool

Returns: Uri

View source

public static JsonObject TransformBody(JsonObject body)

Removes model and sets anthropic_version.

Parameters

Name Type Description
body JsonObject

Returns: JsonObject

View source

TransformHeaders(Dictionary<string, string?>, IReadOnlyDictionary<string, JsonElement>?)

Section titled “TransformHeaders(Dictionary<string, string?>, IReadOnlyDictionary<string, JsonElement>?)”
public static Dictionary<string, string?> TransformHeaders(Dictionary<string, string?> headers, IReadOnlyDictionary<string, JsonElement>? providerOptions)

Sends providerOptions.vertex.labels as the x-vertex-ai-labels header. An explicit header wins.

Parameters

Name Type Description
headers Dictionary<string, string>
providerOptions IReadOnlyDictionary<string, JsonElement>

Returns: Dictionary<string, string>

View source

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