UNPKG

ai-ping

Version:

ping AI provider to check if a api key is valid

22 lines (20 loc) 749 B
type Platform = 'openai' | 'anthropic' | 'google' | 'unknown'; /** * Predict the platform based on the API key prefix * * This function will check the prefix of the API key and return the corresponding platform. * * @param apiKey */ declare function predict(apiKey: string): Platform; /** * Ping the API to check if the key is valid * * This function will make a request to the API and check if the response is 401 (Unauthorized). * * @param apiKey - The API key to validate * @param platform - The platform to validate against. If not provided, it will be predicted from the API key. */ declare function ping(apiKey: string, platform?: Omit<Platform, 'unknown'>): Promise<boolean>; export { ping, predict }; export type { Platform };