// @bun
import {
  init_envUtils,
  isEnvTruthy
} from "./chunk-3r24h7t6.js";
import {
  __esm
} from "./chunk-qp2qdcda.js";

// src/utils/model/providers.ts
function getAPIProvider() {
  if (isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK))
    return "bedrock";
  if (isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX))
    return "vertex";
  if (isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY))
    return "foundry";
  if (process.env.PROVIDER || isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI))
    return "openai";
  const knownKeyEnvVars = [
    "OPENAI_API_KEY",
    "GOOGLE_API_KEY",
    "GEMINI_API_KEY",
    "DEEPSEEK_API_KEY",
    "QWEN_API_KEY",
    "DASHSCOPE_API_KEY",
    "ZHIPU_API_KEY",
    "GLM_API_KEY",
    "MOONSHOT_API_KEY",
    "KIMI_API_KEY",
    "DOUBAO_API_KEY",
    "ARK_API_KEY",
    "VOLC_API_KEY",
    "BAIDU_API_KEY",
    "QIANFAN_API_KEY",
    "YI_API_KEY",
    "LINGYIWANWU_API_KEY",
    "STEPFUN_API_KEY",
    "STEP_API_KEY",
    "BAICHUAN_API_KEY",
    "MINIMAX_API_KEY",
    "SPARK_API_KEY",
    "XFYUN_API_KEY",
    "HUNYUAN_API_KEY",
    "TENCENT_API_KEY",
    "MISTRAL_API_KEY",
    "GROQ_API_KEY",
    "XAI_API_KEY",
    "GROK_API_KEY",
    "TOGETHER_API_KEY",
    "COHERE_API_KEY",
    "CO_API_KEY",
    "PERPLEXITY_API_KEY",
    "PPLX_API_KEY",
    "SILICONFLOW_API_KEY",
    "SF_API_KEY",
    "OPENROUTER_API_KEY",
    "OR_API_KEY"
  ];
  for (const key of knownKeyEnvVars) {
    if (process.env[key])
      return "openai";
  }
  if (process.env.ANTHROPIC_API_KEY)
    return "firstParty";
  return "openai";
}
function isOpenAIProvider() {
  return getAPIProvider() === "openai";
}
function getAPIProviderForStatsig() {
  return getAPIProvider();
}
function isFirstPartyAnthropicBaseUrl() {
  const baseUrl = process.env.ANTHROPIC_BASE_URL;
  if (!baseUrl) {
    return true;
  }
  try {
    const host = new URL(baseUrl).host;
    const allowedHosts = ["api.anthropic.com"];
    if (process.env.USER_TYPE === "ant") {
      allowedHosts.push("api-staging.anthropic.com");
    }
    return allowedHosts.includes(host);
  } catch {
    return false;
  }
}
var init_providers = __esm(() => {
  init_envUtils();
});

export { getAPIProvider, isOpenAIProvider, getAPIProviderForStatsig, isFirstPartyAnthropicBaseUrl, init_providers };
