Add OpenRouter headers to image generation requests
| @@ -2,6 +2,7 @@ import express from 'express'; | |||
| 2 | import fetch from 'node-fetch'; | 2 | import fetch from 'node-fetch'; |
| 3 | import mime from 'mime-types'; | 3 | import mime from 'mime-types'; |
| 4 | import { readSecret, SECRET_KEYS } from './secrets.js'; | 4 | import { readSecret, SECRET_KEYS } from './secrets.js'; |
| 5 | import { OPENROUTER_HEADERS } from '../constants.js'; | ||
| 5 | 6 | ||
| 6 | export const router = express.Router(); | 7 | export const router = express.Router(); |
| 7 | const API_OPENROUTER = 'https://openrouter.ai/api/v1'; | 8 | const API_OPENROUTER = 'https://openrouter.ai/api/v1'; |
| @@ -119,6 +120,7 @@ router.post('/image/generate', async (req, res) => { | |||
| 119 | const response = await fetch(`${API_OPENROUTER}/chat/completions`, { | 120 | const response = await fetch(`${API_OPENROUTER}/chat/completions`, { |
| 120 | method: 'POST', | 121 | method: 'POST', |
| 121 | headers: { | 122 | headers: { |
| 123 | ...OPENROUTER_HEADERS, | ||
| 122 | 'Content-Type': 'application/json', | 124 | 'Content-Type': 'application/json', |
| 123 | 'Authorization': `Bearer ${key}`, | 125 | 'Authorization': `Bearer ${key}`, |
| 124 | }, | 126 | }, |