OpenAiChatModel

constructor(client: HttpClient, apiKey: String?, model: String, parameters: JsonObject = JsonObject(emptyMap()), headers: Map<String, String> = emptyMap(), baseUrl: String = OPENAI_BASE_URL, timeout: Duration? = 5.minutes)

Parameters

client

the Ktor client that sends the requests.

apiKey

the key, sent as a bearer token. null for a server that needs none.

model

the id of the model, for example gpt-5.

parameters

more fields for the body of every request, such as temperature, max_completion_tokens, reasoning_effort or tool_choice. A field given here replaces the one this class would send.

headers

more headers for every request, such as OpenAI-Organization.

baseUrl

where the API lives, up to and including the version: this class adds /chat/completions to it.

timeout

how long one call may take, from the request to the end of the answer, and how long it may wait for the next piece of the answer. It replaces the limits of client and of its engine for the requests of this model. null leaves those limits in place.