( apiKey: string | null | undefined, )
| 4 | * @returns true if the API key is valid, false otherwise |
| 5 | */ |
| 6 | export function isValidAnthropicApiKey( |
| 7 | apiKey: string | null | undefined, |
| 8 | ): boolean { |
| 9 | if (!apiKey || typeof apiKey !== "string") { |
| 10 | return false; |
| 11 | } |
| 12 | |
| 13 | // Anthropic API keys must start with "sk-ant-" and have additional characters |
| 14 | return apiKey.startsWith("sk-ant-") && apiKey.length > "sk-ant-".length; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Gets a user-friendly error message for invalid API keys |
no outgoing calls
no test coverage detected