If you use the Gemini API directly, you can integrate Manglai by building a backend that combines both APIs:
import { GoogleGenerativeAI } from '@google/generative-ai';const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);const model = genAI.getGenerativeModel({ model: 'gemini-1.5-pro' });// When the user asks about emissions, call Manglai:const manglaiResponse = await fetch( 'https://www.manglai.io/api/v1/emissions/dashboard?companyId=UUID&startDate=2024-01-01&endDate=2024-12-31', { headers: { Authorization: `Bearer ${process.env.MANGLAI_TOKEN}` } });const data = await manglaiResponse.json();const result = await model.generateContent( `Manglai emissions data: ${JSON.stringify(data)}. Analyze and summarize the key insights.`);