(error: unknown)
| 143 | } |
| 144 | |
| 145 | export function isApiKeyError(error: unknown): boolean { |
| 146 | if (error instanceof ApiKeyMissingError) { |
| 147 | return true; |
| 148 | } |
| 149 | |
| 150 | if (error instanceof Error) { |
| 151 | const message = error.message.toLowerCase(); |
| 152 | |
| 153 | // Common API key error patterns |
| 154 | if ( |
| 155 | message.includes('api key') || |
| 156 | message.includes('apikey') || |
| 157 | message.includes('authentication') || |
| 158 | message.includes('unauthorized') || |
| 159 | message.includes('invalid_api_key') || |
| 160 | message.includes('incorrect api key') |
| 161 | ) { |
| 162 | return true; |
| 163 | } |
| 164 | |
| 165 | // Check for 401 status |
| 166 | if ('response' in (error as any)) { |
| 167 | const response = (error as any).response; |
| 168 | if (response?.status === 401) { |
| 169 | return true; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | return false; |
| 175 | } |
| 176 | |
| 177 | export function getSuggestedModels( |
| 178 | provider: string, |
no test coverage detected
searching dependent graphs…