export async function embedText(text: string): Promise { if (!process.env.VOYAGE_API_KEY) throw new Error('VOYAGE_API_KEY is not set') const res = await fetch('https://api.voyageai.com/v1/embeddings', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.VOYAGE_API_KEY}`, }, body: JSON.stringify({ input: [text], model: 'voyage-3-lite' }), }) if (!res.ok) throw new Error(`Voyage embed failed: ${res.status}`) const json = await res.json() as { data: Array<{ embedding: number[] }> } return json.data[0].embedding }