Skip to main content

Overview

SeeDream 4.0 (seedream-4-0-250828) is a high-quality image generation model from BytePlus Volcano Engine international edition. APIYI has established an official strategic partnership to provide stable and reliable service.

📚 Latest Documentation

Feishu Complete Usage Guide - Fastest updates, supports comment interactionVisit Feishu documentation for latest tutorials, tips sharing, and Q&A. Documentation continuously updated, questions can be discussed directly in Feishu comments.

Core Advantages
  • 🎨 High-Quality Output: Supports 4K HD image generation with excellent visual consistency
  • 💰 Pricing Advantage: 0.025/image(official0.025/image (official 0.03/image, equivalent to 65% off)
  • 🚀 Generation Speed: Average 15 seconds per image, responsive
  • 🤝 Official Partnership: BytePlus Volcano Engine strategic cooperation, reliable and stable resources
  • 🔧 Standard Interface: Fully compatible with OpenAI Image API format

Calling Methods

Correct Endpoint ✅

POST /v1/images/generations
Important Note: SeeDream 4.0 uses the standard OpenAI image generation endpoint, fully compatible with OpenAI Image API format, billed per request, simple and transparent.

Python Example Code

Complete Python example code demonstrating how to use SeeDream 4.0 to generate images:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
SeeDream 4.0 Image Generation - Python Version
Supports standard OpenAI Image API format
"""

import requests
import json
import base64
import os
import datetime
from typing import Optional, Dict, Any

class SeeDreamImageGenerator:
    def __init__(self, api_key: str, api_url: str = "https://api.apiyi.com/v1/images/generations"):
        """
        Initialize SeeDream Image Generator

        Args:
            api_key: API key
            api_url: API address
        """
        self.api_key = api_key
        self.api_url = api_url
        self.headers = {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {api_key}"
        }

    def generate_image(self,
                      prompt: str,
                      model: str = "seedream-4-0-250828",
                      size: str = "2048x2048",
                      quality: str = "standard",
                      n: int = 1,
                      response_format: str = "url",
                      output_dir: str = ".") -> Dict[str, Any]:
        """
        Generate image

        Args:
            prompt: Image description prompt
            model: Model to use
            size: Image size
                  Method 1: Resolution spec ("1K", "2K", "4K") - let model decide final dimensions
                  Method 2: Exact pixels ("2048x2048", "1920x1080", etc.) - range [1280x720, 4096x4096]
            quality: Image quality (standard or hd)
            n: Generation count
            response_format: Response format (url or b64_json)
            output_dir: Output directory (used only when response_format is b64_json)

        Returns:
            API response result
        """
        print("🚀 Starting image generation...")
        print(f"Prompt: {prompt}")
        print(f"Model: {model}")
        print(f"Size: {size}")
        print(f"Quality: {quality}")

        try:
            # Prepare request data
            payload = {
                "model": model,
                "prompt": prompt,
                "size": size,
                "quality": quality,
                "n": n,
                "response_format": response_format
            }

            print("📡 Sending API request...")

            # Send request
            response = requests.post(
                self.api_url,
                headers=self.headers,
                json=payload,
                timeout=60
            )

            if response.status_code != 200:
                error_msg = f"API request failed, status code: {response.status_code}"
                try:
                    error_detail = response.json()
                    error_msg += f", error details: {error_detail}"
                except:
                    error_msg += f", response content: {response.text[:500]}"
                print(f"❌ {error_msg}")
                return {"error": error_msg}

            print("✅ API request successful")

            # Parse response
            result = response.json()

            # Process response data
            if response_format == "b64_json" and "data" in result:
                print("🔍 Saving base64 images...")
                for i, item in enumerate(result["data"]):
                    if "b64_json" in item:
                        self._save_base64_image(
                            item["b64_json"],
                            output_dir,
                            f"seedream_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}_{i}.png"
                        )
            elif response_format == "url" and "data" in result:
                print("🎨 Generated image URLs:")
                for item in result["data"]:
                    if "url" in item:
                        print(f"  🔗 {item['url']}")

            return result

        except requests.exceptions.Timeout:
            error_msg = "Request timeout (60 seconds)"
            print(f"❌ {error_msg}")
            return {"error": error_msg}
        except requests.exceptions.ConnectionError as e:
            error_msg = f"Connection error: {str(e)}"
            print(f"❌ {error_msg}")
            return {"error": error_msg}
        except Exception as e:
            error_msg = f"Unknown error: {str(e)}"
            print(f"❌ {error_msg}")
            return {"error": error_msg}

    def _save_base64_image(self, b64_data: str, output_dir: str, filename: str):
        """
        Save base64 image locally

        Args:
            b64_data: Base64 encoded image data
            output_dir: Output directory
            filename: Filename
        """
        try:
            # Decode base64 data
            image_data = base64.b64decode(b64_data)

            # Create output directory
            os.makedirs(output_dir, exist_ok=True)

            # Save file
            output_path = os.path.join(output_dir, filename)
            with open(output_path, 'wb') as f:
                f.write(image_data)

            print(f"🖼️  Image saved successfully: {output_path}")
            print(f"📊 File size: {len(image_data)} bytes")

        except Exception as e:
            print(f"❌ Failed to save image: {str(e)}")

def main():
    """
    Main function - demonstrates SeeDream 4.0 image generation
    """
    # Configuration parameters
    API_KEY = "sk-"  # Replace with your actual API key

    # Example prompts
    prompts = [
        "A serene Japanese garden with cherry blossoms in full bloom, koi pond, traditional bridge, 4K, ultra detailed",
        "Futuristic cityscape at night with neon lights and flying vehicles, cyberpunk style, high quality",
        "Cute cartoon cat astronaut floating in space with planets in background, pixar style"
    ]

    print("="*60)
    print("SeeDream 4.0 Image Generator - Python Version")
    print("="*60)
    print(f"Start time: {datetime.datetime.now()}")

    # Create generator instance
    generator = SeeDreamImageGenerator(API_KEY)

    # Generate example images
    for i, prompt in enumerate(prompts, 1):
        print(f"\n🎯 Example {i}/{len(prompts)}")
        print("-"*40)

        result = generator.generate_image(
            prompt=prompt,
            size="2K",          # Options: "1K", "2K", "4K" or exact size like "2048x2048"
            quality="hd",       # Options: standard, hd
            n=1,                # Generation count
            response_format="url"  # Options: url, b64_json
        )

        if "error" not in result:
            print(f"✅ Image {i} generated successfully!")
        else:
            print(f"❌ Image {i} generation failed")

        print("-"*40)

    print(f"\nEnd time: {datetime.datetime.now()}")
    print("="*60)

if __name__ == "__main__":
    main()

Usage Steps

  1. Replace API Key: Replace API_KEY in code with your actual API key
  2. Set Parameters:
    • prompt: Describe in detail the image you want to generate
    • size: Choose image size
      • Method 1: Use resolution spec (“1K”, “2K”, “4K”) - model automatically decides aspect ratio
      • Method 2: Specify exact pixels (e.g., “2048x2048”) - total pixel range [1280×720, 4096×4096], aspect ratio range [1/16, 16]
    • quality: Choose quality level (standard or hd)
    • response_format: Choose return format (url or b64_json)
  3. Run Script: Execute Python script to generate images

cURL Example

If you prefer using cURL command-line tool:
curl -X POST "https://api.apiyi.com/v1/images/generations" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "seedream-4-0-250828",
    "prompt": "A beautiful sunset over mountains with dramatic clouds",
    "size": "4K",
    "quality": "hd",
    "n": 1,
    "response_format": "url"
  }'

Price Comparison

ModelOfficial PriceAPIYI PriceDiscountFeatures
SeeDream 4.0$0.03/image$0.025/image65%⭐ 4K HD, excellent visual consistency
Nano Banana$0.04/image$0.025/image62.5%Google tech, 10-second fast
GPT-Image-1Higher--OpenAI tech
DALL·E 3Size-based billing--Classic model
Cost-effectiveness Recommendation: SeeDream 4.0 excels in HD image generation, particularly suitable for applications requiring high quality and strong visual consistency. Combined with 15% top-up bonus, actual cost is about ¥0.14/image.

Feature Comparison

Quality Characteristics

  • 4K HD Output: Supports high-resolution image generation
  • Visual Consistency: Generated images have unified style with rich details
  • Response Speed: 15 seconds on average, moderate speed

API Features

  • ✅ Standard OpenAI Image API format
  • ✅ Supports multiple image sizes
  • ✅ Supports both URL and Base64 return formats
  • ✅ Per-request billing, transparent and simple
  • ✅ Batch generation support (n parameter)

Supported Sizes

SeeDream 4.0 supports two size setting methods:

Method 1: Resolution Specs

Use resolution specs and let model automatically decide optimal aspect ratio based on prompt description:
  • 1K - Approximately 1024×1024 pixels
  • 2K - Approximately 2048×2048 pixels
  • 4K - Approximately 4096×4096 pixels

Method 2: Exact Pixel Dimensions

Directly specify width and height (unit: pixels):
  • Default: 2048x2048
  • Total Pixel Range: [1280×720, 4096×4096]
  • Aspect Ratio Range: [1/16, 16]

Common Size Examples:

  • 2048x2048 - Square (default)
  • 1920x1080 - 16:9 landscape (Full HD)
  • 3840x2160 - 16:9 landscape (4K)
  • 1080x1920 - 9:16 portrait (phone screen)
  • 2560x1440 - 16:9 landscape (2K)
Note: The two methods cannot be used simultaneously. Choose one.

FAQ

SeeDream 4.0’s main advantages include: 4K HD image generation capability, excellent visual consistency, stability guaranteed by official strategic partnership, and 65% price advantage compared to official pricing.
Choose based on usage scenario:
  • Fast generation: Use resolution specs (“1K”, “2K”, “4K”), let model decide automatically
  • Exact control: Use pixel dimensions
    • Social media avatars: 2048x2048
    • Banners, covers: 3840x2160 or 2560x1440
    • Phone wallpaper: 1080x1920
    • Desktop wallpaper: 1920x1080 or 3840x2160
Yes, by setting the n parameter you can generate multiple images at once (recommended max 4 to ensure stability).

Best Practices

Prompt Optimization

  1. Detailed Descriptions: Provide specific scene, style, color descriptions
  2. Add Quality Tags: Such as “4K”, “ultra detailed”, “high quality”
  3. Specify Style: Such as “photorealistic”, “cartoon style”, “oil painting”
  4. Include Lighting Info: Such as “golden hour”, “soft lighting”, “dramatic shadows”

Example Prompts

Good prompt:
"A majestic mountain landscape at golden hour, snow-capped peaks reflecting
warm sunlight, crystal clear lake in foreground, pine forests, ultra detailed,
4K resolution, photorealistic"

Simple prompt:
"mountain landscape"  # Results may not be ideal
SeeDream 4.0 is a high-quality image generation service launched by APIYI after reaching strategic cooperation with BytePlus Volcano Engine, continuously being optimized. For questions or suggestions, please visit Feishu documentation to leave comments.