kobold_complete
Generate text completions using OpenAI-compatible API endpoints. Input a prompt, adjust parameters like max_tokens and temperature, and receive AI-generated responses for diverse applications.
Instructions
Text completion (OpenAI-compatible)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiUrl | No | http://localhost:5001 | |
| max_tokens | No | ||
| prompt | Yes | ||
| stop | No | ||
| temperature | No | ||
| top_p | No |
Implementation Reference
- src/index.ts:346-358 (handler)Generic handler logic for all POST endpoint tools, including "kobold_complete". It validates the input arguments using the tool's schema, makes a POST request to the KoboldAI API endpoint, and returns the response as text content.if (postEndpoints[name]) { const { endpoint, schema } = postEndpoints[name]; const parsed = schema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments: ${parsed.error}`); } const result = await makeRequest(`${apiUrl}${endpoint}`, 'POST', requestData); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError: false, }; }
- src/index.ts:113-119 (schema)Zod schema defining the input parameters for the "kobold_complete" tool, extending BaseConfigSchema with OpenAI-compatible completion parameters.const CompletionSchema = BaseConfigSchema.extend({ prompt: z.string(), max_tokens: z.number().optional(), temperature: z.number().optional(), top_p: z.number().optional(), stop: z.array(z.string()).optional(), });
- src/index.ts:265-269 (registration)Registers the "kobold_complete" tool in the ListTools response, providing its name, description, and input schema.{ name: "kobold_complete", description: "Text completion (OpenAI-compatible)", inputSchema: zodToJsonSchema(CompletionSchema), },
- src/index.ts:146-162 (helper)Helper function used by the tool handlers to perform HTTP requests to the KoboldAI API server.async function makeRequest(url: string, method = 'GET', body: Record<string, unknown> | null = null) { const options: RequestInit = { method, headers: body ? { 'Content-Type': 'application/json' } : undefined, }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { throw new Error(`KoboldAI API error: ${response.statusText}`); } return response.json(); }
- src/index.ts:343-344 (helper)Dispatch mapping for "kobold_complete" tool to its API endpoint '/v1/completions' and validation schema.kobold_complete: { endpoint: '/v1/completions', schema: CompletionSchema }, };