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 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.2.tar.gz (2.5 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.2-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: midjpy-1.0.2.tar.gz
  • Upload date:
  • Size: 2.5 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.2.tar.gz
Algorithm Hash digest
SHA256 c9876a22934fc1c4a7d3bfc4450ed0fa1d209181349d8aa8aee2b0ef2c3d25cd
MD5 9de8add976cf55f0ff67f8bc8432881a
BLAKE2b-256 0142254b9361be35b3a4836133b687c607c3564d28428c00963c6d44621c6e1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: midjpy-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 373905ad51f40b2de22b6a914d568ddee6d37311ab4875e6103edf14c982dce0
MD5 5a3aea56512f1a5a3a31c33bed6f2009
BLAKE2b-256 5f2fb6ae62e97b3cc9f3a777ec5476ffca9680f1993f6d740149d8fb16912106

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