validate_key
Check if your OpenAI API key is valid and ready for use with DALL-E image generation tools.
Instructions
Validate the OpenAI API key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/index.ts:289-297 (handler)The handler function for the 'validate_key' tool. It calls dalleService.validateApiKey() and returns a text response indicating if the API key is valid.handler: async (_args: ValidateKeyArgs): Promise<ToolResponse> => { const isValid = await dalleService.validateApiKey(); return { content: [{ type: "text", text: isValid ? "API key is valid" : "API key is invalid" }] }; }
- src/tools/index.ts:284-288 (schema)Input schema for the 'validate_key' tool, defining an empty object with no required properties.inputSchema: { type: "object", properties: {}, required: [] },
- src/tools/index.ts:281-298 (registration)Registration of the 'validate_key' tool in the exported tools array.{ name: "validate_key", description: "Validate the OpenAI API key", inputSchema: { type: "object", properties: {}, required: [] }, handler: async (_args: ValidateKeyArgs): Promise<ToolResponse> => { const isValid = await dalleService.validateApiKey(); return { content: [{ type: "text", text: isValid ? "API key is valid" : "API key is invalid" }] }; } }
- Supporting utility method in DalleService that performs the actual API key validation by querying the OpenAI /models endpoint.async validateApiKey(): Promise<boolean> { try { // Make a minimal request to check if the API key is valid await axios.get(`${this.baseUrl}/models`, { headers: { 'Authorization': `Bearer ${this.config.apiKey}` } }); return true; } catch (error) { console.log("API Key Validation Error:", error); return false; } }
- src/types/index.ts:42-42 (schema)TypeScript interface defining the arguments for the 'validate_key' tool (empty object).export interface ValidateKeyArgs {}