OpenAIClientOptionsWithAzureAgent interface

Extended OpenAI client options to include Azure Agent endpoint configuration.

Extends

ClientOptions

Properties

azureConfig

Azure Agent endpoint configuration.

Inherited Properties

adminAPIKey

Defaults to process.env['OPENAI_ADMIN_KEY'].

apiKey

API key used for authentication.

  • Accepts either a static string or an async function that resolves to a string.
  • Defaults to process.env['OPENAI_API_KEY'].
  • When a function is provided, it is invoked before each request so you can rotate or refresh credentials at runtime.
  • The function must return a non-empty string; otherwise an OpenAIError is thrown.
  • If the function throws, the error is wrapped in an OpenAIError with the original error available as cause.
  • Mutually exclusive with workloadIdentity.
baseURL

Override the default base URL for the API, e.g., "https://api.example.com/v2/"

Defaults to process.env['OPENAI_BASE_URL'].

dangerouslyAllowBrowser

By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers. Only set this option to true if you understand the risks and have appropriate mitigations in place.

defaultHeaders

Default headers to include with every request to the API.

These can be removed in individual requests by explicitly setting the header to null in request options.

defaultQuery

Default query parameters to include with every request to the API.

These can be removed in individual requests by explicitly setting the param to undefined in request options.

fetch

Specify a custom fetch function implementation.

If not provided, we expect that fetch is defined globally.

fetchOptions

Additional RequestInit options to be passed to fetch calls. Properties will be overridden by per-request fetchOptions.

logger

Set the logger.

Defaults to globalThis.console.

logLevel

Set the log level.

Defaults to process.env['OPENAI_LOG'] or 'warn' if it isn't set.

maxRetries

The maximum number of times that the client will retry a request in case of a temporary failure, like a network error or a 5XX error from the server.

organization

Defaults to process.env['OPENAI_ORG_ID'].

project

Defaults to process.env['OPENAI_PROJECT_ID'].

timeout

The maximum amount of time (in milliseconds) that the client should wait for a response from the server before timing out a single request.

Note that request timeouts are retried by default, so in a worst-case scenario you may wait much longer than this timeout before the promise succeeds or fails.

webhookSecret

Defaults to process.env['OPENAI_WEBHOOK_SECRET'].

workloadIdentity

Workload identity configuration for OAuth2 token exchange authentication. Mutually exclusive with apiKey.

Property Details

azureConfig

Azure Agent endpoint configuration.

azureConfig?: AzureAgentConfig

Property Value

Inherited Property Details

adminAPIKey

Defaults to process.env['OPENAI_ADMIN_KEY'].

adminAPIKey?: null | string

Property Value

null | string

Inherited From OpenAIClientOptions.adminAPIKey

apiKey

API key used for authentication.

  • Accepts either a static string or an async function that resolves to a string.
  • Defaults to process.env['OPENAI_API_KEY'].
  • When a function is provided, it is invoked before each request so you can rotate or refresh credentials at runtime.
  • The function must return a non-empty string; otherwise an OpenAIError is thrown.
  • If the function throws, the error is wrapped in an OpenAIError with the original error available as cause.
  • Mutually exclusive with workloadIdentity.
apiKey?: null | string | ApiKeySetter

Property Value

null | string | ApiKeySetter

Inherited From OpenAIClientOptions.apiKey

baseURL

Override the default base URL for the API, e.g., "https://api.example.com/v2/"

Defaults to process.env['OPENAI_BASE_URL'].

baseURL?: null | string

Property Value

null | string

Inherited From OpenAIClientOptions.baseURL

dangerouslyAllowBrowser

By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers. Only set this option to true if you understand the risks and have appropriate mitigations in place.

dangerouslyAllowBrowser?: boolean

Property Value

boolean

Inherited From OpenAIClientOptions.dangerouslyAllowBrowser

defaultHeaders

Default headers to include with every request to the API.

These can be removed in individual requests by explicitly setting the header to null in request options.

defaultHeaders?: HeadersLike

Property Value

HeadersLike

Inherited From OpenAIClientOptions.defaultHeaders

defaultQuery

Default query parameters to include with every request to the API.

These can be removed in individual requests by explicitly setting the param to undefined in request options.

defaultQuery?: Record<string, undefined | string>

Property Value

Record<string, undefined | string>

Inherited From OpenAIClientOptions.defaultQuery

fetch

Specify a custom fetch function implementation.

If not provided, we expect that fetch is defined globally.

fetch?: Fetch

Property Value

Fetch

Inherited From OpenAIClientOptions.fetch

fetchOptions

Additional RequestInit options to be passed to fetch calls. Properties will be overridden by per-request fetchOptions.

fetchOptions?: MergedRequestInit

Property Value

MergedRequestInit

Inherited From OpenAIClientOptions.fetchOptions

logger

Set the logger.

Defaults to globalThis.console.

logger?: Logger

Property Value

Logger

Inherited From OpenAIClientOptions.logger

logLevel

Set the log level.

Defaults to process.env['OPENAI_LOG'] or 'warn' if it isn't set.

logLevel?: LogLevel

Property Value

LogLevel

Inherited From OpenAIClientOptions.logLevel

maxRetries

The maximum number of times that the client will retry a request in case of a temporary failure, like a network error or a 5XX error from the server.

maxRetries?: number

Property Value

number

Inherited From OpenAIClientOptions.maxRetries

organization

Defaults to process.env['OPENAI_ORG_ID'].

organization?: null | string

Property Value

null | string

Inherited From OpenAIClientOptions.organization

project

Defaults to process.env['OPENAI_PROJECT_ID'].

project?: null | string

Property Value

null | string

Inherited From OpenAIClientOptions.project

timeout

The maximum amount of time (in milliseconds) that the client should wait for a response from the server before timing out a single request.

Note that request timeouts are retried by default, so in a worst-case scenario you may wait much longer than this timeout before the promise succeeds or fails.

timeout?: number

Property Value

number

Inherited From OpenAIClientOptions.timeout

webhookSecret

Defaults to process.env['OPENAI_WEBHOOK_SECRET'].

webhookSecret?: null | string

Property Value

null | string

Inherited From OpenAIClientOptions.webhookSecret

workloadIdentity

Workload identity configuration for OAuth2 token exchange authentication. Mutually exclusive with apiKey.

workloadIdentity?: WorkloadIdentity

Property Value

WorkloadIdentity

Inherited From OpenAIClientOptions.workloadIdentity