GatewayProvider
Namespace: Vercel.AI.Gateway
public sealed class GatewayProvider : ProviderBase, IBatchProvider, IDecisionProvider, IEvaluationProviderVercel 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
Constructors
Section titled “Constructors”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 |
Fields
Section titled “Fields”ApiKeyEnvironmentVariable
Section titled “ApiKeyEnvironmentVariable”public const string ApiKeyEnvironmentVariable = "AI_GATEWAY_API_KEY"Environment variable for the Gateway key.
Value: string
ProviderId
Section titled “ProviderId”public const string ProviderId = "gateway"Provider id.
Value: string
Properties
Section titled “Properties”public ProviderHttp Http { get; }HTTP helper.
Value: ProviderHttp
Options
Section titled “Options”public GatewayOptions Options { get; }Options.
Value: GatewayOptions
Methods
Section titled “Methods”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
DecisionModel(string)
Section titled “DecisionModel(string)”public GatewayDecisionModel DecisionModel(string modelId)Decision model routed through /decision-model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: GatewayDecisionModel
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 GatewayDecisionModel EvaluationModel(string modelId)Deprecated alias of DecisionModel(string). Maps to evaluationModel.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: GatewayDecisionModel
ExperimentalBatch()
Section titled “ExperimentalBatch()”public IBatchApi? ExperimentalBatch()Gateway batch API. Downloads batch results.
Returns: IBatchApi
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
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product