Skip to content

Validate API Key

Once you’ve obtained your API key from the PromptTK website, you can validate it using the validateApiKey function. This function checks if the provided API key is valid and active.

import { PromptTK } from "@devvle/ptk-api-sdk";
const promptTK = new PromptTK({
userId: "your-user-id",
apiKey: "your-api-key",
});
async function validateApiKey() {
try {
const isValid = await promptTK.validateApiKey();
console.log("API Key is valid:", isValid);
} catch (error) {
console.error("Error validating API key:", error);
}
}
validateApiKey();

The validateApiKey function makes a request to the following endpoint:

POST /dev/validate/key
ParameterTypeDescription
userIdstringYour unique user ID from PromptTK
apiKeystringYour API key from PromptTK