Merge ca8bd38a99 into da71eaebd2
This commit is contained in:
commit
1830f0d113
@ -69,7 +69,9 @@ const pickAnthropicTokens = (store: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fetchAnthropicOAuthUsage = async (token: string) => {
|
const fetchAnthropicOAuthUsage = async (token: string) => {
|
||||||
const res = await fetch("https://api.anthropic.com/api/oauth/usage", {
|
const baseUrl = process.env.ANTHROPIC_BASE_URL?.trim() || "https://api.anthropic.com";
|
||||||
|
const url = `${baseUrl}/api/oauth/usage`;
|
||||||
|
const res = await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
|
|||||||
@ -246,6 +246,15 @@ export function normalizeProviders(params: {
|
|||||||
normalizedProvider = googleNormalized;
|
normalizedProvider = googleNormalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply ANTHROPIC_BASE_URL environment variable override
|
||||||
|
if (normalizedKey === "anthropic") {
|
||||||
|
const baseUrl = process.env.ANTHROPIC_BASE_URL?.trim();
|
||||||
|
if (baseUrl && normalizedProvider.baseUrl !== baseUrl) {
|
||||||
|
mutated = true;
|
||||||
|
normalizedProvider = { ...normalizedProvider, baseUrl };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next[key] = normalizedProvider;
|
next[key] = normalizedProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,6 +405,15 @@ export async function resolveImplicitProviders(params: {
|
|||||||
allowKeychainPrompt: false,
|
allowKeychainPrompt: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add Anthropic provider if ANTHROPIC_BASE_URL is set
|
||||||
|
const anthropicBaseUrl = process.env.ANTHROPIC_BASE_URL?.trim();
|
||||||
|
if (anthropicBaseUrl) {
|
||||||
|
providers.anthropic = {
|
||||||
|
baseUrl: anthropicBaseUrl,
|
||||||
|
models: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const minimaxKey =
|
const minimaxKey =
|
||||||
resolveEnvApiKeyVarName("minimax") ??
|
resolveEnvApiKeyVarName("minimax") ??
|
||||||
resolveApiKeyFromProfiles({ provider: "minimax", store: authStore });
|
resolveApiKeyFromProfiles({ provider: "minimax", store: authStore });
|
||||||
|
|||||||
@ -99,8 +99,10 @@ export async function fetchClaudeUsage(
|
|||||||
timeoutMs: number,
|
timeoutMs: number,
|
||||||
fetchFn: typeof fetch,
|
fetchFn: typeof fetch,
|
||||||
): Promise<ProviderUsageSnapshot> {
|
): Promise<ProviderUsageSnapshot> {
|
||||||
|
const baseUrl = process.env.ANTHROPIC_BASE_URL?.trim() || "https://api.anthropic.com";
|
||||||
|
const url = `${baseUrl}/api/oauth/usage`;
|
||||||
const res = await fetchJson(
|
const res = await fetchJson(
|
||||||
"https://api.anthropic.com/api/oauth/usage",
|
url,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user