Skip to content

GatewayProvider

Namespace: Vercel.AI.Gateway

public sealed class GatewayProvider : ProviderBase, IBatchProvider, IDecisionProvider, IEvaluationProvider

Vercel AI Gateway provider. Language, embedding, and image calls use the Gateway V4 routes (/language-model, /embedding-model, /image-model).

Inheritance: object → ProviderBase

Implements: IBatchProvider, IDecisionProvider, IEvaluationProvider

View source

GatewayProvider(GatewayOptions?, HttpClient)

Section titled “GatewayProvider(GatewayOptions?, HttpClient)”
public GatewayProvider(GatewayOptions? options, HttpClient httpClient)

Creates a Gateway provider.

Parameters

Name Type Description
options GatewayOptions
httpClient HttpClient

View source

public const string ApiKeyEnvironmentVariable = "AI_GATEWAY_API_KEY"

Environment variable for the Gateway key.

Value: string

View source

public const string ProviderId = "gateway"

Provider id.

Value: string

View source

public ProviderHttp Http { get; }

HTTP helper.

Value: ProviderHttp

View source

public GatewayOptions Options { get; }

Options.

Value: GatewayOptions

View source

Create(GatewayOptions?, HttpMessageHandler?)

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

Creates a provider. Pass a handler from tests.

Parameters

Name Type Description
options GatewayOptions
handler HttpMessageHandler

Returns: GatewayProvider

View source

public GatewayDecisionModel DecisionModel(string modelId)

Decision model routed through /decision-model.

Parameters

Name Type Description
modelId string

Returns: GatewayDecisionModel

View source

public override IEmbeddingModel EmbeddingModel(string modelId)

Returns an embedding model.

Parameters

Name Type Description
modelId string

Returns: IEmbeddingModel

View source

[Obsolete("Use DecisionModel instead.")]
public GatewayDecisionModel EvaluationModel(string modelId)

Deprecated alias of DecisionModel(string). Maps to evaluationModel.

Parameters

Name Type Description
modelId string

Returns: GatewayDecisionModel

View source

public IBatchApi? ExperimentalBatch()

Gateway batch API. Downloads batch results.

Returns: IBatchApi

View source

public override IImageModel ImageModel(string modelId)

Returns an image model.

Parameters

Name Type Description
modelId string

Returns: IImageModel

View source

public override ILanguageModel LanguageModel(string modelId)

Returns a language model.

Parameters

Name Type Description
modelId string

Returns: ILanguageModel

View source

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