kobold_txt2img
Convert text prompts into images with customizable dimensions, sampling methods, and precision settings for creative or practical visual generation.
Instructions
Generate image from text prompt
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiUrl | No | http://localhost:5001 | |
| cfg_scale | No | ||
| height | No | ||
| negative_prompt | No | ||
| prompt | Yes | ||
| sampler_name | No | ||
| seed | No | ||
| steps | No | ||
| width | No |
Implementation Reference
- src/index.ts:346-358 (handler)Generic POST handler logic that dispatches kobold_txt2img to the KoboldAI Stable Diffusion txt2img endpoint via makeRequest after schema validation.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:77-86 (schema)Zod input schema definition for the kobold_txt2img tool, extending BaseConfigSchema.const Txt2ImgSchema = BaseConfigSchema.extend({ prompt: z.string(), negative_prompt: z.string().optional(), width: z.number().optional(), height: z.number().optional(), steps: z.number().optional(), cfg_scale: z.number().optional(), sampler_name: z.string().optional(), seed: z.number().optional(), });
- src/index.ts:244-248 (registration)Registration of the kobold_txt2img tool in the ListTools response.{ name: "kobold_txt2img", description: "Generate image from text prompt", inputSchema: zodToJsonSchema(Txt2ImgSchema), },
- src/index.ts:340-340 (handler)Endpoint mapping and schema reference for kobold_txt2img in the POST endpoints dispatch table.kobold_txt2img: { endpoint: '/sdapi/v1/txt2img', schema: Txt2ImgSchema },
- src/index.ts:146-162 (helper)Helper function for making HTTP requests to the KoboldAI API, used by the tool handler.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(); }