9993c96907
Move provider auth and OAuth flows onto pi-ai Models, compose models.json and extension overlays through ModelRuntime, and retain ModelRegistry as an extension compatibility facade.
21 lines
839 B
TypeScript
21 lines
839 B
TypeScript
import { anthropicMessagesApi } from "../api/anthropic-messages.lazy.ts";
|
|
import { envApiKeyAuth, lazyOAuth } from "../auth/helpers.ts";
|
|
import { loadAnthropicOAuth } from "../auth/oauth/load.ts";
|
|
import { createProvider, type Provider } from "../models.ts";
|
|
import { ANTHROPIC_MODELS } from "./anthropic.models.ts";
|
|
|
|
export function anthropicProvider(): Provider<"anthropic-messages"> {
|
|
return createProvider({
|
|
id: "anthropic",
|
|
name: "Anthropic",
|
|
baseUrl: "https://api.anthropic.com",
|
|
auth: {
|
|
// ANTHROPIC_OAUTH_TOKEN takes precedence over ANTHROPIC_API_KEY
|
|
apiKey: envApiKeyAuth("Anthropic API key", ["ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"]),
|
|
oauth: lazyOAuth({ name: "Anthropic (Claude Pro/Max)", load: loadAnthropicOAuth }),
|
|
},
|
|
models: Object.values(ANTHROPIC_MODELS),
|
|
api: anthropicMessagesApi(),
|
|
});
|
|
}
|