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/keyParameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
userId | string | Your unique user ID from PromptTK |
apiKey | string | Your API key from PromptTK |