FalEx.Config (fal_ex v0.1.0)
View SourceConfiguration module for FalEx client.
Handles authentication credentials and client configuration. Supports environment variables and runtime configuration.
Summary
Functions
Gets the effective base URL, considering proxy configuration.
Creates a new configuration.
Resolves credentials at runtime.
Checks if the configuration uses a proxy.
Types
@type t() :: %FalEx.Config{ base_url: String.t(), credentials: credentials() | nil, fetch_implementation: module() | nil, proxy_url: String.t() | nil, request_middleware: module() | nil, response_handler: (Tesla.Env.t() -> any()) | nil }
Functions
Gets the effective base URL, considering proxy configuration.
Creates a new configuration.
Options
:credentials
- API credentials. Can be:- A string API key
- A tuple of
{key_id, key_secret}
- A function that returns either of the above
:proxy_url
- URL of a proxy server to route requests through:request_middleware
- Custom middleware module for request modification:response_handler
- Custom response handler function:fetch_implementation
- Custom HTTP client implementation:base_url
- Base URL for API requests (default: "https://fal.run")
Examples
# Using API key from environment
FalEx.Config.new(credentials: System.get_env("FAL_KEY"))
# Using key ID and secret
FalEx.Config.new(credentials: {"key_id", "key_secret"})
# Using a resolver function
FalEx.Config.new(credentials: fn -> System.get_env("FAL_KEY") end)
# Using proxy
FalEx.Config.new(proxy_url: "/api/fal/proxy")
Resolves credentials at runtime.
Handles credential resolver functions and returns the actual credentials.
Checks if the configuration uses a proxy.