Skip to main content

Official Python SDK for MYTH AI Public API

Project description

myth-ai

Official Python SDK for the MYTH AI Public API - Programmatic access to MYTH AI's generative design capabilities.

Installation

pip install myth-ai

Authentication

All endpoints require a Bearer token. Get your API key from the MYTH AI dashboard.

from myth_ai import ImagesApi, Configuration

config = Configuration(
    host='https://api.myth-ai.com',
    access_token='sk-myth-xxxxx'  # Your API key
)

images = ImagesApi(configuration=config)

Quick Start

List Images

from myth_ai import ImagesApi, Configuration

config = Configuration(
    host='https://api.myth-ai.com',
    access_token='sk-myth-xxxxx'
)
images = ImagesApi(configuration=config)

result = images.list_images(page=1, page_size=10)

print(f'Total: {result.total}')
print('Images:', result.items)

Create Image from Image

import time
import uuid
from myth_ai import ImagesApi, Configuration, RepeatMode

config = Configuration(
    host='https://api.myth-ai.com',
    access_token='sk-myth-xxxxx'
)
images = ImagesApi(configuration=config)

# Create generation
result = images.create_image_to_image(
    idempotency_key=uuid.uuid4(),
    image_to_image_advanced_request={
        'url': 'https://example.com/inspiration.jpg',
        'width': 1024,
        'height': 1024,
        'sharpness': 7.5,
        'repeat_mode': RepeatMode.BLOCK
    }
)

print(f'Generation ID: {result.id}')

# Poll for completion
image = images.get_image(image_id=result.id)
while image.status in ('PENDING', 'PROCESSING'):
    time.sleep(2)
    image = images.get_image(image_id=result.id)
    print(f'Status: {image.status}')

if image.status == 'SUCCESS':
    print(f'Download URL: {image.url}')

Upload and Generate

import httpx
import uuid
from myth_ai import ImagesApi, UploadsApi, Configuration, RepeatMode

config = Configuration(
    host='https://api.myth-ai.com',
    access_token='sk-myth-xxxxx'
)
uploads = UploadsApi(configuration=config)
images = ImagesApi(configuration=config)

# Get presigned upload URL
upload_info = uploads.create_upload_url(
    idempotency_key=uuid.uuid4(),
    presigned_upload_request={
        'content_type': 'image/png'
    }
)

print(f'Artifact ID: {upload_info.artifact_id}')

# Upload file to S3
with open('inspiration.png', 'rb') as f:
    response = httpx.put(
        upload_info.presigned_url,
        content=f.read(),
        headers={'Content-Type': 'image/png'}
    )
    response.raise_for_status()

# Generate pattern using uploaded image
generation = images.create_image_to_image(
    idempotency_key=uuid.uuid4(),
    image_to_image_advanced_request={
        'url': upload_info.s3_url,
        'artifact_id': upload_info.artifact_id,
        'width': 1024,
        'height': 1024,
        'sharpness': 5.0,
        'repeat_mode': RepeatMode.HALF_DROP
    }
)

print(f'Generation ID: {generation.id}')

API Endpoints

All URIs are relative to https://api.myth-ai.com

Method Endpoint Description
GET /v1/images List images
GET /v1/images/{image_id} Get image details
POST /v1/images Image to Design (advanced)
POST /v1/images/extract Pattern extraction
POST /v1/images/prompt-to-image Image + Text to Design
POST /v1/images/seamless Make seamless
POST /v1/images/{image_id}/export Export image
POST /v1/uploads Get upload URL

Features

  • Full Type Hints - Complete type annotations for IDE support
  • Async Support - Works with async/await patterns
  • Idempotency - Built-in support for idempotent requests
  • Context Managers - Automatic connection cleanup

Async Usage

import asyncio
import uuid
from myth_ai import ImagesApi, Configuration, RepeatMode
from myth_ai.api_client import ApiClient

async def main():
    config = Configuration(
        host='https://api.myth-ai.com',
        access_token='sk-myth-xxxxx'
    )

    async with ApiClient(configuration=config) as client:
        images = ImagesApi(client)

        result = await images.create_image_to_image_async(
            idempotency_key=uuid.uuid4(),
            image_to_image_advanced_request={
                'url': 'https://example.com/image.jpg',
                'width': 1024,
                'height': 1024,
                'sharpness': 7.5,
                'repeat_mode': RepeatMode.BLOCK
            }
        )

        print(f'Generation ID: {result.id}')

asyncio.run(main())

Rate Limiting

Rate limits are enforced based on your plan:

  • Free: 100 requests/hour (GET), 10/hour (POST)
  • Pro: 1000 requests/hour (GET), 100/hour (POST)

Requirements

  • Python 3.9+
  • urllib3 >= 2.1.0
  • python-dateutil >= 2.8.2
  • pydantic >= 2
  • typing-extensions >= 4.7.1

Documentation

License

MIT

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

myth_ai-0.1.0b5.tar.gz (97.5 kB view details)

Uploaded Source

Built Distribution

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

myth_ai-0.1.0b5-py3-none-any.whl (185.9 kB view details)

Uploaded Python 3

File details

Details for the file myth_ai-0.1.0b5.tar.gz.

File metadata

  • Download URL: myth_ai-0.1.0b5.tar.gz
  • Upload date:
  • Size: 97.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for myth_ai-0.1.0b5.tar.gz
Algorithm Hash digest
SHA256 01cfc77bcdaf451c714cb6e59ced9f53ad77b703d7f5d915d5a7738925e75b17
MD5 f7319611b5097cb8427bcd0afb697129
BLAKE2b-256 8fb4875d9b589a8708d79477fb2db22ae0b8a429b26ea56f7c029dbb3a17e4f1

See more details on using hashes here.

File details

Details for the file myth_ai-0.1.0b5-py3-none-any.whl.

File metadata

  • Download URL: myth_ai-0.1.0b5-py3-none-any.whl
  • Upload date:
  • Size: 185.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for myth_ai-0.1.0b5-py3-none-any.whl
Algorithm Hash digest
SHA256 d14af44164261fe43e41798737fc9df79624d8a6627359ac68bc9716a239bfb7
MD5 55a24cbfa5dcfc21411d56fdfe75f611
BLAKE2b-256 4cb666016438843ac60ae6ec377b6d4423caefae9d70e69c524ce53ea9a1b114

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