Spaces:
Paused
Paused
| import fetch from 'node-fetch' | |
| export async function proxyGemini(prompt: string) { | |
| const url = | |
| 'https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent?key=' + | |
| process.env.GEMINI_API_KEY | |
| const r = await fetch(url, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| contents: [{ parts: [{ text: prompt }] }] | |
| }) | |
| }) | |
| const j: any = await r.json() | |
| const text = j.candidates?.[0]?.content?.parts?.[0]?.text || '' | |
| return text | |
| } | |