mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-12 09:46:56 +02:00
debug(ai): add diagnostic logs for AI API key persistence
This commit is contained in:
1 parent
c41a60b430
commit
85215565fa
2 files changed
+12
-2
No files matched your search
@@ -19,14 +19,18 @@ Ta réponse doit être en 1-2 phrases maximum, en français, directe et actionna
|
||||
Format: "[Recommandation]: [Justification courte basée sur les données]"`;
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
console.log("[AI] Analysis request received.");
|
||||
const config = await getSavedDatabaseConfig();
|
||||
const apiKey = process.env.OPENROUTER_API_KEY || config?.openRouterKey;
|
||||
const model = config?.openRouterModel || "google/gemini-flash-1.5";
|
||||
|
||||
if (!apiKey) {
|
||||
console.error("[AI] OPENROUTER_API_KEY is missing (neither in env nor in config file).");
|
||||
return NextResponse.json({ error: "OPENROUTER_API_KEY not configured. Please set it in Settings." }, { status: 503 });
|
||||
}
|
||||
|
||||
console.log(`[AI] Using model: ${model} with API key starting with ${apiKey.substring(0, 10)}...`);
|
||||
|
||||
const body = await req.json();
|
||||
const parsed = AnalyzeSchema.safeParse(body);
|
||||
if (!parsed.success) {
|
||||
|
||||
Reference in new issue
Block a user