Skip to content

GoogleVertexXaiProvider

Namespace: Vercel.AI.Google

public sealed class GoogleVertexXaiProvider

xAI Grok models hosted on Vertex.

Inheritance: object

View source

GoogleVertexXaiProvider(string, string?, string?, HttpMessageHandler?)

Section titled “GoogleVertexXaiProvider(string, string?, string?, HttpMessageHandler?)”
public GoogleVertexXaiProvider(string project, string? location, string? baseUrl = null, HttpMessageHandler? handler = null)

Creates a provider.

Parameters

Name Type Description
project string
location string
baseUrl string
handler HttpMessageHandler

View source

GoogleVertexXaiProvider(GoogleVertexPartnerOptions, HttpMessageHandler?)

Section titled “GoogleVertexXaiProvider(GoogleVertexPartnerOptions, HttpMessageHandler?)”
public GoogleVertexXaiProvider(GoogleVertexPartnerOptions options, HttpMessageHandler? handler = null)

Creates a provider. <code class=“paramref”>handler</code> sends the request after the auth headers are added.

Parameters

Name Type Description
options GoogleVertexPartnerOptions
handler HttpMessageHandler

View source

public string BaseUrl { get; }

OpenAI-compatible base URL.

Value: string

View source

public bool ClientCreated { get; }

True after the inner provider has been created.

Value: bool

View source

public string Location { get; }

Location.

Value: string

View source

public string Project { get; }

Project id.

Value: string

View source

public static GoogleTokenUsage ConvertUsage(int? promptTokens, int? completionTokens, int? cachedTokens, int? reasoningTokens)

Counts Grok reasoning tokens separately. Output total is completion tokens plus reasoning tokens.

Parameters

Name Type Description
promptTokens int?
completionTokens int?
cachedTokens int?
reasoningTokens int?

Returns: GoogleTokenUsage

View source

public IEmbeddingModel EmbeddingModel(string modelId)

Embedding and image models are not available.

Parameters

Name Type Description
modelId string

Returns: IEmbeddingModel

View source

public ILanguageModel LanguageModel(string modelId)

Returns a chat model.

Parameters

Name Type Description
modelId string

Returns: ILanguageModel

View source

public static JsonObject TransformBody(JsonObject body)

Removes reasoning_effort. Vertex Grok does not accept it.

Parameters

Name Type Description
body JsonObject

Returns: JsonObject

View source

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