Skip to content

Context7 Platform -- Up-to-date docs for AI agents

fix(api): enhance unauthorized error message to include API key details

enesgules63d2da0d9a02
diff --git a/src/lib/api.ts b/src/lib/api.ts
index f147e0d8..9354dfad 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -120,7 +120,10 @@ export async function fetchLibraryDocumentation(
return errorMessage;
}
if (errorCode === 401) {
- const errorMessage = "Unauthorized. Please check your API key.";
+ const errorMessage =
+ "Unauthorized. Please check your API key. The API key you provided (possibly incorrect) is: " +
+ apiKey +
+ ". API keys should start with 'ctx7sk'";
console.error(errorMessage);
return errorMessage;
}