ExLLM.ConfigProvider behaviour (ex_llm v0.5.0)
View SourceBehaviour for configuration providers.
This allows modules to receive configuration through dependency injection rather than directly accessing application configuration, making them more portable and testable.
Example
# Using static configuration
config = %{
openai: %{api_key: "sk-..."},
anthropic: %{api_key: "api-..."}
}
{:ok, provider} = ExLLM.ConfigProvider.Static.start_link(config)
ExLLM.OpenAI.chat(messages, config_provider: provider)
# Using environment-based configuration
ExLLM.OpenAI.chat(messages, config_provider: ExLLM.ConfigProvider.Env)