feat(anthropic): support longcat as Bearer-auth Anthropic-compatible provider
LongCat (Meituan) ships an Anthropic-compatible endpoint at https://api.longcat.chat/anthropic that authenticates via `Authorization: Bearer $KEY` instead of Anthropic's native `x-api-key` header. Without this change, pi sends x-api-key and LongCat replies with 401 invalid_api_key / missing_api_key. Same topology as the existing alibaba-coding-plan / minimax / minimax-cn entries (#3783). - Add "longcat" to usesAnthropicBearerAuth() so createClient routes the key through authToken. - Add "longcat": "LONGCAT_API_KEY" to env-api-keys.ts envMap so getEnvApiKey() can resolve it when options.apiKey is absent. - Add "longcat" to KnownProvider so the === literal check type-checks. - Extend anthropic-auth.test.ts to assert usesAnthropicBearerAuth returns true for longcat.
This commit is contained in:
parent
cb8ac79ce6
commit
1fc62582ed
4 changed files with 10 additions and 2 deletions
|
|
@ -141,6 +141,7 @@ export function getEnvApiKey(provider: any): string | undefined {
|
|||
ollama: "OLLAMA_API_KEY",
|
||||
"ollama-cloud": "OLLAMA_API_KEY",
|
||||
"custom-openai": "CUSTOM_OPENAI_API_KEY",
|
||||
longcat: "LONGCAT_API_KEY",
|
||||
};
|
||||
|
||||
const envVar = envMap[provider];
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ test("usesAnthropicBearerAuth covers Bearer-only Anthropic-compatible providers
|
|||
assert.equal(usesAnthropicBearerAuth("alibaba-coding-plan"), true);
|
||||
assert.equal(usesAnthropicBearerAuth("minimax"), true);
|
||||
assert.equal(usesAnthropicBearerAuth("minimax-cn"), true);
|
||||
assert.equal(usesAnthropicBearerAuth("longcat"), true);
|
||||
assert.equal(usesAnthropicBearerAuth("anthropic"), false);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,12 @@ function mergeHeaders(...headerSources: (Record<string, string> | undefined)[]):
|
|||
}
|
||||
|
||||
export function usesAnthropicBearerAuth(provider: Model<"anthropic-messages">["provider"]): boolean {
|
||||
return provider === "alibaba-coding-plan" || provider === "minimax" || provider === "minimax-cn";
|
||||
return (
|
||||
provider === "alibaba-coding-plan" ||
|
||||
provider === "minimax" ||
|
||||
provider === "minimax-cn" ||
|
||||
provider === "longcat"
|
||||
);
|
||||
}
|
||||
|
||||
async function createClient(
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ export type KnownProvider =
|
|||
| "alibaba-coding-plan"
|
||||
| "alibaba-dashscope"
|
||||
| "ollama"
|
||||
| "ollama-cloud";
|
||||
| "ollama-cloud"
|
||||
| "longcat";
|
||||
export type Provider = KnownProvider | string;
|
||||
|
||||
export type ThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue