OpenAIProvider
classin packageklyn.llm
public class OpenAIProvider extends Object implements LLMProvider, LLMTokenEstimator
└ OpenAIProvider
All Implemented Interfaces: LLMProvider, LLMTokenEstimator

OpenAI-compatible HTTP provider.

Despite its name, this class targets the chat-completions style API used by many OpenAI-compatible providers.

Fields
Modifier and Type Member Description
public apiKey
apiKey as String
Bearer API key.
public baseUrl
baseUrl as String
Provider API root.
public estimatedImageTokens
estimatedImageTokens as Int = 1024
Approximate tokens per image when provider usage is unavailable.
public httpClient
httpClient as HttpClient
HTTP client used for provider calls.
public model
model as String
Model identifier.
public temperature
temperature as Double
Sampling temperature.
Properties
Modifier and Type Member Description
public readonly property chatCompletionsUrl
chatCompletionsUrl as String
Returns the final chat-completions endpoint.
public property maxCompletionTokens
maxCompletionTokens as Int
Optional maximum generated tokens, including reasoning tokens.
public property reasoningEffort
reasoningEffort as String
Optional reasoning effort level for models that expose that parameter.
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public OpenAIProvider
OpenAIProvider(baseUrl as String, apiKey as String, model as String, temperature as Double = 0.7)
Creates a configured provider.
Methods
Modifier and Type Member Description
public cancel
cancel() as Void
Cancels the currently running provider HTTP request, if any.
public override complete
complete(request as LLMRequest) as LLMResponse throws Exception
Sends one completion request.
public override estimateMessageTokens
estimateMessageTokens(message as LLMThreadMessage) as Int
Estimates one serialized chat message without file or network IO.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml
methodInherited Methods from LLMTokenEstimator: estimateMessageTokens