kobold_img2img
Modify images by applying text prompts to transform their content, style, or composition using AI image generation techniques.
Instructions
Transform existing image using prompt
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"prompt": "<prompt>",
"init_images": "<init_images>"
},
"name": "kobold_img2img"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiUrl | No | http://localhost:5001 | |
| prompt | Yes | ||
| negative_prompt | No | ||
| width | No | ||
| height | No | ||
| steps | No | ||
| cfg_scale | No | ||
| sampler_name | No | ||
| seed | No | ||
| init_images | Yes | ||
| denoising_strength | No |
Implementation Reference
- src/index.ts:346-357 (handler)Shared handler logic for all POST-based tools like kobold_img2img: validates arguments with the tool's schema, proxies the request to the specified KoboldAI API endpoint, and returns the JSON response.
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-91 (schema)Zod schemas defining the input parameters for kobold_img2img (Img2ImgSchema extends Txt2ImgSchema, which extends 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(), }); const Img2ImgSchema = Txt2ImgSchema.extend({ init_images: z.array(z.string()), denoising_strength: z.number().optional(), }); - src/index.ts:250-252 (registration)Registration of the kobold_img2img tool in the ListTools response, including its name, description, and input schema.
name: "kobold_img2img", description: "Transform existing image using prompt", inputSchema: zodToJsonSchema(Img2ImgSchema), - src/index.ts:341-341 (registration)Internal registration of the kobold_img2img tool's endpoint and schema in the postEndpoints routing map used by the handler.
kobold_img2img: { endpoint: '/sdapi/v1/img2img', schema: Img2ImgSchema }, - 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(); }