mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
- image/embed/tts/search base URLs derive from media.*Config.baseUrl / searchViaChat.endpoint (single source); handlers read PROVIDER_MEDIA. - ~18 hardcoded endpoints moved: bfl/fal/stability/runway/hf/gemini/ cloudflare/recraft/sdwebui/comfyui/nanobanana image, voyage embed, gemini/openrouter tts, chatSearch endpoints. - Byte-identical: PROVIDERS 62 + alias 90 baselines, image buildUrl outputs. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
// Google Gemini adapter (Nano Banana models)
|
|
import { nowSec } from "./_base.js";
|
|
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
|
|
|
const BASE_URL = PROVIDER_MEDIA["gemini"]?.imageConfig?.baseUrl;
|
|
|
|
export default {
|
|
buildUrl: (model, creds) => {
|
|
const apiKey = creds?.apiKey || creds?.accessToken;
|
|
const modelId = model.replace(/^models\//, "");
|
|
return `${BASE_URL}/${modelId}:generateContent?key=${encodeURIComponent(apiKey)}`;
|
|
},
|
|
buildHeaders: () => ({ "Content-Type": "application/json" }),
|
|
buildBody: (_model, body) => ({
|
|
contents: [{ parts: [{ text: body.prompt }] }],
|
|
generationConfig: { responseModalities: ["TEXT", "IMAGE"] },
|
|
}),
|
|
normalize: (responseBody, prompt) => {
|
|
const parts = responseBody.candidates?.[0]?.content?.parts || [];
|
|
const images = parts.filter((p) => p.inlineData?.data).map((p) => ({ b64_json: p.inlineData.data }));
|
|
return {
|
|
created: nowSec(),
|
|
data: images.length > 0 ? images : [{ b64_json: "", revised_prompt: prompt }],
|
|
};
|
|
},
|
|
};
|