feat(ai): add OpenRouterClient implementing LlmClient

OpenAI-compatible client for OpenRouter. Translates canonical wire shapes at
the boundary: tool-call arguments stringify on send / parse on receive
(accepting both string and native-object forms); images rewritten from the
base64 images field into content-parts with image_url entries; role=tool
messages inherit tool_call_id from the preceding assistant's tool calls.

/models parsed into ModelCapabilities via supported_parameters (tool use)
and architecture.input_modalities (vision). 15-minute capabilities cache.
Bearer auth; HTTP-Referer / X-Title attribution headers optional.

Not wired into request routing yet — first consumer arrives with hybrid
backend mode. 11 unit tests cover the translation helpers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cameron
2026-04-20 22:18:29 -04:00
parent 0073409b3d
commit e799ba716c
2 changed files with 728 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ pub mod handlers;
pub mod insight_generator;
pub mod llm_client;
pub mod ollama;
pub mod openrouter;
pub mod sms_client;
// strip_summary_boilerplate is used by binaries (test_daily_summary), not the library