kobold_img2img
Modify an existing image using text prompts with stable diffusion integration. Adjust parameters like dimensions, steps, and denoising strength for precise transformations.
Instructions
Transform existing image using prompt
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiUrl | No | http://localhost:5001 | |
| cfg_scale | No | ||
| denoising_strength | No | ||
| height | No | ||
| init_images | Yes | ||
| negative_prompt | No | ||
| prompt | Yes | ||
| sampler_name | No | ||
| seed | No | ||
| steps | No | ||
| width | No |
Implementation Reference
- src/index.ts:346-357 (handler)Shared handler logic for all POST-based tools, including 'kobold_img2img'. Validates input against the tool's schema, then proxies the request to the KoboldAI API endpoint '/sdapi/v1/img2img'.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:88-91 (schema)Zod schema defining the input parameters for the 'kobold_img2img' tool, extending Txt2ImgSchema with required init_images array and optional denoising_strength.const Img2ImgSchema = Txt2ImgSchema.extend({ init_images: z.array(z.string()), denoising_strength: z.number().optional(), });
- src/index.ts:249-253 (registration)Registration of the 'kobold_img2img' tool in the list of available tools returned by ListToolsRequest.{ name: "kobold_img2img", description: "Transform existing image using prompt", inputSchema: zodToJsonSchema(Img2ImgSchema), },
- src/index.ts:341-341 (registration)Mapping of tool name 'kobold_img2img' to its API endpoint and schema in the postEndpoints dispatch table.kobold_img2img: { endpoint: '/sdapi/v1/img2img', schema: Img2ImgSchema },
- src/index.ts:146-162 (helper)Utility function used by all tool handlers to make HTTP requests to the KoboldAI backend API.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(); }