MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / applyAuthConfig

Function applyAuthConfig

ai/ai.ts:1723–1745  ·  view source on GitHub ↗
(
  authMode: AuthMode,
  config: ProviderConfig,
  url: string,
  headers: Record<string, string>,
)

Source from the content-addressed store, hash-verified

1721
1722const applyAuthConfig = (
1723 authMode: AuthMode,
1724 config: ProviderConfig,
1725 url: string,
1726 headers: Record<string, string>,
1727): { url: string; headers: Record<string, string> } => {
1728 if (authMode === "query-key") {
1729 try {
1730 const u = new URL(url);
1731 if (!u.searchParams.has("key")) u.searchParams.set("key", config.key);
1732 return { url: u.toString(), headers };
1733 } catch {
1734 return { url, headers };
1735 }
1736 }
1737 return {
1738 url,
1739 headers: {
1740 ...headers,
1741 Authorization: `Bearer ${config.key}`,
1742 },
1743 };
1744};
1745
1746const normalizeOpenAIBaseUrl = (url: string): string => {
1747 try {
1748 const u = new URL(url);

Calls 1

setMethod · 0.45

Tested by

no test coverage detected