fix: propagate warmup errors and skip when no API key configured
Address review feedback from @coderabbitai and @gemini-code-assist: - Missing API key is now a silent no-op instead of returning an error - Network/TLS errors are now propagated via `?` instead of silently discarded, so they surface as non-fatal warnings in the caller's log - Added `error_for_status()` to catch HTTP-level failures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cc13fec16d
commit
1110158b23
1 changed files with 8 additions and 10 deletions
|
|
@ -54,16 +54,14 @@ impl Provider for OpenRouterProvider {
|
||||||
async fn warmup(&self) -> anyhow::Result<()> {
|
async fn warmup(&self) -> anyhow::Result<()> {
|
||||||
// Hit a lightweight endpoint to establish TLS + HTTP/2 connection pool.
|
// Hit a lightweight endpoint to establish TLS + HTTP/2 connection pool.
|
||||||
// This prevents the first real chat request from timing out on cold start.
|
// This prevents the first real chat request from timing out on cold start.
|
||||||
let api_key = self
|
if let Some(api_key) = self.api_key.as_ref() {
|
||||||
.api_key
|
self.client
|
||||||
.as_ref()
|
.get("https://openrouter.ai/api/v1/auth/key")
|
||||||
.ok_or_else(|| anyhow::anyhow!("No API key for warmup"))?;
|
.header("Authorization", format!("Bearer {api_key}"))
|
||||||
let _ = self
|
.send()
|
||||||
.client
|
.await?
|
||||||
.get("https://openrouter.ai/api/v1/auth/key")
|
.error_for_status()?;
|
||||||
.header("Authorization", format!("Bearer {api_key}"))
|
}
|
||||||
.send()
|
|
||||||
.await;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue