Transcribe through OpenRouter when OPENROUTER_API_KEY is set

A Claude subscription can't be used by the app, so let it use any cheap
vision model on OpenRouter instead (default google/gemini-3.1-flash-lite,
OPENROUTER_MODEL to change). The Anthropic API stays available as the
second choice. Both providers share the prompt and live behind one
{ name, model, transcribe } interface in server/providers.mjs; OpenRouter
retries 408/429/5xx and network errors and turns 401/402/404 into
messages the editor can show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gVRDXpoukzgMFumoJt
This commit is contained in:
agent 2026-11-04 15:38:24 +00:00
parent 46aa1236ed
commit f353c14619
11 changed files with 258 additions and 91 deletions

View file

@ -20,7 +20,7 @@
<fieldset class="field">
<legend>Fotky stran</legend>
<p class="muted" id="ai-note">Každou stranu přečte umělá inteligence (Claude) a přepíše ji do textu. Text pak zkontrolujete a opravíte v editoru, než hru zveřejníte.</p>
<p class="muted" id="ai-note">Každou stranu přečte umělá inteligence a přepíše ji do textu. Text pak zkontrolujete a opravíte v editoru, než hru zveřejníte.</p>
<label class="dropzone" id="drop">
<input type="file" id="files" accept="image/*" multiple>
<span><b>Vyberte fotky</b> nebo je sem přetáhněte. Jedna fotka = jedna strana.</span>

View file

@ -105,7 +105,7 @@ async function main() {
return;
}
if (!cfg.transcription) {
$("ai-note").textContent = "Automatický přepis není na serveru zapnutý (chybí klíč k API). Fotky se nahrají a text pak napíšete v editoru ručně.";
$("ai-note").textContent = "Automatický přepis není na serveru zapnutý (chybí klíč OPENROUTER_API_KEY nebo ANTHROPIC_API_KEY). Fotky se nahrají a text pak napíšete v editoru ručně.";
$("go").textContent = "Nahrát";
}
if (!getPassword()) askPassword("Přidávat hry může jen ten, kdo zná heslo.");