Skip to main content
Glama
ilhankilic

YaparAI MCP Server

by ilhankilic

generate_image

Generate AI images from text prompts with smart model selection. Supports Flux, SDXL, and Imagen4 for diverse styles and quality needs.

Instructions

Generate an image using AI.

Supports 3 AI models: Flux, SDXL, Imagen 4. Smart routing automatically picks the best model for your prompt. Cost: ~6 credits per image.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesDescription of the image to generate (Turkish or English)
modelNoAI model to use — "auto" (smart routing), "flux" (best quality), "sdxl" (fast), "imagen4" (Google, photorealistic)auto
negative_promptNoThings to avoid in the image
widthNoImage width in pixels (64-2048, default 512)
heightNoImage height in pixels (64-2048, default 512)
styleNoStyle preset (realistic, anime, cinematic, artistic)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the generate_image tool. It takes a prompt, optional model (auto/flux/sdxl/imagen4), negative_prompt, width, height, and style, then creates a payload and calls YaparAIClient.generate() to start an image generation job, polls for the result, and returns the image URL.
    async def generate_image(
        prompt: str,
        model: Literal["auto", "flux", "sdxl", "imagen4"] = "auto",
        negative_prompt: str = "",
        width: int = 512,
        height: int = 512,
        style: Literal["realistic", "anime", "cinematic", "artistic"] | None = None,
    ) -> dict:
        """
        Generate an image using AI.
    
        Supports 3 AI models: Flux, SDXL, Imagen 4.
        Smart routing automatically picks the best model for your prompt.
        Cost: ~6 credits per image.
    
        Args:
            prompt: Description of the image to generate (Turkish or English)
            model: AI model to use — "auto" (smart routing), "flux" (best quality),
                   "sdxl" (fast), "imagen4" (Google, photorealistic)
            negative_prompt: Things to avoid in the image
            width: Image width in pixels (64-2048, default 512)
            height: Image height in pixels (64-2048, default 512)
            style: Style preset (realistic, anime, cinematic, artistic)
    
        Returns:
            Dict with job_id, status, result_url (image URL when done),
            credits_used, and balance_remaining.
        """
        client = YaparAIClient()
        payload: dict = {
            "type": "image",
            "prompt": prompt,
            "negative_prompt": negative_prompt,
            "width": width,
            "height": height,
            "style": style,
        }
        if model != "auto":
            payload["model"] = model
    
        job = await client.generate(payload)
        result = await client.wait_for_result(job["job_id"], timeout=60)
        return {
            "status": "success",
            "image_url": result.get("result_url"),
            "job_id": result.get("job_id"),
            "credits_used": job.get("credits_used"),
            "balance_remaining": job.get("balance_remaining"),
        }
  • Import of generate_image from the generate module into the server.
    from yaparai.tools.generate import (
        generate_image,
        generate_video,
        generate_music,
        generate_music_video,
    )
  • Registration of generate_image as an MCP tool via mcp.tool(generate_image).
    mcp.tool(generate_image)
  • The YaparAIClient.generate() method that actually sends the POST request to /v1/public/generate to start the generation job.
    async def generate(self, request: dict) -> dict:
        """Start a generation job."""
        return await self._request("POST", "/v1/public/generate", json=request)
  • The YaparAIClient.wait_for_result() method that polls the job status until completion or timeout.
    async def wait_for_result(
        self,
        job_id: str,
        timeout: int = 120,
        poll_interval: int = 3,
    ) -> dict:
        """Poll job status until completed or timeout."""
        elapsed = 0
        while elapsed < timeout:
            job = await self.get_job(job_id)
            status = job.get("status", "")
            if status == "succeeded":
                return job
            if status == "failed":
                error = job.get("error_message") or job.get("error") or "Unknown error"
                raise RuntimeError(f"Generation failed: {error}")
            await asyncio.sleep(poll_interval)
            elapsed += poll_interval
        raise TimeoutError(
            f"Job {job_id} is still processing after {timeout}s. "
            f"Use get_job_status('{job_id}') to check later."
        )
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description partially covers behavior: cost (~6 credits) and model routing. Missing details like output format (likely image URL), processing time, or error handling for invalid prompts.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise: three short sentences cover purpose, models, routing, and cost. No redundancy, front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the existence of an output schema (handling return details), the description provides adequate context for invocation: required prompt, optional parameters explained in schema, and cost. Missing usage nuance but sufficient for a straightforward tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. Description adds value by explaining smart routing for model='auto' and stating the credit cost, which is absent from the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states 'Generate an image using AI' - a specific verb and resource. The description distinguishes from sibling tools like generate_text or generate_video by explicitly mentioning image generation and model options.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit when-to-use or when-not-to-use guidance. The mention of smart routing implies automated model selection but doesn't explain when to manually choose models or compare with alternatives like analyze_image or remove_background.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ilhankilic/yaparai-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server