refactor(open-sse): B1 consolidate media endpoint URLs into registry
- 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>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// Black Forest Labs (FLUX) — async submit + polling_url
|
||||
import { sleep, nowSec, POLL_INTERVAL_MS, POLL_TIMEOUT_MS } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = "https://api.bfl.ai/v1";
|
||||
const BASE_URL = PROVIDER_MEDIA["black-forest-labs"]?.imageConfig?.baseUrl;
|
||||
|
||||
export default {
|
||||
async: true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { nowSec, urlToBase64 } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = "https://api.cloudflare.com/client/v4/accounts";
|
||||
const BASE_URL = PROVIDER_MEDIA["cloudflare-ai"]?.imageConfig?.baseUrl;
|
||||
|
||||
const MULTIPART_MODELS = new Set([
|
||||
"@cf/black-forest-labs/flux-2-dev",
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
// ComfyUI — local, noAuth (placeholder; full graph workflow not implemented)
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = PROVIDER_MEDIA["comfyui"]?.imageConfig?.baseUrl;
|
||||
|
||||
export default {
|
||||
noAuth: true,
|
||||
buildUrl: () => "http://localhost:8188",
|
||||
buildUrl: () => BASE_URL,
|
||||
buildHeaders: () => ({ "Content-Type": "application/json" }),
|
||||
buildBody: (_model, body) => ({ prompt: body.prompt }),
|
||||
normalize: (responseBody) => responseBody,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Fal.ai — async submit + queue polling
|
||||
import { sleep, nowSec, sizeToAspectRatio, POLL_INTERVAL_MS, POLL_TIMEOUT_MS } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = "https://queue.fal.run";
|
||||
const BASE_URL = PROVIDER_MEDIA["fal-ai"]?.imageConfig?.baseUrl;
|
||||
|
||||
export default {
|
||||
async: true,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Google Gemini adapter (Nano Banana models)
|
||||
import { nowSec } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = "https://generativelanguage.googleapis.com/v1beta/models";
|
||||
const BASE_URL = PROVIDER_MEDIA["gemini"]?.imageConfig?.baseUrl;
|
||||
|
||||
export default {
|
||||
buildUrl: (model, creds) => {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// HuggingFace Inference API — returns binary image
|
||||
import { nowSec } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = "https://api-inference.huggingface.co/models";
|
||||
const BASE_URL = PROVIDER_MEDIA["huggingface"]?.imageConfig?.baseUrl;
|
||||
|
||||
export default {
|
||||
buildUrl: (model) => `${BASE_URL}/${model}`,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// NanoBanana API — async submit + poll record-info
|
||||
import { sleep, nowSec, sizeToAspectRatio, POLL_INTERVAL_MS, POLL_TIMEOUT_MS } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const SUBMIT_URL = "https://api.nanobananaapi.ai/api/v1/nanobanana/generate";
|
||||
const POLL_BASE = "https://api.nanobananaapi.ai/api/v1/nanobanana/record-info";
|
||||
const IMG_CFG = PROVIDER_MEDIA["nanobanana"]?.imageConfig || {};
|
||||
const SUBMIT_URL = IMG_CFG.baseUrl;
|
||||
const POLL_BASE = IMG_CFG.pollUrl;
|
||||
|
||||
export default {
|
||||
async: true,
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
// OpenAI-compatible adapter (used by openai, minimax, openrouter, recraft)
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
// media-only providers without a registry file keep their URL here; rest derive from registry media.imageConfig.baseUrl
|
||||
const ENDPOINTS = {
|
||||
recraft: "https://external.api.recraft.ai/v1/images/generations",
|
||||
};
|
||||
|
||||
const imageCfg = (id) => PROVIDER_MEDIA[id]?.imageConfig || {};
|
||||
const imageUrl = (id) => imageCfg(id).baseUrl || ENDPOINTS[id];
|
||||
const imageUrl = (id) => imageCfg(id).baseUrl;
|
||||
|
||||
export default function createOpenAIAdapter(providerId) {
|
||||
const cfg = imageCfg(providerId);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Runway ML — async submit + /tasks/{id} polling
|
||||
import { sleep, nowSec, sizeToAspectRatio, POLL_INTERVAL_MS, POLL_TIMEOUT_MS } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = "https://api.dev.runwayml.com/v1";
|
||||
const BASE_URL = PROVIDER_MEDIA["runwayml"]?.imageConfig?.baseUrl;
|
||||
|
||||
export default {
|
||||
async: true,
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// SD WebUI (AUTOMATIC1111) — local, noAuth
|
||||
import { nowSec } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = PROVIDER_MEDIA["sdwebui"]?.imageConfig?.baseUrl;
|
||||
|
||||
export default {
|
||||
noAuth: true,
|
||||
buildUrl: () => "http://localhost:7860/sdapi/v1/txt2img",
|
||||
buildUrl: () => BASE_URL,
|
||||
buildHeaders: () => ({ "Content-Type": "application/json" }),
|
||||
buildBody: (_model, body) => {
|
||||
const { prompt, n = 1, size = "1024x1024" } = body;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Stability AI v2 — sync, returns { image: "<b64>" }
|
||||
import { nowSec, sizeToAspectRatio } from "./_base.js";
|
||||
import { PROVIDER_MEDIA } from "../../providers/index.js";
|
||||
|
||||
const BASE_URL = "https://api.stability.ai/v2beta/stable-image/generate";
|
||||
const BASE_URL = PROVIDER_MEDIA["stability-ai"]?.imageConfig?.baseUrl;
|
||||
|
||||
// Map model id → endpoint segment
|
||||
function modelToEndpoint(model) {
|
||||
|
||||
Reference in New Issue
Block a user