pub fn get_openrouter_embedder(
api_key: SecretBox<String>,
model: &str,
dim: usize,
timeout_override: Option<u64>,
) -> Result<&'static OpenRouterClient, AppError>Expand description
Initialises the process-wide OpenRouter embedding client on first use and returns it.
The per-request timeout resolves in the documented precedence:
timeout_override (the --openrouter-timeout flag) first, then XDG
embedding.timeout_secs, then the client’s own default.
FIRST INITIALISER WINS. The client lives in a OnceLock, so a later call
with a different timeout returns the already-built client unchanged. This is
sound under the one-shot CLI contract: a single invocation runs a single
subcommand, so exactly one timeout is in play per process. Nothing here
attempts to rebuild or swap the client, which would race with in-flight
requests for no benefit.