Skip to content

OpenAICompatibleOptions

Namespace: Vercel.AI.OpenAICompatible

public class OpenAICompatibleOptions

Settings for an OpenAI Chat Completions compatible provider.

Inheritance: object

Derived: AssemblyAIOptions, BasetenOptions, DeepgramOptions, ElevenLabsOptions, GladiaOptions, HumeOptions, KlingAIOptions, OpenAIOptions, RevAIOptions

View source

public string[] AdditionalApiKeyEnvironmentVariables { get; set; }

Extra environment variables accepted as a fallback.

Value: string[]

View source

public string? ApiKey { get; set; }

Explicit API key. Wins over the environment variable.

Value: string

View source

public string ApiKeyEnvironmentVariable { get; set; }

Environment variable read when ApiKey is empty.

Value: string

View source

public string ApiKeyHeaderName { get; set; }

Header name for ApiKeyHeader and CustomHeader.

Value: string

View source

public ApiKeyStyle ApiKeyStyle { get; set; }

How to send the key.

Value: ApiKeyStyle

View source

public string? AzureApiVersion { get; set; }

When set, chat, completion, embedding, and Responses URLs use the Azure routes and this API version.

Value: string

View source

public bool AzureUseDeploymentBasedUrls { get; set; }

With AzureApiVersion, uses /openai/deployments/{id} routes instead of /openai/v1.

Value: bool

View source

public string BaseUrl { get; set; }

API origin, without a trailing slash. Chat calls append ChatCompletionsPath.

Value: string

View source

public string ChatCompletionsPath { get; set; }

Relative chat path.

Value: string

View source

public string CompletionsPath { get; set; }

Relative completions path.

Value: string

View source

public Func<JsonElement, LanguageModelUsage>? ConvertUsage { get; set; }

Converts the raw chat usage object. Null uses JsonElement%7d).

Value: Func<JsonElement, LanguageModelUsage>

View source

public HttpClient? DownloadHttpClient { get; set; }

Client for hops off the provider origin when a URL from a response body is downloaded (Fal, Replicate, Luma, Prodia). It must not follow redirects: each hop is validated before it is requested. Null uses a shared client that does not follow them.

Value: HttpClient

View source

public string EmbeddingsPath { get; set; }

Relative embeddings path.

Value: string

View source

public Dictionary<string, string> Headers { get; }

Extra headers sent on every call. These override the API key header.

Value: Dictionary<string, string>

View source

public string? ImageBaseUrl { get; set; }

Origin for image calls when it differs from BaseUrl.

Value: string

View source

public string ImagesPath { get; set; }

Relative images path.

Value: string

View source

public bool IncludeUsage { get; set; }

When true, streaming requests send stream_options.include_usage.

Value: bool

View source

public bool JsonTextOverridesToolCalls { get; set; }

When true, a JSON-mode response that has text drops its tool calls, and a tool_calls finish becomes stop.

Value: bool

View source

public Func<string?, FinishReason?>? MapFinishReason { get; set; }

Maps a raw finish reason before the shared mapping. Null falls through.

Value: Func<string, FinishReason?>

View source

public int MaxEmbeddingsPerCall { get; set; }

Maximum embedding inputs in one request.

Value: int

View source

public string ProviderName { get; set; }

Provider id recorded on models.

Value: string

View source

public Dictionary<string, string> QueryParameters { get; }

Query parameters appended to every request URL.

Value: Dictionary<string, string>

View source

public bool RequireApiKey { get; set; }

When true, a missing API key fails the call. The generic provider leaves this unset.

Value: bool

View source

public string RerankPath { get; set; }

Relative rerank path.

Value: string

View source

public Func<string, string?, string?, IList<CallWarning>, string?>? ResolveReasoningEffort { get; set; }

Resolves reasoning_effort for a model. Arguments are the model id, the portable Reasoning level, the provider option effort, and the call warnings. Null removes the field. Null here keeps the default behavior.

Value: Func<string, string, string, IList<CallWarning>, string>

View source

public Func<string?, string?>? SelectErrorMessage { get; set; }

Rewrites a provider error body into the exception message.

Value: Func<string, string>

View source

public bool SupportsEmbeddings { get; set; }

Whether embedding calls are supported.

Value: bool

View source

public bool SupportsImages { get; set; }

Whether ImageModel(string) is supported.

Value: bool

View source

public bool SupportsMultiPartToolContent { get; set; }

When true, a tool result with OutputContent is sent as an array of content parts. Otherwise the parts are sent as a JSON string.

Value: bool

View source

public bool SupportsStructuredOutputs { get; set; }

When true, a JSON schema is sent as json_schema instead of json_object.

Value: bool

View source

public Func<JsonObject, IList<CallWarning>, JsonObject>? TransformRequestBody { get; set; }

Rewrites the JSON body before it is sent. Warnings raised here are returned with the call.

Value: Func<JsonObject, IList<CallWarning>, JsonObject>

View source

public string? UserAgent { get; set; }

User-agent suffix. Empty uses UserAgent(string).

Value: string

View source

public OpenAICompatibleOptions Copy()

Returns a copy. Providers change the copy, so the options the caller passed in are left as they were.

Returns: OpenAICompatibleOptions

View source

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