#include "vendors/compat/registry.h" #include "llm/error.h" namespace molo::compat { namespace { constexpr unsigned C = Feature::kChat; constexpr unsigned E = Feature::kEmbeddings; constexpr unsigned M = Feature::kModels; constexpr unsigned I = Feature::kImages; constexpr unsigned T = Feature::kTranscribe; constexpr unsigned S = Feature::kSpeech; constexpr Evidence DP = Evidence::kDocsAndProbe; constexpr Evidence PO = Evidence::kProbeOnly; constexpr Evidence DO = Evidence::kDocsOnly; // Probe date for every "Probe:" note: 2026-10-25, unauthenticated, no key sent. // Fields: id, name, base_url, key_env, base_env, extra_env, models_path, // features, quirks, evidence, local, doc_url, note. const ProviderRow kRows[] = { {"groq", "Groq", "https://api.groq.com/openai/v1", "GROQ_API_KEY", "", "", "/models", C | M | T, Quirk::kRejectLogprobs | Quirk::kRejectMessageName | Quirk::kSingleChoice, DP, false, "https://console.groq.com/docs/openai", "Docs: logprobs, logit_bias, top_logprobs and messages[].name answer 400; n must be 1; temperature 0 " "becomes 1e-8; transcription formats vtt and srt unsupported. Probe: 401 invalid_api_key on /models and chat."}, {"together", "Together AI", "https://api.together.ai/v1", "TOGETHER_API_KEY", "", "", "/models", C | E | M | I | T | S, Quirk::kNone, DP, false, "https://docs.together.ai/docs/openai-api-compatibility", "Docs: logit_bias unsupported on most models; service_tier, store, metadata and prediction are accepted " "and ignored. Probe: 401 on /models and chat; legacy host api.together.xyz answers 401 too."}, {"fireworks", "Fireworks AI", "https://api.fireworks.ai/inference/v1", "FIREWORKS_API_KEY", "", "", "/models", C | E | M, Quirk::kNone, DP, false, "https://docs.fireworks.ai/tools-sdks/openai-compatibility", "Probe: /models 401 with a docs link; unknown model answers 404 NOT_FOUND; empty embeddings body answers 500."}, {"cerebras", "Cerebras", "https://api.cerebras.ai/v1", "CEREBRAS_API_KEY", "", "", "/models", C | M, Quirk::kNoToolsWithFormat, DP, false, "https://inference-docs.cerebras.ai/resources/openai", "Docs: tools and response_format must not be combined (gpt-oss-120b rejects it); system and developer roles " "both act at developer level. Probe: /models 403 {detail}, chat 401 wrong_api_key, embeddings path 404."}, {"sambanova", "SambaNova", "https://api.sambanova.ai/v1", "SAMBANOVA_API_KEY", "", "", "/models", C | E | M, Quirk::kNone, PO, false, "https://docs.sambanova.ai/docs/en/features/openai-compatibility", "Docs page answers 403 to a plain fetch. Probe: /models 200 public; chat 401 (also accepts x-api-key); " "embeddings answers 400 'must provide a model' before auth."}, {"deepinfra", "DeepInfra", "https://api.deepinfra.com/v1/openai", "DEEPINFRA_API_KEY", "", "", "/models", C | E | M | I | T, Quirk::kNone, DP, false, "https://docs.deepinfra.com/chat/overview", "Probe: /models 200 public; chat 401 missing API key; images and audio paths answer 401 with a {detail} body."}, {"novita", "Novita AI", "https://api.novita.ai/openai/v1", "NOVITA_API_KEY", "", "", "/models", C | M, Quirk::kNone, DP, false, "https://novita.ai/docs/guides/llm-api", "Probe: /models 200 public; bad key answers 403 INVALID_API_KEY (not 401); legacy base /v3/openai answers the same."}, {"nvidia", "NVIDIA NIM (build.nvidia.com)", "https://integrate.api.nvidia.com/v1", "NVIDIA_API_KEY", "", "", "/models", C | E | M, Quirk::kNone, DP, false, "https://docs.api.nvidia.com/nim/reference/llm-apis", "Probe: /models 200 public; embeddings answers 400 'model field is required'; retired models answer 410 Gone."}, {"cloudflare", "Cloudflare Workers AI", "https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1", "CLOUDFLARE_API_TOKEN", "", "CLOUDFLARE_ACCOUNT_ID", "", C | E, Quirk::kNone, DO, false, "https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/", "Docs list /chat/completions, /embeddings and /responses under the account path. Probe: GET /models answers " "405 (no list endpoint here); not probeable further without an account id."}, {"moonshot", "Moonshot (Kimi)", "https://api.moonshot.ai/v1", "MOONSHOT_API_KEY", "", "", "/models", C | M, Quirk::kNone, DP, false, "https://platform.kimi.ai/docs/api/chat", "Probe: 401 incorrect_api_key_error on /models and chat; the China host api.moonshot.cn answers the same " "(separate keys)."}, {"dashscope", "Alibaba DashScope (Qwen, intl)", "https://dashscope-intl.aliyuncs.com/compatible-mode/v1", "DASHSCOPE_API_KEY", "", "", "", C | E, Quirk::kNone, DP, false, "https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope", "Probe: 401 on /models and chat; embeddings answers 400 'you must provide a model parameter'; China host " "dashscope.aliyuncs.com/compatible-mode/v1 answers 401 too."}, {"zhipu", "Zhipu (GLM, China)", "https://open.bigmodel.cn/api/paas/v4", "ZHIPU_API_KEY", "", "", "", C | E | I, Quirk::kNone, DP, false, "https://docs.bigmodel.cn/cn/guide/develop/openai/introduction", "Docs name the base URL; the path is /api/paas/v4, not /v1. Probe: 401 code 1001 (missing Authorization) " "on chat, embeddings and images."}, {"zai", "Z.ai (GLM, international)", "https://api.z.ai/api/paas/v4", "ZAI_API_KEY", "", "", "", C | E | I, Quirk::kNone, DP, false, "https://docs.z.ai/api-reference/introduction", "International host of the Zhipu API, same /api/paas/v4 path. Probe: 401 code 1001."}, {"minimax", "MiniMax", "https://api.minimax.io/v1", "MINIMAX_API_KEY", "", "", "", C, Quirk::kNone, PO, false, "https://platform.minimax.io/docs/api-reference/text-openai-api", "Docs text did not name the URL. Probe: 401 authorized_error on /models and chat; embeddings answers HTTP 200 " "with a base_resp status_code 1004 envelope (not OpenAI shaped); China host api.minimaxi.com answers 401."}, {"qianfan", "Baidu Qianfan", "https://qianfan.baidubce.com/v2", "QIANFAN_API_KEY", "", "", "", C | E, Quirk::kNone, PO, false, "https://cloud.baidu.com/doc/qianfan-api/s/3m9b5lqft", "Docs page is rendered client side. Probe: chat and embeddings 401 invalid_iam_token; GET /models 403 " "AccessDenied (different envelope)."}, {"ark", "Volcengine Ark (Doubao)", "https://ark.cn-beijing.volces.com/api/v3", "ARK_API_KEY", "", "", "", C, Quirk::kNone, PO, false, "https://www.volcengine.com/docs/82379/1298454", "Docs page is rendered client side. Probe: 401 AuthenticationError on /models, chat and embeddings; path is /api/v3."}, {"siliconflow", "SiliconFlow", "https://api.siliconflow.com/v1", "SILICONFLOW_API_KEY", "", "", "/models", C | E | M, Quirk::kNone, DP, false, "https://docs.siliconflow.com/en/api-reference/chat-completions/chat-completions", "Probe: 401 code 30014 with a {code,data,message} envelope on every path; China host api.siliconflow.cn identical."}, {"nebius", "Nebius Token Factory", "https://api.studio.nebius.com/v1", "NEBIUS_API_KEY", "", "", "/models", C | E | M, Quirk::kNone, DP, false, "https://docs.tokenfactory.nebius.com/api-reference/introduction", "Probe: 401 unauthenticated on /models, chat and embeddings; images/generations 404 on this host; " "api.tokenfactory.nebius.com/v1 answers the same."}, {"scaleway", "Scaleway Generative APIs", "https://api.scaleway.ai/v1", "SCALEWAY_API_KEY", "", "", "/models", C | E | M, Quirk::kNone, DP, false, "https://www.scaleway.com/en/docs/generative-apis/api-cli/using-chat-api/", "Probe: 401 UNAUTHORIZED (missing 'Authorization' header) on /models, chat and embeddings."}, {"upstage", "Upstage (Solar)", "https://api.upstage.ai/v1", "UPSTAGE_API_KEY", "", "", "", C | E, Quirk::kNone, DP, false, "https://console.upstage.ai/docs/getting-started", "Probe: 401 invalid API key on /models, chat and embeddings."}, {"inception", "Inception (Mercury)", "https://api.inceptionlabs.ai/v1", "INCEPTION_API_KEY", "", "", "/models", C | M, Quirk::kNone, DP, false, "https://docs.inceptionlabs.ai/get-started/get-started", "Probe: /models 200 public; chat answers 400 listing the valid model names before auth."}, {"stepfun", "StepFun", "https://api.stepfun.com/v1", "STEPFUN_API_KEY", "", "", "/models", C | M, Quirk::kNone, DP, false, "https://platform.stepfun.com/docs/api-reference/chat/chat-completion-create", "Probe: 401 invalid_api_key on /models and chat."}, {"hunyuan", "Tencent Hunyuan", "https://api.hunyuan.cloud.tencent.com/v1", "HUNYUAN_API_KEY", "", "", "", C, Quirk::kNone, PO, false, "https://cloud.tencent.com/document/product/1729/111007", "Docs page did not name the URL in readable text. Probe: 401 'Incorrect API key provided' on /models and chat."}, {"venice", "Venice AI", "https://api.venice.ai/api/v1", "VENICE_API_KEY", "", "", "/models", C | M, Quirk::kNone, DP, false, "https://docs.venice.ai/api-reference/endpoint/chat/completions", "Probe: /models 200 public; unauthenticated chat answers 402 with an x402 payment envelope (not 401)."}, {"vercel", "Vercel AI Gateway", "https://ai-gateway.vercel.sh/v1", "AI_GATEWAY_API_KEY", "", "", "/models", C | M, Quirk::kNone, DP, false, "https://vercel.com/docs/ai-gateway/openai-compat", "Probe: /models 200 public; chat 401 authentication_error 'Missing Authorization header'."}, {"friendli", "FriendliAI Serverless", "https://api.friendli.ai/serverless/v1", "FRIENDLI_TOKEN", "", "", "/models", C | M, Quirk::kNone, DP, false, "https://friendli.ai/docs/openapi/serverless/chat-completions", "Probe: /models 200 public; chat 401 {detail}."}, {"gemini", "Google Gemini (OpenAI compatibility)", "https://generativelanguage.googleapis.com/v1beta/openai", "GEMINI_API_KEY", "", "", "", C, Quirk::kNone, DP, false, "https://ai.google.dev/gemini-api/docs/openai", "Probe: chat answers 400 'Missing or invalid Authorization header'; unauthenticated GET /models and " "embeddings answer 404, so only chat is claimed."}, {"baseten", "Baseten Model APIs", "https://inference.baseten.co/v1", "BASETEN_API_KEY", "", "", "", C, Quirk::kNone, DP, false, "https://docs.baseten.co/development/model-apis/overview", "Probe: /models 401 'No Authorization header provided'; chat 403 'please check the api-key you provided'."}, {"featherless", "Featherless AI", "https://api.featherless.ai/v1", "FEATHERLESS_API_KEY", "", "", "/models", C | M, Quirk::kNone, PO, false, "https://featherless.ai/docs/overview", "Docs text did not name the URL. Probe: /models 200 public; chat 401 'must be signed in'."}, {"ovh", "OVHcloud AI Endpoints", "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1", "OVH_AI_ENDPOINTS_ACCESS_TOKEN", "", "", "/models", C | M, Quirk::kNone, PO, false, "https://help.ovhcloud.com/csm/en-gb-public-cloud-ai-endpoints-getting-started", "Docs text did not name the URL. Probe: /models 200 public; chat on an unknown model answers 404 model_not_found."}, {"parasail", "Parasail", "https://api.parasail.io/v1", "PARASAIL_API_KEY", "", "", "/models", C | M, Quirk::kNone, PO, false, "https://docs.parasail.io/parasail-docs/serverless/serverless", "Docs URL answered 404 at probe time. Probe: 401 'No bearer token provided' on /models and chat."}, {"crusoe", "Crusoe Managed Inference", "https://managed-inference-api-proxy.crusoecloud.com/v1", "CRUSOE_API_KEY", "", "", "/models", C | M, Quirk::kNone, PO, false, "https://docs.crusoe.ai/managed-inference", "Docs URL answered 404 at probe time. Probe: 401 {errors:[Authentication failed]} on /models and chat."}, {"xiaomi", "Xiaomi MiMo", "https://api.xiaomimimo.com/v1", "XIAOMI_API_KEY", "", "", "", C, Quirk::kNone, PO, false, "https://platform.xiaomimimo.com/", "Docs text did not name the URL. Probe: 401 'Invalid API Key' on /models and chat."}, {"chutes", "Chutes", "https://llm.chutes.ai/v1", "CHUTES_API_KEY", "", "", "/models", C | M, Quirk::kNone, PO, false, "https://docs.chutes.ai/", "Docs text did not name the URL. Probe: /models 200 public; chat answered an nginx 429 HTML page."}, // Self-hosted servers: the key is optional, the row is configured when its base_env is set. {"ollama", "Ollama", "http://localhost:11434/v1", "OLLAMA_API_KEY", "OLLAMA_BASE_URL", "", "/models", C | E | M, Quirk::kNone, DO, true, "https://raw.githubusercontent.com/ollama/ollama/main/docs/api/openai-compatibility.mdx", "Docs name http://localhost:11434/v1. The key is required by OpenAI clients but ignored by the server; " "the module sends the placeholder 'local' when none is set."}, {"lmstudio", "LM Studio", "http://localhost:1234/v1", "LMSTUDIO_API_KEY", "LMSTUDIO_BASE_URL", "", "/models", C | E | M, Quirk::kNone, DO, true, "https://lmstudio.ai/docs/developer/openai-compat", "Docs name http://localhost:1234/v1. Key ignored unless configured in the app."}, {"vllm", "vLLM server", "http://localhost:8000/v1", "VLLM_API_KEY", "VLLM_BASE_URL", "", "/models", C | E | M | T, Quirk::kNone, DO, true, "https://docs.vllm.ai/en/latest/serving/online_serving/", "Docs list /v1/chat/completions, /v1/embeddings and /v1/audio/transcriptions; key only when the server " "was started with --api-key."}, {"llamacpp", "llama.cpp server", "http://localhost:8080/v1", "LLAMACPP_API_KEY", "LLAMACPP_BASE_URL", "", "/models", C | E | M, Quirk::kNone, DO, true, "https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/server/README.md", "README lists /v1/chat/completions; key only when started with --api-key. Same default port as LocalAI."}, {"localai", "LocalAI", "http://localhost:8080/v1", "LOCALAI_API_KEY", "LOCALAI_BASE_URL", "", "/models", C | E | M, Quirk::kNone, DO, true, "https://localai.io/docs/overview/", "Docs name localhost:8080; endpoint list beyond chat, embeddings and models was not read."}, }; constexpr std::size_t kRowCount = sizeof(kRows) / sizeof(kRows[0]); } // namespace std::size_t Registry::count() { return kRowCount; } const ProviderRow& Registry::at(std::size_t index) { if (index >= kRowCount) throw llm::ApiError::invalid("compat", "registry index out of range"); return kRows[index]; } const ProviderRow* Registry::find(const std::string& id) { for (const ProviderRow& row : kRows) if (id == row.id) return &row; return nullptr; } const ProviderRow& Registry::get(const std::string& id) { const ProviderRow* row = find(id); if (!row) throw llm::ApiError::invalid("compat", "unknown provider '" + id.substr(0, 64) + "'"); return *row; } const char* Registry::evidence_name(Evidence e) { switch (e) { case Evidence::kDocsAndProbe: return "docs+probe"; case Evidence::kProbeOnly: return "probe-only"; case Evidence::kDocsOnly: return "docs-only"; } return ""; } std::string Registry::feature_names(const ProviderRow& row) { struct Name { unsigned bit; const char* name; }; static const Name names[] = {{Feature::kChat, "chat"}, {Feature::kEmbeddings, "embeddings"}, {Feature::kModels, "models"}, {Feature::kImages, "images"}, {Feature::kTranscribe, "transcribe"}, {Feature::kSpeech, "speech"}}; std::string out; for (const Name& n : names) if (row.features & n.bit) out += (out.empty() ? "" : ",") + std::string(n.name); return out; } } // namespace molo::compat