const express = require('express'); const axios = require('axios'); const bodyParser = require('body-parser'); const app = express(); const port = 3000; app.use(bodyParser.json()); app.post('/v1/chat/completions', async (req, res) => { const requestBody = req.body; // Check if the model is gpt-3.5-turbo and change it to gpt if (requestBody.model === 'llama-3.1-8b-instant') { requestBody.model = 'test'; } try { // Forward the modified request to the OpenAI API const response = await axios.post('https://api.groq.com/openai/v1/chat/completions', requestBody, { headers: { 'Authorization': req.headers['authorization'], 'Content-Type': 'application/json' } }); // Send the response back to the client res.json(response.data); } catch (error) { // Handle any errors res.status(error.response ? error.response.status : 500).json({ error: error.message, details: error.response ? error.response.data : null }); } }); app.listen(port, () => { console.log(`API proxy server running on port ${port}`); });