mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-18 21:20:39 +01:00
[wip] OpenRouter: Add model providers endpoint
This commit is contained in:
parent
71e1fc91f1
commit
bfd57b66ef
@ -4,6 +4,31 @@ import { jsonParser } from '../express-common.js';
|
||||
export const router = express.Router();
|
||||
const API_OPENROUTER = 'https://openrouter.ai/api/v1';
|
||||
|
||||
router.post('/models/providers', jsonParser, async (req, res) => {
|
||||
try {
|
||||
const { model } = req.body;
|
||||
const response = await fetch(`${API_OPENROUTER}/models/${model}/endpoints`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return res.json([]);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const endpoints = data?.data?.endpoints || [];
|
||||
const providerNames = endpoints.map(e => e.provider_name);
|
||||
|
||||
return res.json(providerNames);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/models/multimodal', jsonParser, async (_req, res) => {
|
||||
try {
|
||||
// The endpoint is available without authentication
|
||||
|
Loading…
x
Reference in New Issue
Block a user