// src/openai-chat-compat.ts
function normalizedModel(model) {
  return model.trim().toLowerCase();
}
function matchesModelFamily(normalized, familyPattern) {
  return familyPattern.test(normalized);
}
function shouldAssumeOpenAiChatCompletions(baseUrl) {
  if (!baseUrl) return true;
  try {
    return new URL(baseUrl).hostname.toLowerCase() === "api.openai.com";
  } catch {
    return false;
  }
}
function usesMaxCompletionTokens(model, options) {
  const normalized = normalizedModel(model);
  if (options?.assumeOpenAI !== true) return false;
  if (matchesModelFamily(normalized, /^gpt-5(?:$|[-.])/)) return true;
  if (matchesModelFamily(normalized, /^gpt-4o(?:$|[-.])/)) return true;
  if (matchesModelFamily(normalized, /^gpt-4\.1(?:$|[-.])/)) return true;
  if (matchesModelFamily(normalized, /^o1(?:$|[-.])/)) return true;
  if (matchesModelFamily(normalized, /^o3(?:$|[-.])/)) return true;
  return matchesModelFamily(normalized, /^o4-mini(?:$|[-.])/);
}
function buildChatCompletionTokenLimit(model, maxTokens, options) {
  const safeMaxTokens = Math.max(0, Math.floor(maxTokens));
  if (usesMaxCompletionTokens(model, options)) {
    return { max_completion_tokens: safeMaxTokens };
  }
  return { max_tokens: safeMaxTokens };
}

export {
  shouldAssumeOpenAiChatCompletions,
  usesMaxCompletionTokens,
  buildChatCompletionTokenLimit
};
//# sourceMappingURL=chunk-Y27UJK6V.js.map