Spaces:
Sleeping
Sleeping
| const handler = async (req, res) => { | |
| try { | |
| const { text, model = 'qwen3-max' } = req.query; | |
| if (!text) { | |
| return res.status(400).json({ | |
| success: false, | |
| error: 'Missing required parameter: text' | |
| }); | |
| } | |
| const apiKey = process.env.QWEN; | |
| if (!apiKey) { | |
| return res.status(500).json({ | |
| success: false, | |
| error: 'QWEN API key not configured' | |
| }); | |
| } | |
| const url = `https://qwen-azure.vercel.app/api/qwen?text=${encodeURIComponent(text)}&model=${model}&key=${apiKey}`; | |
| const response = await fetch(url); | |
| const result = await response.json(); | |
| if (!response.ok || !result.success) { | |
| return res.status(response.status || 500).json({ | |
| success: false, | |
| error: result.error || 'Failed to get response from Qwen API' | |
| }); | |
| } | |
| res.json({ | |
| author: "Herza", | |
| success: true, | |
| data: result.data | |
| }); | |
| } catch (error) { | |
| res.status(500).json({ | |
| success: false, | |
| error: error.message | |
| }); | |
| } | |
| }; | |
| module.exports = { | |
| name: 'Qwen AI', | |
| description: 'Generate responses using Qwen AI', | |
| type: 'GET', | |
| routes: ['api/AI/qwen'], | |
| tags: ['ai', 'qwen'], | |
| main: ['AI'], | |
| parameters: ['text', 'model', 'key'], | |
| enabled: true, | |
| handler | |
| }; |