Skip to main content
Glama

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
NameRequiredDescriptionDefault
descriptionYesDescription for the new API key
apiKeyTypeNoAPI key type (ADMIN or INFERENCE)INFERENCE
consumptionLimitNoOptional consumption limits
expiresAtNoOptional expiration date (ISO 8601 format)

Implementation Reference

  • 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!` }] }; }
  • 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)") },
  • 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!` }] }; } );
  • 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 }); }
  • 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; }

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/georgeglarson/venice-mcp'

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