ChatCompletions
Creates a ChatCompletions model backed by an OpenAI-compatible Chat Completions endpoint.
Parameters
The model name, such as gpt-4o, or google/gemini-3.1-flash-lite on Vertex AI.
The API key, sent as a bearer token; a blank one counts as unset. Falls back to OPENAI_API_KEY only when httpOptions sets no base URL, so that key never goes to a base URL the caller sets.
The base URL (OPENAI_BASE_URL, else OpenAI's, when unset), extra headers, and timeout, which bounds each unary attempt and the start of a stream. A stream also fails after 10 minutes without data, or the timeout if longer; a zero or infinite timeout disables both.
Throws
If no key is found and the base URL is unset or blank, or if httpOptions has a negative timeout or any apiVersion.
Creates a ChatCompletions model that calls apiKeyProvider before each request, for a key that expires, such as a Google Cloud access token.
Parameters
The model name, such as gpt-4o, or google/gemini-3.1-flash-lite on Vertex AI.
The base URL (OPENAI_BASE_URL, else OpenAI's, when unset), extra headers, and timeout, which bounds each unary attempt and the start of a stream. A stream also fails after 10 minutes without data, or the timeout if longer; a zero or infinite timeout disables both.
Returns the API key, sent as a bearer token.
Throws
If httpOptions has a negative timeout or any apiVersion.