Add openrouter

This commit is contained in:
Joey Yakimowich-Payne 2026-01-15 12:28:51 -07:00
commit 36b686bbd4
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
8 changed files with 380 additions and 61 deletions

View file

@ -600,7 +600,15 @@ export const useGame = () => {
return response.json();
};
const startQuizGen = async (options: { topic?: string; questionCount?: number; files?: File[]; useOcr?: boolean }) => {
const startQuizGen = async (options: {
topic?: string;
questionCount?: number;
files?: File[];
useOcr?: boolean;
aiProvider?: 'gemini' | 'openrouter';
apiKey?: string;
openRouterModel?: string;
}) => {
try {
setGameState('GENERATING');
setError(null);
@ -616,7 +624,10 @@ export const useGame = () => {
const generateOptions: GenerateQuizOptions = {
topic: options.topic,
questionCount: options.questionCount,
documents
documents,
aiProvider: options.aiProvider,
apiKey: options.apiKey,
openRouterModel: options.openRouterModel,
};
const generatedQuiz = await generateQuiz(generateOptions);

View file

@ -6,6 +6,7 @@ import { COLOR_SCHEMES } from '../types';
const DEFAULT_PREFERENCES: UserPreferences = {
colorScheme: 'blue',
aiProvider: 'gemini',
};
export const applyColorScheme = (schemeId: string) => {
@ -42,7 +43,10 @@ export const useUserPreferences = (): UseUserPreferencesReturn => {
const data = await response.json();
const prefs: UserPreferences = {
colorScheme: data.colorScheme || 'blue',
aiProvider: data.aiProvider || 'gemini',
geminiApiKey: data.geminiApiKey || undefined,
openRouterApiKey: data.openRouterApiKey || undefined,
openRouterModel: data.openRouterModel || undefined,
};
setPreferences(prefs);
setHasAIAccess(data.hasAIAccess || false);