मुख्य सामग्री पर जाएं
DALL-E के साथ इमेज जनरेट करें, वेरिएशन बनाएँ, एडिट लागू करें, और विज़न models के साथ इमेज का विश्लेषण करें — यह सब एक ही unified Client के ज़रिए।
इमेज जनरेशन के लिए सर्वोत्तम क्वालिटी पाने के लिए openai/dall-e-3 का उपयोग करें। विज़न टास्क के लिए, openai/gpt-5.2 उत्कृष्ट परफॉर्मेंस प्रदान करता है।

प्रोग्रेसिव उदाहरण: अपनी workflow में images जोड़ें

यदि आपने पहले से टेक्स्ट‑आधारित एजेंट बना लिया है (Chat → Tools → MCP → Streaming), तो आमतौर पर अगली क्षमता के रूप में आप images जोड़ते हैं:
  1. किसी prompt से एक image generate करें
  2. मौजूदा image को edit / vary करें
  3. किसी vision model के साथ किसी image को analyze करें
नीचे दिए गए सेक्शन सबसे सरल call (generation) से शुरू होते हैं, और फिर उस पर editing और vision को क्रमिक रूप से जोड़ते हैं।

इमेज जेनरेशन

DALL-E models का उपयोग करके text prompt से images जेनरेट करें।
import asyncio
from dedalus_labs import AsyncDedalus
from dotenv import load_dotenv

load_dotenv()

async def generate_image():
    """टेक्स्ट से इमेज जेनरेट करें."""
    client = AsyncDedalus()
    response = await client.images.generate(
        prompt="Dedalus flying through clouds",
        model="openai/dall-e-3",
    )
    print(response.data[0].url)

if __name__ == "__main__":
    asyncio.run(generate_image())

इमेज संपादन

स्रोत इमेज, मास्क, और इच्छित बदलावों का वर्णन करने वाला prompt देकर मौजूदा इमेज को संपादित करें।
import asyncio
import httpx
from dedalus_labs import AsyncDedalus
from dotenv import load_dotenv

load_dotenv()

async def edit_image():
    """Edit image (using generated image as both source and mask)."""

    client = AsyncDedalus()

    # एक टेस्ट इमेज बनाएँ (DALL·E आउटपुट मान्य RGBA PNG है)
    gen_response = await client.images.generate(
        prompt="A white cat on a cushion",
        model="openai/dall-e-2",
        size="512x512",
    )

    # जनरेट की गई इमेज डाउनलोड करें
    async with httpx.AsyncClient() as http:
        img_data = await http.get(gen_response.data[0].url)
        img_bytes = img_data.content

    # उसी इमेज को स्रोत और मास्क दोनों के रूप में उपयोग करें (सिर्फ़ यह जाँचने के लिए कि endpoint काम कर रहा है)
    response = await client.images.edit(
        image=img_bytes,
        mask=img_bytes,
        prompt="A white cat with sunglasses",
        model="openai/dall-e-2",
    )
    print(response.data[0].url)

if __name__ == "__main__":
    asyncio.run(edit_image())

Image Variations

किसी मौजूदा इमेज के वैरिएशन बनाएँ।
import asyncio
from pathlib import Path
from dedalus_labs import AsyncDedalus
from dotenv import load_dotenv

load_dotenv()

async def create_variations():
    """Create image variations."""
    client = AsyncDedalus()

    image_path = Path("image.png")
    if not image_path.exists():
        print("Skipped: image.png not found")
        return

    response = await client.images.create_variation(
        image=image_path.read_bytes(),
        model="openai/dall-e-2",
        n=2,
    )
    for img in response.data:
        print(img.url)

if __name__ == "__main__":
    asyncio.run(create_variations())

Vision: URL से इमेज का विश्लेषण करें

URL पर होस्ट की गई इमेज का विश्लेषण और विवरण करने के लिए विज़न मॉडल्स का उपयोग करें।
import asyncio
from dedalus_labs import AsyncDedalus
from dotenv import load_dotenv

load_dotenv()

async def vision_url():
    """Analyze image from URL."""
    client = AsyncDedalus()
    completion = await client.chat.completions.create(
        model="openai/gpt-5.2",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "What's in this image?"},
                    {
                        "type": "image_url",
                        "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"},
                    },
                ],
            }
        ],
    )
    print(completion.choices[0].message.content)

if __name__ == "__main__":
    asyncio.run(vision_url())

विज़न: Base64 के साथ लोकल इमेज का विश्लेषण

लोकल इमेज को base64 में एन्कोड करके उनका विश्लेषण करें।
import asyncio
import base64
from pathlib import Path
from dedalus_labs import AsyncDedalus
from dotenv import load_dotenv

load_dotenv()

