mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +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>
24 lines
877 B
JavaScript
24 lines
877 B
JavaScript
// HuggingFace Inference API — returns binary image
|
|
import { nowSec } from "./_base.js";
|
|
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
|
|
|
const BASE_URL = PROVIDER_MEDIA["huggingface"]?.imageConfig?.baseUrl;
|
|
|
|
export default {
|
|
buildUrl: (model) => `${BASE_URL}/${model}`,
|
|
buildHeaders: (creds) => {
|
|
const headers = { "Content-Type": "application/json" };
|
|
const key = creds?.apiKey || creds?.accessToken;
|
|
if (key) headers["Authorization"] = `Bearer ${key}`;
|
|
return headers;
|
|
},
|
|
buildBody: (_model, body) => ({ inputs: body.prompt }),
|
|
// HF returns raw image bytes — convert to b64_json
|
|
async parseResponse(response) {
|
|
const buf = await response.arrayBuffer();
|
|
const base64 = Buffer.from(buf).toString("base64");
|
|
return { created: nowSec(), data: [{ b64_json: base64 }] };
|
|
},
|
|
normalize: (responseBody) => responseBody,
|
|
};
|