├── midjourney_api.egg-info ├── dependency_links.txt ├── top_level.txt ├── SOURCES.txt └── PKG-INFO ├── .gitignore ├── .gitattributes ├── midjourney_api ├── setup.cfg ├── MANIFEST ├── __pycache__ │ └── __init__.cpython-310.pyc ├── LICENSE.txt └── __init__.py ├── MANIFEST ├── setup.py ├── README.md └── README.rst /midjourney_api.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /midjourney_api.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | midjourney_api 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | debug.py 2 | dist/** 3 | build/** 4 | **.egg-info/** -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /midjourney_api/setup.cfg: -------------------------------------------------------------------------------- 1 | # Inside of setup.cfg 2 | [metadata] 3 | description-file = README.rst -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | # file GENERATED by distutils, do NOT edit 2 | setup.py 3 | midjourney_api\__init__.py 4 | -------------------------------------------------------------------------------- /midjourney_api/MANIFEST: -------------------------------------------------------------------------------- 1 | # file GENERATED by distutils, do NOT edit 2 | setup.cfg 3 | setup.py 4 | midjourney_api\__init__.py 5 | -------------------------------------------------------------------------------- /midjourney_api/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/midjourney-api-the-next-leg/python-midjourney-api/HEAD/midjourney_api/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /midjourney_api.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | README.rst 2 | setup.py 3 | midjourney_api/__init__.py 4 | midjourney_api.egg-info/PKG-INFO 5 | midjourney_api.egg-info/SOURCES.txt 6 | midjourney_api.egg-info/dependency_links.txt 7 | midjourney_api.egg-info/top_level.txt -------------------------------------------------------------------------------- /midjourney_api/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | Copyright (c) 2018 YOUR NAME 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | setuptools.setup( 4 | name="midjourney_api", # How you named your package folder (MyLib) 5 | packages=["midjourney_api"], # Chose the same as "name" 6 | version="1.0.7", # Start with a small number and increase it with every change you make 7 | license="MIT", # Chose a license from here: https://help.github.com/articles/licensing-a-repository 8 | long_description=open("README.rst").read(), 9 | description="Midjourney API wrapper by The Next Leg", # Give a short description about your library 10 | author="The Next leg", # Type in your name 11 | author_email="support@thenextleg.io", # Type in your E-Mail 12 | url="https://github.com/midjourney-api-the-next-leg/python-midjourney-api", # Provide either the link to your github or to your website 13 | download_url="https://github.com/midjourney-api-the-next-leg/python-midjourney-api/archive/refs/tags/v1.0.0.tar.gz", # I explain this later on 14 | keywords=[ 15 | "MIDJOURNEY", 16 | "API", 17 | "THE_NEXT_LEG", 18 | ], # Keywords that define your package best 19 | install_requires=[], 20 | classifiers=[ 21 | "Development Status :: 3 - Alpha", # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package 22 | "Intended Audience :: Developers", # Define that your audience are developers 23 | "Topic :: Software Development :: Build Tools", 24 | "License :: OSI Approved :: MIT License", # Again, pick a license 25 | "Programming Language :: Python :: 3", # Specify which pyhton versions that you want to support 26 | "Programming Language :: Python :: 3.4", 27 | "Programming Language :: Python :: 3.5", 28 | "Programming Language :: Python :: 3.6", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Next Leg 2 | 3 | The Next Leg is a module that provides functionality for creating AI-generated images with Midjourney. It provides a simple interface for interacting with Midjourney's API and performing various actions such as creating images from prompts or URLs, describing images, using buttons or slash commands, and getting/setting account settings. 4 | 5 | ## Installation 6 | 7 | To use this package, you need to have Python installed on your machine. You can install TNL using pip: 8 | 9 | ```sh 10 | pip install midjourney-api 11 | ``` 12 | 13 | ## Usage 14 | 15 | Here is an example of how to use the TNL package to create an image from a prompt: 16 | 17 | ``` 18 | from midjourney_api import TNL 19 | 20 | TNL_API_KEY = 'your_api_key_here' 21 | tnl = TNL(TNL_API_KEY) 22 | 23 | prompt = 'a cat playing the piano' 24 | response = tnl.imagine(prompt) 25 | 26 | print(response) 27 | ``` 28 | 29 | ## API 30 | 31 | ### `TNL(api_key: str) 32 | 33 | Creates a new instance of `TNL` with the provided `apiKey`. 34 | 35 | ### Imagine 36 | 37 | `tnl.imagine(prompt: str, ref: str = '', webhook_override: str = '')` 38 | 39 | Creates a new image from a prompt. 40 | 41 | - `prompt` - The prompt you want to use to generate the image. 42 | - `ref` (optional) - A reference string that will be returned in the webhook response. 43 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 44 | 45 | ### Get Progress and Message Result 46 | 47 | `tnl.get_message_and_progress(message_id: str, expire_mins: Optional[int] = None)` 48 | 49 | Gets the progress and response of a message. 50 | 51 | - `message_id` - The message ID of the message you want to get the progress and response for. 52 | - `expire_mins` (optional) - A timeout for the request in minutes. If the request takes longer than this, it will return as 'incomplete' 53 | 54 | ### Img 2 Img 55 | 56 | `tnl.img2img(prompt: str, img_url: str, ref: str = '', webhook_override: str = '')` 57 | 58 | Creates an image from a prompt and an image. 59 | 60 | - `prompt` - The prompt you want to use to generate the image. 61 | - `img_url` - The URL of the image you want to use as the base image. 62 | - `ref` (optional) - A reference string that will be returned in the webhook response. 63 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 64 | 65 | ### Describe 66 | 67 | `tnl.describe(img_url: str, ref: str = '', webhook_override: str = '')` 68 | 69 | Describes an image. 70 | 71 | - `img_url` - The URL of the image you want to describe. 72 | - `ref` (optional) - A reference string that will be returned in the webhook response. 73 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 74 | 75 | ### Button 76 | 77 | `tnl.button(button: TNLTypes.ButtonTypes, button_message_id: str, ref: str = '', webhook_override: str = '')` 78 | 79 | Uses a button on an image. 80 | 81 | - `button` - A button type. 82 | - `button_message_id` - The button_message_id of the message that contains the button. 83 | - `ref` (optional) - A reference string that will be returned in the webhook response. 84 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 85 | 86 | ### Get Seed 87 | 88 | `tnl.getSeed(message_id: string): Promise` 89 | 90 | Gets a seed of a message. 91 | 92 | - `message_id` - The message ID of the message you want to get the seed for. 93 | 94 | ### Slash Command 95 | 96 | `tnl.slashCommand(slashCommand: TNLTypes.SlashCommands, ref?: string, webhook_override?: string)` 97 | 98 | Uses a slash command such as relax, fast, private, or stealth. 99 | 100 | - `slashCommand` - A slash command type. 101 | - `ref` (optional) - A reference string that will be returned in the webhook response. 102 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 103 | 104 | ### Get Settings 105 | 106 | `tnl.getSettings(): Promise` 107 | 108 | Gets the settings available for your account. 109 | 110 | ### Set Settings 111 | 112 | `tnl.setSettings(settings: TNLTypes.Settings, ref?: string, webhook_override?: string)` 113 | 114 | Sets the settings for your account. 115 | 116 | - `settings` - The settings you want to set. 117 | - `ref` (optional) - A reference string that will be returned in the webhook response. 118 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 119 | 120 | ### Get Info 121 | 122 | `tnl.getInfo(ref?: string, webhook_override?: string)` 123 | 124 | Gets information about your account including Fast Time Remaining, Job Mode, Queued Jobs and more. 125 | 126 | - `ref` (optional) - A reference string that will be returned in the webhook response. 127 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 128 | 129 | ### Get Seed 130 | 131 | `tnl.getSeed(message_id: str)` 132 | 133 | Gets a seed of a message. 134 | 135 | - `message_id` - The message ID of the message you want to get the seed for. 136 | 137 | ### Slash Command 138 | 139 | `tnl.slashCommand(slash_command: TNLTypes.SlashCommands, ref: str = '', webhook_override: str = '')` 140 | 141 | Uses a slash command such as relax, fast, private, or stealth. 142 | 143 | - `slash_command` - A slash command type. 144 | - `ref` (optional) - A reference string that will be returned in the webhook response. 145 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 146 | 147 | ### Get Settings 148 | 149 | `tnl.getSettings()` 150 | 151 | Gets the settings available for your account. 152 | 153 | ### Set Settings 154 | 155 | `tnl.setSettings(settings: TNLTypes.Settings, ref: str = '', webhook_override: str = '')` 156 | 157 | Sets the settings for your account. 158 | 159 | - `settings` - The settings you want to set. 160 | - `ref` (optional) - A reference string that will be returned in the webhook response. 161 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 162 | 163 | ### Get Info 164 | 165 | `tnl.getInfo(ref: str = '', webhook_override: str = '')` 166 | 167 | Gets information about your account including Fast Time Remaining, Job Mode, Queued Jobs and more. 168 | 169 | - `ref` (optional) - A reference string that will be returned in the webhook response. 170 | - `webhook_override` (optional) - A webhook URL that will be used instead of the one set in the dashboard. 171 | -------------------------------------------------------------------------------- /midjourney_api/__init__.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | BASE_URL = "https://api.thenextleg.io/v2" 4 | 5 | 6 | class TNL: 7 | def __init__(self, token): 8 | self.token = token 9 | 10 | def create_headers(self): 11 | return { 12 | "Content-Type": "application/json", 13 | "Authorization": f"Bearer {self.token}", 14 | } 15 | 16 | def imagine(self, prompt, ref="", webhook_override=""): 17 | """ 18 | Imagine an image based on a prompt. 19 | ARGS: 20 | prompt: str - The prompt to use. 21 | ref: str - A reference string passed back in the webhook 22 | webhook_override: str - A webhook to override the default webhook. 23 | """ 24 | request = { 25 | "msg": prompt, 26 | "ref": ref, 27 | "webhookOverride": webhook_override, 28 | } 29 | 30 | res = requests.post( 31 | f"{BASE_URL}/imagine", json=request, headers=self.create_headers() 32 | ) 33 | 34 | return res.json() 35 | 36 | def img2img(self, prompt, img_url, ref="", webhook_override=""): 37 | """ 38 | Perform an image to image operation. 39 | ARGS: 40 | prompt: str - The prompt to use. 41 | img_url: str - The image to use. 42 | ref: str - A reference string passed back in the webhook 43 | webhook_override: str - A webhook to override the default webhook. 44 | """ 45 | request = { 46 | "msg": f"{img_url} {prompt}", 47 | "ref": ref, 48 | "webhookOverride": webhook_override, 49 | } 50 | 51 | res = requests.post( 52 | f"{BASE_URL}/imagine", json=request, headers=self.create_headers() 53 | ) 54 | return res.json() 55 | 56 | def describe(self, img_url, ref="", webhook_override=""): 57 | """ 58 | Describe an image. 59 | ARGS: 60 | img_url: str - The image to describe. 61 | ref: str - A reference string passed back in the webhook 62 | webhook_override: str - A webhook to override the default webhook. 63 | """ 64 | request = { 65 | "url": img_url, 66 | "ref": ref, 67 | "webhookOverride": webhook_override, 68 | } 69 | 70 | res = requests.post( 71 | f"{BASE_URL}/imagine", json=request, headers=self.create_headers() 72 | ) 73 | return res.json() 74 | 75 | def button(self, button, button_message_id, ref="", webhook_override=""): 76 | """ 77 | Press a button. 78 | ARGS: 79 | button: str - The button to press. 80 | button_message_id: str - The message id of the button. 81 | ref: str - A reference string passed back in the webhook 82 | webhook_override: str - A webhook to override the default webhook. 83 | """ 84 | request = { 85 | "button": button, 86 | "buttonMessageId": button_message_id, 87 | "ref": ref, 88 | "webhookOverride": webhook_override, 89 | } 90 | 91 | res = requests.post( 92 | f"{BASE_URL}/button", json=request, headers=self.create_headers() 93 | ) 94 | return res.json() 95 | 96 | def get_seed(self, message_id): 97 | """ 98 | Get the seed of a message. 99 | ARGS: 100 | message_id: str - The message id of the message. 101 | """ 102 | request = { 103 | "messageId": message_id, 104 | } 105 | 106 | res = requests.post( 107 | f"{BASE_URL}/seed", json=request, headers=self.create_headers() 108 | ) 109 | return res.json() 110 | 111 | def slash_command(self, slash_command, ref="", webhook_override=""): 112 | """ 113 | Perform a slash command. 114 | ARGS: 115 | slash_command: str - The slash command to perform. 116 | ref: str - A reference string passed back in the webhook 117 | webhook_override: str - A webhook to override the default webhook. 118 | """ 119 | request = { 120 | "cmd": slash_command, 121 | "ref": ref, 122 | "webhookOverride": webhook_override, 123 | } 124 | 125 | res = requests.post( 126 | f"{BASE_URL}/slash-commands", json=request, headers=self.create_headers() 127 | ) 128 | return res.json() 129 | 130 | def get_settings(self): 131 | """ 132 | Get an account setting. 133 | """ 134 | res = requests.get(f"{BASE_URL}/settings", headers=self.create_headers()) 135 | return res.json() 136 | 137 | def set_settings(self, setting, ref="", webhook_override=""): 138 | """ 139 | Set an account settings. 140 | ARGS: 141 | setting: str - The setting to set. 142 | ref: str - A reference string passed back in the webhook 143 | webhook_override: str - A webhook to override the default webhook. 144 | """ 145 | request = { 146 | "settingsToggle": setting, 147 | "ref": ref, 148 | "webhookOverride": webhook_override, 149 | } 150 | 151 | res = requests.post( 152 | f"{BASE_URL}/settings", json=request, headers=self.create_headers() 153 | ) 154 | return res.json() 155 | 156 | def get_info(self, ref="", webhook_override=""): 157 | """ 158 | Get the info of the account. 159 | ARGS: 160 | ref: str - A reference string passed back in the webhook 161 | webhook_override: str - A webhook to override the default webhook. 162 | """ 163 | request = { 164 | "ref": ref, 165 | "webhookOverride": webhook_override, 166 | } 167 | 168 | res = requests.post( 169 | f"{BASE_URL}/info", json=request, headers=self.create_headers() 170 | ) 171 | return res.json() 172 | 173 | def get_message_and_progress(self, message_id, expire_mins): 174 | """ 175 | Get the message and progress of a message. 176 | ARGS: 177 | message_id: str - The message id of the message. 178 | expire_mins: int - The time to live for the message. 179 | """ 180 | url = f"{BASE_URL}/message/{message_id}" 181 | if expire_mins: 182 | url += f"?expireMins={expire_mins}" 183 | res = requests.get( 184 | f"{BASE_URL}/message/{message_id}", headers=self.create_headers() 185 | ) 186 | return res.json() 187 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | The Next Leg 2 | ============ 3 | 4 | The Next Leg is a module that provides functionality for creating 5 | AI-generated images with Midjourney. It provides a simple interface for 6 | interacting with Midjourney�s API and performing various actions such as 7 | creating images from prompts or URLs, describing images, using buttons 8 | or slash commands, and getting/setting account settings. 9 | 10 | Installation 11 | ------------ 12 | 13 | To use this package, you need to have Python installed on your machine. 14 | You can install TNL using pip: 15 | 16 | .. code:: sh 17 | 18 | pip install midjourney-api 19 | 20 | Usage 21 | ----- 22 | 23 | Here is an example of how to use the TNL package to create an image from 24 | a prompt: 25 | 26 | :: 27 | 28 | from midjourney_api import TNL 29 | 30 | TNL_API_KEY = 'your_api_key_here' 31 | tnl = TNL(TNL_API_KEY) 32 | 33 | prompt = 'a cat playing the piano' 34 | response = tnl.imagine(prompt) 35 | 36 | print(response) 37 | 38 | API 39 | --- 40 | 41 | \`TNL(api_key: str) 42 | ~~~~~~~~~~~~~~~~~~~ 43 | 44 | Creates a new instance of ``TNL`` with the provided ``apiKey``. 45 | 46 | Imagine 47 | ~~~~~~~ 48 | 49 | ``tnl.imagine(prompt: str, ref: str = '', webhook_override: str = '')`` 50 | 51 | Creates a new image from a prompt. 52 | 53 | - ``prompt`` - The prompt you want to use to generate the image. 54 | - ``ref`` (optional) - A reference string that will be returned in the 55 | webhook response. 56 | - ``webhook_override`` (optional) - A webhook URL that will be used 57 | instead of the one set in the dashboard. 58 | 59 | Get Progress and Message Result 60 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 | 62 | ``tnl.get_message_and_progress(message_id: str, expire_mins: Optional[int] = None)`` 63 | 64 | Gets the progress and response of a message. 65 | 66 | - ``message_id`` - The message ID of the message you want to get the 67 | progress and response for. 68 | - ``expire_mins`` (optional) - A timeout for the request in minutes. If 69 | the request takes longer than this, it will return as �incomplete� 70 | 71 | Img 2 Img 72 | ~~~~~~~~~ 73 | 74 | ``tnl.img2img(prompt: str, img_url: str, ref: str = '', webhook_override: str = '')`` 75 | 76 | Creates an image from a prompt and an image. 77 | 78 | - ``prompt`` - The prompt you want to use to generate the image. 79 | - ``img_url`` - The URL of the image you want to use as the base image. 80 | - ``ref`` (optional) - A reference string that will be returned in the 81 | webhook response. 82 | - ``webhook_override`` (optional) - A webhook URL that will be used 83 | instead of the one set in the dashboard. 84 | 85 | Describe 86 | ~~~~~~~~ 87 | 88 | ``tnl.describe(img_url: str, ref: str = '', webhook_override: str = '')`` 89 | 90 | Describes an image. 91 | 92 | - ``img_url`` - The URL of the image you want to describe. 93 | - ``ref`` (optional) - A reference string that will be returned in the 94 | webhook response. 95 | - ``webhook_override`` (optional) - A webhook URL that will be used 96 | instead of the one set in the dashboard. 97 | 98 | Button 99 | ~~~~~~ 100 | 101 | ``tnl.button(button: TNLTypes.ButtonTypes, button_message_id: str, ref: str = '', webhook_override: str = '')`` 102 | 103 | Uses a button on an image. 104 | 105 | - ``button`` - A button type. 106 | - ``button_message_id`` - The button_message_id of the message that 107 | contains the button. 108 | - ``ref`` (optional) - A reference string that will be returned in the 109 | webhook response. 110 | - ``webhook_override`` (optional) - A webhook URL that will be used 111 | instead of the one set in the dashboard. 112 | 113 | Get Seed 114 | ~~~~~~~~ 115 | 116 | ``tnl.getSeed(message_id: string): Promise`` 117 | 118 | Gets a seed of a message. 119 | 120 | - ``message_id`` - The message ID of the message you want to get the 121 | seed for. 122 | 123 | Slash Command 124 | ~~~~~~~~~~~~~ 125 | 126 | ``tnl.slashCommand(slashCommand: TNLTypes.SlashCommands, ref?: string, webhook_override?: string)`` 127 | 128 | Uses a slash command such as relax, fast, private, or stealth. 129 | 130 | - ``slashCommand`` - A slash command type. 131 | - ``ref`` (optional) - A reference string that will be returned in the 132 | webhook response. 133 | - ``webhook_override`` (optional) - A webhook URL that will be used 134 | instead of the one set in the dashboard. 135 | 136 | Get Settings 137 | ~~~~~~~~~~~~ 138 | 139 | ``tnl.getSettings(): Promise`` 140 | 141 | Gets the settings available for your account. 142 | 143 | Set Settings 144 | ~~~~~~~~~~~~ 145 | 146 | ``tnl.setSettings(settings: TNLTypes.Settings, ref?: string, webhook_override?: string)`` 147 | 148 | Sets the settings for your account. 149 | 150 | - ``settings`` - The settings you want to set. 151 | - ``ref`` (optional) - A reference string that will be returned in the 152 | webhook response. 153 | - ``webhook_override`` (optional) - A webhook URL that will be used 154 | instead of the one set in the dashboard. 155 | 156 | Get Info 157 | ~~~~~~~~ 158 | 159 | ``tnl.getInfo(ref?: string, webhook_override?: string)`` 160 | 161 | Gets information about your account including Fast Time Remaining, Job 162 | Mode, Queued Jobs and more. 163 | 164 | - ``ref`` (optional) - A reference string that will be returned in the 165 | webhook response. 166 | - ``webhook_override`` (optional) - A webhook URL that will be used 167 | instead of the one set in the dashboard. 168 | 169 | .. _get-seed-1: 170 | 171 | Get Seed 172 | ~~~~~~~~ 173 | 174 | ``tnl.getSeed(message_id: str)`` 175 | 176 | Gets a seed of a message. 177 | 178 | - ``message_id`` - The message ID of the message you want to get the 179 | seed for. 180 | 181 | .. _slash-command-1: 182 | 183 | Slash Command 184 | ~~~~~~~~~~~~~ 185 | 186 | ``tnl.slashCommand(slash_command: TNLTypes.SlashCommands, ref: str = '', webhook_override: str = '')`` 187 | 188 | Uses a slash command such as relax, fast, private, or stealth. 189 | 190 | - ``slash_command`` - A slash command type. 191 | - ``ref`` (optional) - A reference string that will be returned in the 192 | webhook response. 193 | - ``webhook_override`` (optional) - A webhook URL that will be used 194 | instead of the one set in the dashboard. 195 | 196 | .. _get-settings-1: 197 | 198 | Get Settings 199 | ~~~~~~~~~~~~ 200 | 201 | ``tnl.getSettings()`` 202 | 203 | Gets the settings available for your account. 204 | 205 | .. _set-settings-1: 206 | 207 | Set Settings 208 | ~~~~~~~~~~~~ 209 | 210 | ``tnl.setSettings(settings: TNLTypes.Settings, ref: str = '', webhook_override: str = '')`` 211 | 212 | Sets the settings for your account. 213 | 214 | - ``settings`` - The settings you want to set. 215 | - ``ref`` (optional) - A reference string that will be returned in the 216 | webhook response. 217 | - ``webhook_override`` (optional) - A webhook URL that will be used 218 | instead of the one set in the dashboard. 219 | 220 | .. _get-info-1: 221 | 222 | Get Info 223 | ~~~~~~~~ 224 | 225 | ``tnl.getInfo(ref: str = '', webhook_override: str = '')`` 226 | 227 | Gets information about your account including Fast Time Remaining, Job 228 | Mode, Queued Jobs and more. 229 | 230 | - ``ref`` (optional) - A reference string that will be returned in the 231 | webhook response. 232 | - ``webhook_override`` (optional) - A webhook URL that will be used 233 | instead of the one set in the dashboard. 234 | -------------------------------------------------------------------------------- /midjourney_api.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: midjourney-api 3 | Version: 1.0.7 4 | Summary: Midjourney API wrapper by The Next Leg 5 | Home-page: https://github.com/midjourney-api-the-next-leg/python-midjourney-api 6 | Download-URL: https://github.com/midjourney-api-the-next-leg/python-midjourney-api/archive/refs/tags/v1.0.0.tar.gz 7 | Author: The Next leg 8 | Author-email: support@thenextleg.io 9 | License: MIT 10 | Keywords: MIDJOURNEY,API,THE_NEXT_LEG 11 | Classifier: Development Status :: 3 - Alpha 12 | Classifier: Intended Audience :: Developers 13 | Classifier: Topic :: Software Development :: Build Tools 14 | Classifier: License :: OSI Approved :: MIT License 15 | Classifier: Programming Language :: Python :: 3 16 | Classifier: Programming Language :: Python :: 3.4 17 | Classifier: Programming Language :: Python :: 3.5 18 | Classifier: Programming Language :: Python :: 3.6 19 | 20 | The Next Leg 21 | ============ 22 | 23 | The Next Leg is a module that provides functionality for creating 24 | AI-generated images with Midjourney. It provides a simple interface for 25 | interacting with Midjourney�s API and performing various actions such as 26 | creating images from prompts or URLs, describing images, using buttons 27 | or slash commands, and getting/setting account settings. 28 | 29 | Installation 30 | ------------ 31 | 32 | To use this package, you need to have Python installed on your machine. 33 | You can install TNL using pip: 34 | 35 | .. code:: sh 36 | 37 | pip install midjourney-api 38 | 39 | Usage 40 | ----- 41 | 42 | Here is an example of how to use the TNL package to create an image from 43 | a prompt: 44 | 45 | :: 46 | 47 | from midjourney_api import TNL 48 | 49 | TNL_API_KEY = 'your_api_key_here' 50 | tnl = TNL(TNL_API_KEY) 51 | 52 | prompt = 'a cat playing the piano' 53 | response = tnl.imagine(prompt) 54 | 55 | print(response) 56 | 57 | API 58 | --- 59 | 60 | \`TNL(api_key: str) 61 | ~~~~~~~~~~~~~~~~~~~ 62 | 63 | Creates a new instance of ``TNL`` with the provided ``apiKey``. 64 | 65 | Imagine 66 | ~~~~~~~ 67 | 68 | ``tnl.imagine(prompt: str, ref: str = '', webhook_override: str = '')`` 69 | 70 | Creates a new image from a prompt. 71 | 72 | - ``prompt`` - The prompt you want to use to generate the image. 73 | - ``ref`` (optional) - A reference string that will be returned in the 74 | webhook response. 75 | - ``webhook_override`` (optional) - A webhook URL that will be used 76 | instead of the one set in the dashboard. 77 | 78 | Get Progress and Message Result 79 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 80 | 81 | ``tnl.get_message_and_progress(message_id: str, expire_mins: Optional[int] = None)`` 82 | 83 | Gets the progress and response of a message. 84 | 85 | - ``message_id`` - The message ID of the message you want to get the 86 | progress and response for. 87 | - ``expire_mins`` (optional) - A timeout for the request in minutes. If 88 | the request takes longer than this, it will return as �incomplete� 89 | 90 | Img 2 Img 91 | ~~~~~~~~~ 92 | 93 | ``tnl.img2img(prompt: str, img_url: str, ref: str = '', webhook_override: str = '')`` 94 | 95 | Creates an image from a prompt and an image. 96 | 97 | - ``prompt`` - The prompt you want to use to generate the image. 98 | - ``img_url`` - The URL of the image you want to use as the base image. 99 | - ``ref`` (optional) - A reference string that will be returned in the 100 | webhook response. 101 | - ``webhook_override`` (optional) - A webhook URL that will be used 102 | instead of the one set in the dashboard. 103 | 104 | Describe 105 | ~~~~~~~~ 106 | 107 | ``tnl.describe(img_url: str, ref: str = '', webhook_override: str = '')`` 108 | 109 | Describes an image. 110 | 111 | - ``img_url`` - The URL of the image you want to describe. 112 | - ``ref`` (optional) - A reference string that will be returned in the 113 | webhook response. 114 | - ``webhook_override`` (optional) - A webhook URL that will be used 115 | instead of the one set in the dashboard. 116 | 117 | Button 118 | ~~~~~~ 119 | 120 | ``tnl.button(button: TNLTypes.ButtonTypes, button_message_id: str, ref: str = '', webhook_override: str = '')`` 121 | 122 | Uses a button on an image. 123 | 124 | - ``button`` - A button type. 125 | - ``button_message_id`` - The button_message_id of the message that 126 | contains the button. 127 | - ``ref`` (optional) - A reference string that will be returned in the 128 | webhook response. 129 | - ``webhook_override`` (optional) - A webhook URL that will be used 130 | instead of the one set in the dashboard. 131 | 132 | Get Seed 133 | ~~~~~~~~ 134 | 135 | ``tnl.getSeed(message_id: string): Promise`` 136 | 137 | Gets a seed of a message. 138 | 139 | - ``message_id`` - The message ID of the message you want to get the 140 | seed for. 141 | 142 | Slash Command 143 | ~~~~~~~~~~~~~ 144 | 145 | ``tnl.slashCommand(slashCommand: TNLTypes.SlashCommands, ref?: string, webhook_override?: string)`` 146 | 147 | Uses a slash command such as relax, fast, private, or stealth. 148 | 149 | - ``slashCommand`` - A slash command type. 150 | - ``ref`` (optional) - A reference string that will be returned in the 151 | webhook response. 152 | - ``webhook_override`` (optional) - A webhook URL that will be used 153 | instead of the one set in the dashboard. 154 | 155 | Get Settings 156 | ~~~~~~~~~~~~ 157 | 158 | ``tnl.getSettings(): Promise`` 159 | 160 | Gets the settings available for your account. 161 | 162 | Set Settings 163 | ~~~~~~~~~~~~ 164 | 165 | ``tnl.setSettings(settings: TNLTypes.Settings, ref?: string, webhook_override?: string)`` 166 | 167 | Sets the settings for your account. 168 | 169 | - ``settings`` - The settings you want to set. 170 | - ``ref`` (optional) - A reference string that will be returned in the 171 | webhook response. 172 | - ``webhook_override`` (optional) - A webhook URL that will be used 173 | instead of the one set in the dashboard. 174 | 175 | Get Info 176 | ~~~~~~~~ 177 | 178 | ``tnl.getInfo(ref?: string, webhook_override?: string)`` 179 | 180 | Gets information about your account including Fast Time Remaining, Job 181 | Mode, Queued Jobs and more. 182 | 183 | - ``ref`` (optional) - A reference string that will be returned in the 184 | webhook response. 185 | - ``webhook_override`` (optional) - A webhook URL that will be used 186 | instead of the one set in the dashboard. 187 | 188 | .. _get-seed-1: 189 | 190 | Get Seed 191 | ~~~~~~~~ 192 | 193 | ``tnl.getSeed(message_id: str)`` 194 | 195 | Gets a seed of a message. 196 | 197 | - ``message_id`` - The message ID of the message you want to get the 198 | seed for. 199 | 200 | .. _slash-command-1: 201 | 202 | Slash Command 203 | ~~~~~~~~~~~~~ 204 | 205 | ``tnl.slashCommand(slash_command: TNLTypes.SlashCommands, ref: str = '', webhook_override: str = '')`` 206 | 207 | Uses a slash command such as relax, fast, private, or stealth. 208 | 209 | - ``slash_command`` - A slash command type. 210 | - ``ref`` (optional) - A reference string that will be returned in the 211 | webhook response. 212 | - ``webhook_override`` (optional) - A webhook URL that will be used 213 | instead of the one set in the dashboard. 214 | 215 | .. _get-settings-1: 216 | 217 | Get Settings 218 | ~~~~~~~~~~~~ 219 | 220 | ``tnl.getSettings()`` 221 | 222 | Gets the settings available for your account. 223 | 224 | .. _set-settings-1: 225 | 226 | Set Settings 227 | ~~~~~~~~~~~~ 228 | 229 | ``tnl.setSettings(settings: TNLTypes.Settings, ref: str = '', webhook_override: str = '')`` 230 | 231 | Sets the settings for your account. 232 | 233 | - ``settings`` - The settings you want to set. 234 | - ``ref`` (optional) - A reference string that will be returned in the 235 | webhook response. 236 | - ``webhook_override`` (optional) - A webhook URL that will be used 237 | instead of the one set in the dashboard. 238 | 239 | .. _get-info-1: 240 | 241 | Get Info 242 | ~~~~~~~~ 243 | 244 | ``tnl.getInfo(ref: str = '', webhook_override: str = '')`` 245 | 246 | Gets information about your account including Fast Time Remaining, Job 247 | Mode, Queued Jobs and more. 248 | 249 | - ``ref`` (optional) - A reference string that will be returned in the 250 | webhook response. 251 | - ``webhook_override`` (optional) - A webhook URL that will be used 252 | instead of the one set in the dashboard. 253 | --------------------------------------------------------------------------------