Llm4sConfig
Application-edge configuration loader for LLM4S.
Reads all runtime configuration from environment variables and system properties via PureConfig. This is the single authorised entry point for configuration in application and test code — never read sys.env, System.getenv, or ConfigFactory.load() directly.
== Provider setup == Set LLM_MODEL to provider/model (e.g. "openai/gpt-4o", "anthropic/claude-sonnet-4-5-latest", "gemini/gemini-2.0-flash") and the corresponding API key environment variable. Then call provider to obtain a org.llm4s.llmconnect.config.ProviderConfig ready for org.llm4s.llmconnect.LLMConnect.getClient.
Attributes
- See also
-
org.llm4s.config.ConfigKeys for the full list of recognised environment variable names.
- Example
-
for { cfg <- Llm4sConfig.provider() client <- LLMConnect.getClient(cfg) agent = new Agent(client) state <- agent.run("Hello", ToolRegistry.empty) } yield state - Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Llm4sConfig.type
Members list
Type members
Classlikes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Loads the active embedding provider and its configuration from the current environment.
Loads the active embedding provider and its configuration from the current environment.
Reads EMBEDDING_MODEL in provider/model format (e.g. "openai/text-embedding-3-small", "voyage/voyage-3", "ollama/nomic-embed-text"). Returns the provider name and typed config.
Attributes
- Returns
-
a pair of
(providerName, EmbeddingProviderConfig), or a org.llm4s.error.ConfigurationError whenEMBEDDING_MODELis absent or the provider is unrecognised.
Alias for loadEmbeddingsChunking.
Alias for loadEmbeddingsInputs.
Alias for loadEmbeddingsUiSettings.
Loads provider exchange logging configuration from the current environment.
Loads provider exchange logging configuration from the current environment.
Reads the optional llm4s.exchangeLogging section. When absent or disabled, exchange logging remains off. When enabled, a JSONL sink is constructed from a configured directory and writes to a new per-run file.
Attributes
Returns true when experimental embedding stubs are enabled.
Returns true when experimental embedding stubs are enabled.
Controlled by the llm4s.embeddings.experimentalStubs config key. Defaults to false when the key is absent.
Attributes
Load Brave Search API configuration.
Load Brave Search API configuration.
Requires BRAVE_SEARCH_API_KEY environment variable.
Attributes
- Returns
-
Result containing BraveSearchToolConfig with API key and settings
Load DuckDuckGo Search configuration.
Load DuckDuckGo Search configuration.
No API key required.
Attributes
- Returns
-
Result containing DuckDuckGoSearchToolConfig with settings
Loads text-chunking settings for the embeddings pipeline from the current environment.
Loads text-chunking settings for the embeddings pipeline from the current environment.
Reads CHUNK_SIZE, CHUNK_OVERLAP, and CHUNKING_ENABLED, applying defaults of 1000, 100, and true respectively when variables are absent.
Attributes
- Returns
-
chunking settings; always returns
Right— missing variables fall back to defaults rather than failing.
Loads input path and query settings for the embeddings pipeline from the current environment.
Loads input path and query settings for the embeddings pipeline from the current environment.
Reads EMBEDDING_INPUT_PATH, llm4s.embeddings.inputPaths, and EMBEDDING_QUERY. All fields are optional; returns Right with None values when variables are absent.
Attributes
Loads UI display settings for the embeddings explorer from the current environment.
Loads UI display settings for the embeddings explorer from the current environment.
Applies defaults when variables are absent: maxRowsPerFile=200, topDimsPerRow=6, globalTopK=10, showGlobalTop=false, colorEnabled=true, tableWidth=120.
Attributes
- Returns
-
UI settings; always returns
Right— missing variables fall back to defaults rather than failing.
Load Exa Search API configuration.
Load Exa Search API configuration.
Requires EXA_API_KEY environment variable.
Attributes
- Returns
-
Result containing ExaSearchToolConfig with API key and settings
Loads and resolves the active embedding model, including its output dimensions.
Loads and resolves the active embedding model, including its output dimensions.
Reads EMBEDDING_MODEL and looks up the known dimension count for the provider/model combination from the bundled dimension registry.
Attributes
- Returns
-
the resolved settings, or a org.llm4s.error.ConfigurationError when
EMBEDDING_MODELis absent or unrecognised.
Loads configuration for locally-available embedding models from the current environment.
Loads configuration for locally-available embedding models from the current environment.
Attributes
- Returns
-
the local model configuration, or a org.llm4s.error.ConfigurationError when required variables are missing.
Load the metrics configuration.
Load the metrics configuration.
Returns a MetricsCollector and optional PrometheusEndpoint if metrics are enabled. Use MetricsCollector.noop if you want to disable metrics programmatically.
Attributes
- Returns
-
Result containing (MetricsCollector, Option[PrometheusEndpoint])
Returns the path to a user-supplied model-metadata override file, if configured.
Returns the path to a user-supplied model-metadata override file, if configured.
When set via llm4s.modelMetadata.file, the override file is consulted before the bundled model catalogue when resolving context-window sizes. Returns None when the key is absent or blank.
Attributes
Loads PostgreSQL vector-search index configuration from the current environment.
Loads PostgreSQL vector-search index configuration from the current environment.
Attributes
- Returns
-
the PgConfig, or a org.llm4s.error.ConfigurationError when required variables are missing.
Loads LLM provider configuration from the current environment.
Loads LLM provider configuration from the current environment.
Reads LLM_MODEL (format: provider/model) and the matching credential variables (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.) to build a typed org.llm4s.llmconnect.config.ProviderConfig.
Attributes
- Returns
-
the provider configuration, or a org.llm4s.error.ConfigurationError when required variables are missing or the provider prefix is unrecognised.
Alias for loadTextEmbeddingModel.
Loads tracing configuration from the current environment.
Loads tracing configuration from the current environment.
Reads TRACING_MODE (langfuse, opentelemetry, console, or none) and the backend-specific variables (Langfuse keys, OTLP endpoint, etc.).
Attributes
- Returns
-
the tracing settings, or a org.llm4s.error.ConfigurationError when a required backend variable is missing.