Seedance 2.0 API

repository·main·Indexed 43 days ago

https://github.com/anil-matcha/seedance-2-api

A Python wrapper for ByteDance's Seedance AI video generation models (2.0, 2.5, and 2 Mini) via MuAPI. Supports Text-to-Video, Image-to-Video, and Omni-Reference generation with high-fidelity 1080p output. Features specialized tools for consistent character generation using 4K character sheets and an MCP server for integration with AI assistants like Claude Desktop or Cursor.

Tokens
8.3K
Snippets
26
Records
32
Agent score
56%

What's inside Seedance

  1. Overview of Seedance 2.0 API models

    main

    The SDK provides access to several ByteDance video generation models via MuAPI:

    • Seedance 2.0: High-fidelity, cinematic quality (1080p) with realistic human face generation and superior motion control.
    • Seedance 2.5: Advanced model supporting native 4K, 30s clips, and multiple reference types (images, videos, audio).
    • Seedance 2 Mini: A lightweight, cost-effective model (approx. ~$0.073/sec) designed for fast prototyping and high-volume pipelines. Use text_to_video_mini() or image_to_video_mini() in the SDK.
  2. Maintain Character Consistency

    main

    To maintain a character's identity across multiple scenes, use one of two workflows:

    Option A: @character:<id> inline (Simplest)

    1. Generate a character sheet using create_character.
    2. Wait for completion to get the request_id.
    3. Reference the character in any prompt using the syntax @character:<request_id>.

    Option B: consistent_video() (Highest Fidelity)

    1. Generate a character sheet.
    2. Retrieve the sheet URL from the outputs[0] field after completion.
    3. Pass that URL directly as the @image1 reference in an Image-to-Video (I2V) request.
    from seedance_api import SeedanceAPI
    api = SeedanceAPI()
    
    # Step 1 — generate a character sheet
    char = api.create_character(
        images_list=["https://example.com/person.jpg"],
        outfit_description="cyberpunk jacket with neon accents, glowing visor",
    )
    char_id = char["request_id"]
    api.wait_for_completion(char_id)
    
    # Step 2 — reference the character inline
    video = api.text_to_video(
        prompt=f"@character:{char_id} rides a motorcycle through a neon-lit city at night",
        aspect_ratio="16:9",
        duration=5,
    )
    result = api.wait_for_completion(video["request_id"])
    print(f"Video: {result['outputs'][0]}")
  3. How character consistency works in Seedance 2.0

    main

    Character consistency is achieved through a two-step workflow that allows you to generate videos featuring the same fictional character across multiple scenes.

    1. Create a character sheet: You provide 1–3 reference photos of a person and a description of their outfit/style. The API generates a high-resolution (4K / 21:9) structured character sheet containing various views (front, back, side, action poses, facial expressions, and accessories).
    2. Use the character in videos: You can then reference this character in video generation using one of two methods:
      • Inline Reference (@character:<request_id>): The easiest method. You embed a special tag in your prompt, and the server automatically resolves the character sheet.
      • Direct Image-to-Video (consistent_video()): The high-fidelity method. You pass the sheet_url directly as the primary image in an Image-to-Video request. This provides the model with the full 4K sheet at inference time, leading to tighter face and identity preservation.
  4. Run the Seedance 2.0 MCP Server

    main

    The Seedance 2.0 API can be used as a Model Context Protocol (MCP) server, allowing AI assistants like Claude Desktop or Cursor to invoke Seedance tools directly.

    Prerequisites:

    • Ensure MUAPI_API_KEY is set in your environment.

    Commands:

    • To run the server: python3 mcp_server.py
    • To test with the MCP Inspector: npx -y @modelcontextprotocol/inspector python3 mcp_server.py
    # Run the server
    python3 mcp_server.py
    
    # Test with the MCP Inspector
    npx -y @modelcontextprotocol/inspector python3 mcp_server.py
  5. Create a consistent character sheet

    main

    Use the character command to define a reusable character for consistent generation across multiple videos.

    Common Flags:

    • --images: Images of the character's face.
    • --outfit: Description of the character's clothing.
    • --name: The unique name for the character.
    • --wait: Blocks until the character sheet is created.
    python3.11 skills/seedance-v2/seedance_cli.py character --images "https://example.com/face.jpg" --outfit "Cyberpunk neon jacket" --name "Neo" --wait
  6. Extend a video segment

    main

    Use the extend command to increase the duration of a previously generated video segment.

    Common Flags:

    • --request_id: The ID of the original video request.
    • --duration: How many seconds to extend.
    • --wait: Blocks until the extension is ready.
    python3.11 skills/seedance-v2/seedance_cli.py extend --request_id "YOUR_REQUEST_ID" --duration 5 --wait
  7. Edit existing videos

    main

    Use the edit command to modify an existing video or apply new styles using natural language commands.

    Common Flags:

    • --videos: URL of the video to edit.
    • --prompt: The editing instruction (e.g., "Add a sunset filter").
    • --wait: Blocks until the video is ready.
    python3.11 skills/seedance-v2/seedance_cli.py edit --videos "https://example.com/video.mp4" --prompt "Add a sunset filter" --wait
  8. Use characters via inline @character:<id> reference

    main

    The simplest way to use a character is to embed the character's request_id directly into your prompt using the syntax @character:<request_id>. This works across Text-to-Video (T2V), Image-to-Video (I2V), and Omni-Reference workflows.

    Examples:

    Text-to-Video:

    {
      "prompt": "@character:ab539e5f-1234-... walks through a rain-soaked neon city at night",
      "aspect_ratio": "16:9",
      "duration": 5,
      "quality": "basic"
    }

    Image-to-Video:

    {
      "prompt": "@character:ab539e5f-1234-... looks out over the city from a rooftop",
      "images_list": ["https://example.com/background.jpg"],
      "aspect_ratio": "16:9",
      "duration": 5
    }

    Omni-Reference (image + video + audio):

    {
      "prompt": "@character:ab539e5f-1234-... enters the scene and picks up the artifact",
      "aspect_ratio": "16:9",
      "duration": 6,
      "images_list": ["https://example.com/scene.jpg"],
      "video_files": ["https://example.com/intro_clip.mp4"]
    }

    Multiple Characters: You can reference multiple characters in a single prompt: "@character:ab539e5f-... and @character:cd781a2b-... face each other in the arena"

  9. Tips for best character consistency results

    main

    To ensure the highest quality character consistency, follow these best practices:

    • Reference photos: Use 2–3 clear, well-lit shots including a frontal view, a 3/4-angle, and a side profile. Avoid heavy shadows or obscured faces.
    • Outfit description: Be highly specific about materials, colors, and distinctive details to avoid generic results.
    • Prompt framing: Focus your prompt on what the character does (actions/environment) rather than what they look like, as the character sheet already provides the visual identity.
    • Consistency across scenes: Reuse the same char_id or sheet_url for every shot in a series.
    • Handling drifting features: If the @character:<id> method causes the character's face to drift or change, switch to consistent_video() to anchor the generation directly to the 4K sheet image.
    • Complex movement: For scenes with complex character actions, use duration=8 and quality=high for smoother motion.
  10. Generate video from text (T2V)

    main

    Use the t2v command to generate a video from a descriptive text prompt. You can specify aspect ratios, duration, quality, and whether to remove watermarks.

    Common Flags:

    • --prompt: The text description of the video.
    • --aspect_ratio: e.g., 16:9 (horizontal) or 9:16 (vertical).
    • --quality: Use high for 2K resolution.
    • --remove_watermark: Removes the MuAPI watermark.
    • --wait: Blocks the CLI until the video is ready and returns the final URL.
    python3.11 skills/seedance-v2/seedance_cli.py t2v --prompt "A cinematic slow-motion shot of a cyberpunk city in the rain" --wait