venice_create_api_key
Generate API keys for Venice AI to enable access to open-source models, image generation, text-to-speech, and embeddings with configurable permissions and consumption limits.
Instructions
Create a new API key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes | Description for the new API key | |
| apiKeyType | No | API key type (ADMIN or INFERENCE) | INFERENCE |
| consumptionLimit | No | Optional consumption limits | |
| expiresAt | No | Optional expiration date (ISO 8601 format) |
Implementation Reference
- src/tools/admin/index.ts:40-52 (handler)The main execution logic of the tool: constructs request body from parameters and uses veniceAPI to POST to /api_keys, handles response and returns formatted text content.async ({ description, apiKeyType, consumptionLimit, expiresAt }) => { const body: Record<string, unknown> = { description, apiKeyType }; if (consumptionLimit) body.consumptionLimit = consumptionLimit; if (expiresAt) body.expiresAt = expiresAt; const response = await veniceAPI("/api_keys", { method: "POST", body: JSON.stringify(body) }); const data = await response.json() as CreateAPIKeyResponse; if (!response.ok) return { content: [{ type: "text" as const, text: `Error: ${data.error?.message || response.statusText}` }] }; const keyData = data.data; const secret = keyData?.apiKey || keyData?.key || "N/A"; return { content: [{ type: "text" as const, text: `Created API key "${keyData?.description}"\nID: ${keyData?.id}\nSecret: ${secret}\n\n⚠️ Save this secret - it won't be shown again!` }] }; }
- src/tools/admin/index.ts:30-39 (schema)Zod schema for input parameters to the tool.{ description: z.string().describe("Description for the new API key"), apiKeyType: z.enum(["ADMIN", "INFERENCE"]).optional().default("INFERENCE").describe("API key type (ADMIN or INFERENCE)"), consumptionLimit: z.object({ usd: z.number().optional(), diem: z.number().optional(), vcu: z.number().optional() }).optional().describe("Optional consumption limits"), expiresAt: z.string().optional().describe("Optional expiration date (ISO 8601 format)") },
- src/tools/admin/index.ts:27-53 (registration)Direct registration of the venice_create_api_key tool using McpServer.tool().server.tool( "venice_create_api_key", "Create a new API key", { description: z.string().describe("Description for the new API key"), apiKeyType: z.enum(["ADMIN", "INFERENCE"]).optional().default("INFERENCE").describe("API key type (ADMIN or INFERENCE)"), consumptionLimit: z.object({ usd: z.number().optional(), diem: z.number().optional(), vcu: z.number().optional() }).optional().describe("Optional consumption limits"), expiresAt: z.string().optional().describe("Optional expiration date (ISO 8601 format)") }, async ({ description, apiKeyType, consumptionLimit, expiresAt }) => { const body: Record<string, unknown> = { description, apiKeyType }; if (consumptionLimit) body.consumptionLimit = consumptionLimit; if (expiresAt) body.expiresAt = expiresAt; const response = await veniceAPI("/api_keys", { method: "POST", body: JSON.stringify(body) }); const data = await response.json() as CreateAPIKeyResponse; if (!response.ok) return { content: [{ type: "text" as const, text: `Error: ${data.error?.message || response.statusText}` }] }; const keyData = data.data; const secret = keyData?.apiKey || keyData?.key || "N/A"; return { content: [{ type: "text" as const, text: `Created API key "${keyData?.description}"\nID: ${keyData?.id}\nSecret: ${secret}\n\n⚠️ Save this secret - it won't be shown again!` }] }; } );
- src/client/venice-api.ts:9-17 (helper)Reusable helper function for making authenticated API requests to Venice AI, used in the tool handler.export async function veniceAPI(endpoint: string, options: RequestInit = {}): Promise<Response> { const url = `${BASE_URL}${endpoint}`; const headers: Record<string, string> = { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json", ...(options.headers as Record<string, string> || {}), }; return fetch(url, { ...options, headers }); }
- src/types/api-types.ts:75-84 (schema)TypeScript interface for the API response, used to type the response data in the handler.export interface CreateAPIKeyResponse extends VeniceAPIError { data?: { id?: string; apiKey?: string; key?: string; name?: string; description?: string; }; success?: boolean; }