OpenAIConfig

org.llm4s.llmconnect.config.OpenAIConfig
See theOpenAIConfig companion object
case class OpenAIConfig(apiKey: String, model: String, organization: Option[String], baseUrl: String, contextWindow: Int, reserveCompletion: Int) extends ProviderConfig

Configuration for the OpenAI API and providers that implement the OpenAI-compatible REST interface.

baseUrl governs which backend is contacted: "https://api.openai.com/v1" reaches OpenAI directly, while a URL containing "openrouter.ai" causes org.llm4s.llmconnect.LLMConnect to route to OpenRouter. Azure OpenAI uses AzureConfig, not this class.

Prefer OpenAIConfig.fromValues over the primary constructor; it resolves contextWindow and reserveCompletion from the model name automatically.

Value parameters

apiKey

OpenAI API key; redacted in toString.

baseUrl

API base URL; determines provider routing in org.llm4s.llmconnect.LLMConnect.

contextWindow

Model's total token capacity (prompt + completion combined).

model

Model identifier, e.g. "gpt-4o".

organization

Optional OpenAI organisation ID.

reserveCompletion

Tokens held back from prompt history for the completion.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product