{"repo": "asbeel24/d4nn9-t2sa", "files": {"api/proxy.js": {"81d81584f1d9d21ac52a8cc1108f6d0aa5857611": {"t": 1785674016.7367868, "n": 2016, "h": "5cc70f81f040dac6", "c": "export default async function handler(req, res) {\n if (req.method !== 'POST') {\n return res.status(405).json({ error: 'Method not allowed' });\n }\n\n const { prompt, apiKey } = req.body;\n\n if (!prompt) {\n return res.status(400).json({ error: 'Prompt is required' });\n }\n\n const key = apiKey || 'sk-cp-beZ0Hla9omb-IIQ9BTzElJfd4hsfZiQGqSPis7voYd9oAIeFsJa5lchL4kID9WuEcYnta1Lny4ZFVb-hp-I0aYg8kcT4QjGG_S_lMWbvudm-O7njOaWI1FI';\n\n try {\n const response = await fetch('https://api.minimaxi.com/anthropic/v1/messages', {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${key}`,\n 'Content-Type': 'application/json',\n 'anthropic-version': '2023-06-01'\n },\n body: JSON.stringify({\n model: 'Minimax-M2.7',\n max_tokens: 32000,\n stream: true,\n messages: [{ role: 'user', content: prompt }]\n })\n });\n\n if (!response.ok) {\n const error = await response.text();\n return res.status(response.status).json({ error });\n }\n\n res.setHeader('Content-Type', 'text/event-stream');\n res.setHeader('Cache-Control', 'no-cache');\n res.setHeader('Connection', 'keep-alive');\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value);\n const lines = chunk.split('\\n');\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.slice(6);\n if (data === '[DONE]') continue;\n\n try {\n const json = JSON.parse(data);\n if (json.type === 'content_block_delta' && json.delta && json.delta.text) {\n res.write(`data: ${JSON.stringify({ text: json.delta.text })}\\n\\n`);\n }\n } catch (e) {}\n }\n }\n }\n\n res.end();\n } catch (error) {\n console.error('Proxy error:', error);\n res.status(500).json({ error: error.message });\n }\n}"}}}}