New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

midjpy

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

midjpy

Python client for the MIDJ API

pipPyPI
Version
1.0.4
Maintainers
1

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts