Petalytics integrates directly with OpenRouter API for AI-powered pet insights.
Users provide their own OpenRouter API key through the Guardian Panel.
interface AnalysisRequest {
pet: {
name: string;
breed: string;
age: number;
gender: 'male' | 'female';
};
entry: {
content: string;
date: string;
mood?: string;
activityLevel?: string;
};
recentHistory: JournalEntry[];
}interface AnalysisResult {
summary: string;
moodTrend: 'improving' | 'stable' | 'concerning';
activityLevel: 'low' | 'normal' | 'high';
healthConcerns: string[];
recommendations: string[];
nextCheckupSuggestion?: string;
}import { AIAnalyzer } from '$lib/utils/ai-analysis';
const analyzer = new AIAnalyzer(apiKey);
const result = await analyzer.analyzeJournalEntry(pet, entry);Each line contains a JSON object:
{"version": "1.0.0"}
{"exportDate": "2025-01-01T00:00:00.000Z"}
{"pet": {"id": "123", "name": "Buddy", ...}}
{"aiAnalyses": {"entry-1": {"summary": "...", ...}}}- File must have
.jsonlextension - Version compatibility checking
- Data structure validation
- Duplicate handling
localStorage.setItem('petalytics-pets', JSON.stringify([
{
id: string,
name: string,
breed: string,
age: number,
profileImageUrl?: string,
journalEntries: JournalEntry[]
}
]));localStorage.setItem(
'petalytics-guardian',
JSON.stringify({
name: string,
apiKey: string,
preferences: object,
apiKeyValid: boolean,
})
);