async def vision_base64():
    """Analyze local image via base64."""
    client = AsyncDedalus()

    image_path = Path("image.png")
    if not image_path.exists():
        print("Skipped: image.png not found")
        return

    b64 = base64.b64encode(image_path.read_bytes()).decode()
    completion = await client.chat.completions.create(
        model="openai/gpt-5.2",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "Describe this image."},
                    {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}},
                ],
            }
        ],
    )
    print(completion.choices[0].message.content)

if __name__ == "__main__":
    asyncio.run(vision_base64())

उन्नत: DedalusRunner के साथ इमेज ऑर्केस्ट्रेशन

DedalusRunner का उपयोग करके जेनरेशन, एडिटिंग और विज़न क्षमताओं को संयोजित करके जटिल इमेज वर्कफ़्लो बनाएं।
Python
import asyncio
import httpx
from dedalus_labs import AsyncDedalus, DedalusRunner
from dotenv import load_dotenv

load_dotenv()

class ImageToolSuite:
    """Helper that exposes image endpoints as DedalusRunner tools."""

    def __init__(self, client: AsyncDedalus):
        self._client = client

    async def generate_concept_art(
        self,
        prompt: str,
        model: str = "openai/dall-e-3",
        size: str = "1024x1024",
    ) -> str:
        """Create concept art and return the hosted image URL."""
        response = await self._client.images.generate(
            prompt=prompt,
            model=model,
            size=size,
        )
        return response.data[0].url

    async def edit_concept_art(
        self,
        prompt: str,
        reference_url: str,
        mask_url: str | None = None,
        model: str = "openai/dall-e-2",
    ) -> str:
        """Apply edits to the referenced image URL and return a new URL."""

        if not reference_url:
            raise ValueError("reference_url must be provided when editing an image.")

        async with httpx.AsyncClient() as http:
            base_image = await http.get(reference_url)
            mask_bytes = await http.get(mask_url) if mask_url else None

        edit_kwargs = {
            "image": base_image.content,
            "prompt": prompt,
            "model": model,
        }
        if mask_bytes:
            edit_kwargs["mask"] = mask_bytes.content

        response = await self._client.images.edit(**edit_kwargs)
        return response.data[0].url

    async def describe_image(
        self,
        image_url: str,
        question: str = "Describe this image.",
        model: str = "openai/gpt-5.2",
    ) -> str:
        """Run a lightweight vision pass against an existing image URL."""
        completion = await self._client.chat.completions.create(
            model=model,
            messages=[
                {
                    "role": "user",
                    "content": [
                        {"type": "text", "text": question},
                        {"type": "image_url", "image_url": {"url": image_url}},
                    ],
                }
            ],
        )
        return completion.choices[0].message.content

async def runner_storyboard():
    """Demonstrate DedalusRunner + agent-as-tool pattern for image workflows."""

    client = AsyncDedalus()
    runner = DedalusRunner(client, verbose=True)
    image_tools = ImageToolSuite(client)

    instructions = (
        "आप एक क्रिएटिव डायरेक्टर हैं। कॉन्सेप्ट आर्ट उत्पन्न करने के लिए प्रदान किए गए टूल्स का उपयोग करें, "
        "वैकल्पिक रूप से इसे परिष्कृत करें, और फिर अंतिम रेंडर का वर्णन करें। मुख्य वार्तालाप को हमेशा "
        "टेक्स्ट मॉडल पर रखें और छवि कार्य के लिए टूल्स पर निर्भर रहें।"
    )

    result = await runner.run(
        instructions=instructions,
        input="Create a retro Dedalus mission patch, refine it with a neon palette, and describe it.",
        model="openai/gpt-5.2",
        tools=[
            image_tools.generate_concept_art,
            image_tools.edit_concept_art,
            image_tools.describe_image,
        ],
        max_steps=4,
        verbose=True,
        debug=False,
    )

    print("Runner final output:", result.final_output)
    print("Tools invoked:", result.tools_called)

if __name__ == "__main__":
    asyncio.run(runner_storyboard())

अगले चरण

  • एंड‑टू‑एंड एजेंट्स देखें: उपयोग के मामले — मल्टीमोडल पैटर्न
  • अपना MCP सर्वर डिप्लॉय करें: MCP quickstart — अपने एजेंट के लिए अपने टूल्स होस्ट करें
  • एक चैट सर्वर बनाएं: Cookbook: Chat server — प्रोडक्शन में अपने एजेंट को सर्व करें
इन डॉक्यूमेंट्स को प्रोग्रामैटिकली जोड़ें ताकि मॉडल कॉन्टेक्स्ट प्रोटोकॉल (MCP) के माध्यम से Claude, VSCode और अन्य से कनेक्ट करके रीयल‑टाइम उत्तर मिल सकें।