Skip to main content

Module chat_api

Module chat_api 

Source
Expand description

HTTP client for the OpenRouter chat-completions API (direct HTTP, no CLI subprocess). HTTP client for the OpenRouter chat-completions API.

Sends structured-output chat requests to the OpenAI-compatible endpoint at openrouter.ai/api/v1/chat/completions and returns the parsed JSON object the model produced under a strict json_schema response_format.

This mirrors crate::embedding_api for the embeddings endpoint: same retry/backoff policy (immediate abort on 401/400/404, retry-after on 429, exponential backoff + jitter on 5xx) and the same minimal headers (only Authorization: Bearer, no HTTP-Referer/X-Title).

v1.0.95 (ADR-0054): adds an OpenRouter REST transport for the enrich JUDGE so structured extraction no longer requires a locally installed claude / codex / opencode CLI subprocess.

Structsยง

OpenRouterChatClient
Process-wide OpenRouter chat client. Holds the model name so that callers only thread the per-item prompt/schema/input through Self::complete.