ChatCompletions

A Model for OpenAI's Chat Completions API and the endpoints compatible with it, such as Gemini and Vertex AI Model Garden models, xAI's Grok, Groq, Mistral, Together, or a local server.

Supports streaming, function calling, structured output, image input, and token usage. A user turn with audio or a non-image file fails with IllegalArgumentException, and logprobs are not returned.

Constructors

Link copied to clipboard
constructor(name: String, apiKey: String? = null, httpOptions: HttpOptions? = null)

Creates a ChatCompletions model backed by an OpenAI-compatible Chat Completions endpoint.

constructor(name: String, httpOptions: HttpOptions? = null, apiKeyProvider: () -> String)

Creates a ChatCompletions model that calls apiKeyProvider before each request, for a key that expires, such as a Google Cloud access token.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val name: String

Functions

Link copied to clipboard
Link copied to clipboard
open override fun generateContent(request: LlmRequest, stream: Boolean): Flow<LlmResponse>