diff --git a/src/lib/system.ts b/src/lib/system.ts index 085b41d7..cdd57844 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -192,7 +192,8 @@ Shakespeare supports AI-powered image generation. Users can configure an image m **Important Notes:** - Not all models support image generation. If users experience issues with image generation, they should try selecting a different image model in Settings > AI - The generate_image tool will only be available once a compatible image model is configured -- When generating images for projects, prefer "jpeg" or "webp" output formats with compression set between 70-90 for optimal file size. Use "png" format when transparency is needed (e.g., logos, icons, overlays). You must supply the output_format parameter when calling the generate_image tool. +- When generating images for projects, prefer "jpeg" or "webp" output formats with compression set between 70-90. You must supply these parameters when calling the generate_image tool to ensure optimal image quality and file size for web usage. +- **Transparency**: To generate images with transparent backgrounds (e.g., logos, icons, overlays), set \`background: "transparent"\` and use \`output_format: "png"\` or \`output_format: "webp"\`. Both parameters must be set together — \`output_format\` alone does not enable transparency. - **Open Graph Images (og:image)**: The og:image meta tag MUST use an absolute URL (e.g., \`https://example.com/og-image.jpg\`). Relative paths will not work for social media sharing. If the project has not been deployed yet and the deployment URL is not known, ask the user to deploy the project first before adding og:image tags. ## Working Around CORS Issues diff --git a/src/lib/tools/GenerateImageTool.ts b/src/lib/tools/GenerateImageTool.ts index 1f7902bd..f811923c 100644 --- a/src/lib/tools/GenerateImageTool.ts +++ b/src/lib/tools/GenerateImageTool.ts @@ -11,6 +11,7 @@ interface GenerateImageParams { output_format?: "png" | "jpeg" | "webp"; output_compression?: number; size?: "auto" | "1024x1024" | "1536x1024" | "1024x1536" | "256x256" | "512x512" | "1792x1024" | "1024x1792"; + background?: "transparent" | "opaque" | "auto"; } export type ImageGenerationMode = 'chat' | 'image'; @@ -23,6 +24,7 @@ export class GenerateImageTool implements Tool { output_format: z.enum(["png", "jpeg", "webp"]).optional().describe('Output format for the image (e.g., "png", "jpeg", "webp"). Support varies by model - leave blank if unsure'), output_compression: z.number().min(1).max(100).optional().describe('Compression quality for the image (0 to 100). Only applicable for "jpeg" and "webp" formats'), size: z.enum(["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"]).optional().describe('Size of the generated image (e.g., "1024x1024", "1536x1024"). Support varies by model - leave blank if unsure'), + background: z.enum(["transparent", "opaque", "auto"]).optional().describe('Background setting for the generated image. Use "transparent" for images that need transparency (e.g., logos, icons, overlays). Only supported with "png" or "webp" output formats'), }); constructor( @@ -36,7 +38,7 @@ export class GenerateImageTool implements Tool { ) {} async execute(args: GenerateImageParams): Promise { - const { prompt, output_format, output_compression, size } = args; + const { prompt, output_format, output_compression, size, background } = args; try { const client = createAIClient(this.provider, this.user, this.corsProxy); @@ -114,6 +116,7 @@ export class GenerateImageTool implements Tool { output_format, output_compression, size, + background, }); // Extract cost from response