Skip to main content

Python client for the MIDJ API

Project description

MIDJPy

The MIDJPy package provides a simple and efficient way to interact with the MIDJ API. Utilize the power of MIDJ with just a few lines of Python code in your applications.

Prerequisites

To use this package, you need to have a midj.app subscription.

Features

  • Generate content with generate method.
  • Fetch content using the trigger ID with get_by_trigger method.
  • Generate a variation of content with generate_variation method.
  • Upscale images with upscale_image method.

Installation

To install the MIDJPy package, use pip:

pip install midjpy

Usage

Start by importing and initializing the MIDJ class:

from midjpy.midj import MIDJ

midj = MIDJ(authorization='YOUR_AUTHORIZATION_TOKEN')

Methods

For Subscription Users

generate(prompt)

Generate content based on a provided prompt:

response = midj.generate('Hello, world!')
print(response)
generate_variation(index, trigger_id, msg_hash)

Generate a variation of content:

response = midj.generate_variation(1, 'trigger_id_here', 'msg_hash_here')
print(response)
upscale_image(index, trigger_id, msg_hash)

Upscale an image:

response = midj.upscale_image(1, 'trigger_id_here', 'msg_hash_here')
print(response)

For Pre-paid Users

pregenerate(prompt)

Generate content based on a provided prompt:

response = midj.pregenerate('Hello, world!')
print(response)
pregenerate_variation(index, trigger_id, msg_hash)

Generate a variation of content:

response = midj.pregenerate_variation(1, 'trigger_id_here', 'msg_hash_here')
print(response)
preupscale_image(index, trigger_id, msg_hash)

Upscale an image:

response = midj.preupscale_image(1, 'trigger_id_here', 'msg_hash_here')
print(response)

Common API

get_by_trigger(trigger_id)

Fetch generated content by its trigger ID:

response = midj.get_by_trigger('trigger_id_here')
print(response)

Configuration

The MIDJ constructor accepts a configuration dictionary:

config = {
    'baseURL': 'https://api.midj.app',  # Optional. This is the default.
    'authorization': 'YOUR_AUTHORIZATION_TOKEN'  # Required.
}

midj = MIDJ(config)

⚠️ Always keep your authorization token secret. Do not expose it in client-side code.

Error Handling

All methods return an error object in case of any issues:

response = midj.generate('Hello, world!')

if 'error' in response:
    print('Error:', response['error'])
else:
    print('Generated Content:', response)

Contributing

For any bugs or feature requests, please open an issue on GitHub.

Please replace 'YOUR_AUTHORIZATION_TOKEN' with your actual MIDJ API authorization token.

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

midjpy-1.0.3.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

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

midjpy-1.0.3-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file midjpy-1.0.3.tar.gz.

File metadata

  • Download URL: midjpy-1.0.3.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for midjpy-1.0.3.tar.gz
Algorithm Hash digest
SHA256 4bfc8f9122b513bd1842a6cd670639a5b9fa2afa3c3246abe7611b4dea970390
MD5 7fa6adfba53a05e9133d760988ef59b4
BLAKE2b-256 0cce0d59099cac2155bb2073553c467f5c88932553f2a24da1b53c705c3fa23b

See more details on using hashes here.

File details

Details for the file midjpy-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: midjpy-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for midjpy-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 94d646c57762c5b4c1aaf831b956515a40bcfc930674f728064b64012ca75007
MD5 f63da2ba5f599823269d318e59dfde8e
BLAKE2b-256 7188238514cb3bee201a5400903d6757ff407aadaa34e96ba76cb113c5f45474

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