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.4.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.4-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: midjpy-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 58b23f85797298a71fdff73dcc13a38c22fc7611aedb47850912feb4e0f3e1f4
MD5 af1abce9c6647aaed4eddf439321ec25
BLAKE2b-256 0cad6cfa027d4c1f99be02b1e3868cf49d8c5b5122895561f62e1e8d02c61d5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: midjpy-1.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 43349a4642b074cf4dcf28687503129e8280475c00bff0bcec69043257a898ff
MD5 23388a1ac32d601dc7ba326d44237f4b
BLAKE2b-256 25a0d177c56bfa3ef6e875bf4843e9f650970696f0720a6f088fb0b58cbed0ed

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