Skip to main content

Python SDK for Legnext AI API - Professional image and video generation using Midjourney models

Project description

Legnext Python SDK

Official Python client library for the Legnext AI API - Professional image and video generation using Midjourney models.

Features

  • Comprehensive API Coverage: Support for all Legnext endpoints
  • Type Safety: Full type hints with Pydantic models
  • Async Support: Both synchronous and asynchronous clients
  • Modern Design: Clean, intuitive API following OpenAI SDK patterns
  • Task Management: Built-in polling and webhook support
  • Error Handling: Robust error handling with automatic retries

Installation

pip install legnext

Or with uv:

uv pip install legnext

Quick Start

Basic Usage

from legnext import Client

client = Client(api_key="your-api-key")

# Generate an image
response = client.midjourney.diffusion(
    text="a beautiful sunset over mountains"
)

print(f"Job ID: {response.job_id}")
print(f"Status: {response.status}")

# Wait for completion
result = client.tasks.wait_for_completion(response.job_id)
print(f"Image URLs: {result.output.image_urls}")

Async Usage

import asyncio
from legnext import AsyncClient

async def main():
    async with AsyncClient(api_key="your-api-key") as client:
        response = await client.midjourney.diffusion(
            text="a futuristic cityscape"
        )
        result = await client.tasks.wait_for_completion(response.job_id)
        print(f"Generated: {result.output.image_urls}")

asyncio.run(main())

API Coverage

Midjourney Operations

Image Generation:

  • client.midjourney.diffusion(text) - Text to image generation (POST /diffusion)
  • client.midjourney.variation(job_id, image_no, type) - Create variations (POST /variation)
  • client.midjourney.upscale(job_id, image_no, type) - Upscale images (POST /upscale)
  • client.midjourney.reroll(job_id) - Re-generate with same prompt (POST /reroll)
  • client.midjourney.blend(image_urls) - Blend 2-5 images (POST /blend)
  • client.midjourney.describe(image_url) - Generate descriptions (POST /describe)
  • client.midjourney.shorten(prompt) - Optimize prompts (POST /shorten)
  • client.midjourney.pan(job_id, image_no, direction) - Extend in direction (POST /pan)
  • client.midjourney.outpaint(job_id, image_no) - Expand all directions (POST /outpaint)
  • client.midjourney.inpaint(job_id, image_no, mask, prompt) - Region editing (POST /inpaint)
  • client.midjourney.remix(job_id, image_no, prompt) - Transform with new prompt (POST /remix)
  • client.midjourney.edit(job_id, image_no, prompt) - Edit specific areas (POST /edit)
  • client.midjourney.upload_paint(image, prompt) - Advanced editing (POST /upload-paint)
  • client.midjourney.retexture(job_id, image_no, prompt) - Change textures (POST /retexture)
  • client.midjourney.remove_background(job_id, image_no) - Remove background (POST /remove-background)
  • client.midjourney.enhance(job_id, image_no) - Improve quality (POST /enhance)

Video Generation:

  • client.midjourney.video_diffusion(prompt, image_url, duration) - Generate video (POST /video-diffusion)
  • client.midjourney.extend_video(job_id) - Extend video (POST /extend-video)
  • client.midjourney.video_upscale(job_id) - Upscale video (POST /video-upscale)

Task Management

  • client.tasks.get() - Get task status
  • client.tasks.wait_for_completion() - Poll until complete

Requirements

  • Python 3.10+
  • httpx >= 0.27.0
  • pydantic >= 2.0.0

Documentation

Support

For questions or issues, please contact:

License

Apache License 2.0 - See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

legnext-0.1.5.tar.gz (62.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

legnext-0.1.5-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file legnext-0.1.5.tar.gz.

File metadata

  • Download URL: legnext-0.1.5.tar.gz
  • Upload date:
  • Size: 62.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for legnext-0.1.5.tar.gz
Algorithm Hash digest
SHA256 dcf6b2921c811c60cb871f78c0c15de06177e43f6effca66b330bc03ebb0117a
MD5 cc3d8b93e955624482522e9dc4d2a912
BLAKE2b-256 65ad82c1398843732460e161bcbd9c682904b5d51495a15541c9b57b3212e6f8

See more details on using hashes here.

File details

Details for the file legnext-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: legnext-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for legnext-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ad46459f3c9967f6ac0e356739e14bb6ae1487f40aa9683f6576f8c198bf1b67
MD5 c5731a77dd56007ad4038bd6312138da
BLAKE2b-256 89f75d1af90228141274a91c5746b36782ac6c2b1b1266711bedd6c043499d1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page