generate_api_key
Generate a new admin API key to authenticate and secure API access to your AnythingLLM platform.
Instructions
Generate a new API key (admin)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:67-67 (registration)The tool 'system_generate_api_key' is registered with the ListToolsRequestSchema handler, providing its name and description. The actual tool name used internally is 'system_generate_api_key'.
{ name: "system_generate_api_key", description: "Generate API key", inputSchema: { type: "object", properties: {}, required: [] } }, - src/index.ts:23-55 (helper)The apiRequest helper function makes HTTP requests to the AnythingLLM backend. It handles constructing the URL, adding auth headers, and parsing JSON responses.
function apiRequest(path: string, method = "GET", body?: any, extraHeaders = {}): Promise<any> { return new Promise((resolve, reject) => { const baseUrl = new URL(ANYTHING_LLM_BASE); const fullUrl = new URL(path, baseUrl); const options: any = { hostname: fullUrl.hostname, port: fullUrl.port || (fullUrl.protocol === "https:" ? 443 : 80), path: fullUrl.pathname + fullUrl.search, method, headers: Object.assign({ "Authorization": "Bearer " + ANYTHING_LLM_API_KEY, "Content-Type": "application/json", "Accept": "application/json", }, extraHeaders), }; const lib = fullUrl.protocol === "https:" ? https : http; const req = lib.request(options, (res: any) => { let data = ""; res.on("data", (chunk: string) => { data += chunk; }); res.on("end", () => { try { resolve(data ? JSON.parse(data) : {}); } catch { resolve({ raw: data }); } }); }); req.on("error", reject); if (body) req.write(JSON.stringify(body)); req.end(); }); } - src/index.ts:90-90 (handler)The tool handler for 'system_generate_api_key' calls apiRequest('/system/generate-api-key', 'POST'), making a POST request to /api/v1/system/generate-api-key on the AnythingLLM backend. No additional input arguments are required.
else if (name === "system_generate_api_key") { result = await apiRequest("/system/generate-api-key", "POST"); }