Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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" }] }; }
  • Input schema for the 'validate_key' tool, defining an empty object with no required properties.
    inputSchema: { type: "object", properties: {}, required: [] },
  • 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; } }
  • TypeScript interface defining the arguments for the 'validate_key' tool (empty object).
    export interface ValidateKeyArgs {}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Garoth/dalle-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server