<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jun Xu on Medium]]></title>
        <description><![CDATA[Stories by Jun Xu on Medium]]></description>
        <link>https://medium.com/@jun.xu708?source=rss-83cb5733d394------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vttmLKpLVnnStZkm</url>
            <title>Stories by Jun Xu on Medium</title>
            <link>https://medium.com/@jun.xu708?source=rss-83cb5733d394------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:54:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jun.xu708/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Global Proxy Connection]]></title>
            <link>https://medium.com/@jun.xu708/global-proxy-connection-e2d33414dba9?source=rss-83cb5733d394------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2d33414dba9</guid>
            <category><![CDATA[proxy-server]]></category>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[proxy-service]]></category>
            <dc:creator><![CDATA[Jun Xu]]></dc:creator>
            <pubDate>Thu, 05 Sep 2024 09:49:40 GMT</pubDate>
            <atom:updated>2024-09-05T09:49:40.547Z</atom:updated>
            <content:encoded><![CDATA[<h3>Global Proxy Connection Instructions</h3><p>This document mainly introduces the connection instructions for Ace Data Cloud’s global proxy, including application methods, usage methods, and other specific content.</p><h3>Trial Link</h3><p>You can register our <a href="https://surl.id/1uHAKZJLhT">website</a> and have a trial, we provide user interface and API, if you want to use our API, send me email: jun.xu708@gmail.com .</p><h3>Application Method</h3><p>To use the global service, you can first apply at the “<a href="https://platform.acedata.cloud/services/87ae4a5a-59d9-4c50-86d4-c0b5d393e5af">Application Page</a>”, and you will receive 1 free credit for your first application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_2pK_BESR0FJSCOg.png" /></figure><p>If you are not logged in, you will automatically be redirected to the login page. After logging in, you can continue with your application.</p><h3>Usage Method</h3><p>After the application is complete, you can check your application results in the “Console,” as shown in the figure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FnynJ2r_SeewRIsq.png" /></figure><p>Click on “Credentials” to view the username and password for using the global proxy service, separated by a colon. The username is 8 characters long, and the password is 32 characters long, as shown in the figure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IXjvSGTwu-SldiFQ.png" /></figure><p>This proxy is a rotating proxy, so you only need to set a fixed proxy address and port for use. The proxy address and port are global.proxy.acedata.cloud and 30007, respectively. This proxy supports HTTP/HTTPS/SOCKS protocols and can be used to request HTTP and HTTPS websites.</p><blockquote>Note: This proxy can only be used outside mainland China. It cannot be used within mainland China.</blockquote><h3>Command Testing</h3><p>Once you have the proxy username and password, the easiest way to test is by using the curl command line. If you haven’t installed it yet, please refer to <a href="https://curl.se/">https://curl.se/</a> for installation.</p><p>Assuming the current proxy username and password are 1f78266a:eff0896726224fa2a99fe82dd1f07562, you can test it using the following curl command:</p><pre>curl -x 1f78266a:eff0896726224fa2a99fe82dd1f07562@global.proxy.acedata.cloud:30007 https://ipinfo.io</pre><p>Here, we use the curl -x parameter to specify the proxy address. The default proxy protocol is HTTP/HTTPS. The URL requested is <a href="https://ipinfo.io/">https://ipinfo.io</a>, which can return the real IP address and geographical location of the requesting IP.</p><blockquote>Note: The above username and password may be invalid; please replace them with your own username and password.</blockquote><p>The output result is as follows:</p><pre>{<br>  &quot;ip&quot;: &quot;66.206.249.77&quot;,<br>  &quot;hostname&quot;: &quot;host-66-206-249-77.public.eastlink.ca&quot;,<br>  &quot;city&quot;: &quot;Kirkland Lake&quot;,<br>  &quot;region&quot;: &quot;Ontario&quot;,<br>  &quot;country&quot;: &quot;CA&quot;,<br>  &quot;loc&quot;: &quot;48.1446,-80.0377&quot;,<br>  &quot;org&quot;: &quot;AS11260 EastLink&quot;,<br>  &quot;postal&quot;: &quot;P2N&quot;,<br>  &quot;timezone&quot;: &quot;America/Toronto&quot;,<br>  &quot;readme&quot;: &quot;https://ipinfo.io/missingauth&quot;<br>}</pre><p>As you can see, the returned country is CA, which represents Canada. If you run it again, you can get different results; each request uses a random IP exit.</p><h3>Code Connection</h3><p>Below is an example of how to set up the proxy using Python:</p><pre>import requests<br> <br>proxy = &#39;http://{proxyusername}:{proxypassword}@global.proxy.acedata.cloud:30007&#39;<br> <br>proxies = {<br>    &#39;http&#39;: proxy,<br>    &#39;https&#39;: proxy<br>}<br> <br>for _ in range(3):<br>    resp = requests.get(&#39;https://ipinfo.io&#39;, proxies=proxies)<br>    print(resp.text)</pre><p>Here, we first declare the proxy URL and assign it to the proxy variable. The protocol is HTTP, followed by the username and password for the tunnel proxy (i.e., the username and password displayed in the console, separated by a colon), then an @ symbol, followed by the proxy address and port.</p><blockquote>Note: You need to replace {proxyusername}:{proxypassword} in the code above with your proxy username and password. The final result should look like proxy = &#39;http://1f78266a:eff0896726224fa2a99fe82dd1f07562@global.proxy.acedata.cloud:30007&#39;, noting that there are no { and } characters.</blockquote><p>Next, we declare a proxies variable that configures two key-value pairs, with the keys named http and https, both set to the proxy variable, indicating that for HTTP and HTTPS websites, the requests will be made using the proxy defined in the proxy variable. We then define a loop to test the proxy three times.</p><p>The output result is as follows:</p><pre>{<br>  &quot;ip&quot;: &quot;103.190.205.165&quot;,<br>  &quot;hostname&quot;: &quot;assigned-for-client.adnsl.com&quot;,<br>  &quot;city&quot;: &quot;Paltan&quot;,<br>  &quot;region&quot;: &quot;Dhaka Division&quot;,<br>  &quot;country&quot;: &quot;BD&quot;,<br>  &quot;loc&quot;: &quot;23.7362,90.4143&quot;,<br>  &quot;org&quot;: &quot;AS38203 ADN Telecom Ltd.&quot;,<br>  &quot;postal&quot;: &quot;1000&quot;,<br>  &quot;timezone&quot;: &quot;Asia/Dhaka&quot;,<br>  &quot;readme&quot;: &quot;https://ipinfo.io/missingauth&quot;<br>}<br>{<br>  &quot;ip&quot;: &quot;74.111.25.181&quot;,<br>  &quot;hostname&quot;: &quot;pool-74-111-25-181.syrcny.fios.verizon.net&quot;,<br>  &quot;city&quot;: &quot;Syracuse&quot;,<br>  &quot;region&quot;: &quot;New York&quot;,<br>  &quot;country&quot;: &quot;US&quot;,<br>  &quot;loc&quot;: &quot;43.0481,-76.1474&quot;,<br>  &quot;org&quot;: &quot;AS701 Verizon Business&quot;,<br>  &quot;postal&quot;: &quot;13201&quot;,<br>  &quot;timezone&quot;: &quot;America/New_York&quot;,<br>  &quot;readme&quot;: &quot;https://ipinfo.io/missingauth&quot;<br>}<br>{<br>  &quot;ip&quot;: &quot;207.113.168.248&quot;,<br>  &quot;city&quot;: &quot;LaPorte&quot;,<br>  &quot;region&quot;: &quot;Indiana&quot;,<br>  &quot;country&quot;: &quot;US&quot;,<br>  &quot;loc&quot;: &quot;41.6106,-86.7225&quot;,<br>  &quot;org&quot;: &quot;AS13428 Surf Air Wireless, LLC&quot;,<br>  &quot;postal&quot;: &quot;46350&quot;,<br>  &quot;timezone&quot;: &quot;America/Chicago&quot;,<br>  &quot;readme&quot;: &quot;https://ipinfo.io/missingauth&quot;<br>}</pre><p>As you can see, each run yields a random proxy IP, and the IP’s geographical location is indeed from different countries and cities worldwide.</p><p>Of course, the above proxy setup method is actually a relatively simple configuration.</p><p>In fact, the above code is equivalent to setting an additional Header — Proxy Authorization at the time of the request, so the above code can also be rewritten as follows:</p><pre>import requests<br>import base64<br> <br>proxy_host = &#39;global.proxy.acedata.cloud&#39;<br>proxy_port = &#39;30007&#39;<br>proxyusername = &#39;{proxyusername}&#39; # 8 character username<br>proxypassword = &#39;{proxypassword}&#39; # 32 character password<br> <br>credentials = base64.b64encode(<br>    f&#39;{proxyusername}:{proxypassword}&#39;.encode()).decode()<br> <br>proxies = {<br>    &#39;http&#39;: f&#39;http://{proxyhost}:{proxyport}&#39;,<br>    &#39;https&#39;: f&#39;http://{proxyhost}:{proxyport}&#39;<br>}<br> <br>headers = {<br>    &#39;Proxy-Authorization&#39;: f&#39;Basic {credentials}&#39;<br>}<br> <br>for _ in range(3):<br>    resp = requests.get(&#39;https://ipinfo.io&#39;,<br>                        proxies=proxies, headers=headers)<br>    print(resp.text)</pre><p>As you can see, here we have set the proxy username and password via the Proxy-Authorization request header (which needs to be Base64 encoded), achieving the same result as before.</p><p>For other languages, such as JavaScript’s axios, a similar setup method can also be used:</p><pre>const axios = require(&quot;axios&quot;);<br>const base64 = require(&quot;base64&quot;);<br> <br>const proxy_host = &quot;global.proxy.acedata.cloud&quot;;<br>const proxy_port = &quot;30007&quot;;<br>const proxyusername = &quot;{proxyusername}&quot;; // 8-character username<br>const proxypassword = &quot;{proxypassword}&quot;; // 32-character password<br> <br>const credentials = base64.encode(`${proxyusername}:${proxypassword}`);<br> <br>const proxies = {<br>  http: `http://${proxyhost}:${proxyport}`,<br>  https: `http://${proxyhost}:${proxyport}`,<br>};<br> <br>const headers = {<br>  &quot;Proxy-Authorization&quot;: `Basic ${credentials}`,<br>};<br> <br>for (let i = 0; i &lt; 3; i++) {<br>  axios<br>    .get(&quot;https://ipinfo.io&quot;, { proxies, headers })<br>    .then((resp) =&gt; console.log(resp.data))<br>    .catch((err) =&gt; console.error(err));<br>}</pre><p>The running effect is the same.</p><p>For the configuration methods in other languages, please refer to the above text and rewrite accordingly.</p><h3>Region Filtering</h3><p>We can filter the region by adding the region in the username, for example, if you want to choose a proxy from the United States, the original username is 1f78266a, you can change the username to 1f78266a-region-us, the above curl can be rewritten as follows:</p><pre>curl -x 1f78266a-region-us:eff0896726224fa2a99fe82dd1f07562@global.proxy.acedata.cloud:30007 https://ipinfo.io</pre><p>Region list:</p><p>Country or Region Name Country/Region Code United States us Hong Kong hk Andorra ad United Arab Emirates ae Afghanistan af Antigua and Barbuda ag Anguilla ai Albania al Armenia am Angola ao Antarctica aq Argentina ar American Samoa as Austria at Australia au Aruba aw Åland Islands ax Azerbaijan az Bosnia and Herzegovina ba Barbados bb Bangladesh bd Belgium be Burkina Faso bf Bulgaria bg Bahrain bh Burundi bi Benin bj Saint Barthélemy bl Bermuda bm Brunei bn Bolivia bo Dutch Caribbean bq Brazil br Bahamas bs Bhutan bt Bouvet Island bv Botswana bw Belarus by Belize bz Canada ca Cocos (Keeling) Islands cc Central African Republic cf Switzerland ch Chile cl Cameroon cm Colombia co Costa Rica cr Cuba cu Cape Verde cv Christmas Island cx Cyprus cy Czech Republic cz Germany de Djibouti dj Denmark dk Dominica dm Dominican Republic do Algeria dz Ecuador ec Estonia ee Egypt eg Western Sahara eh Eritrea er Spain es Finland fi Fiji fj Micronesia fm Faroe Islands fo France fr Gabon ga Grenada gd Georgia ge French Guiana gf Ghana gh Gibraltar gi Greenland gl Guinea gn Guadeloupe gp Equatorial Guinea gq Greece gr Guatemala gt Guam gu Guinea-Bissau gw Guyana gy Heard Island and McDonald Islands hm Honduras hn Croatia hr Haiti ht Hungary hu Indonesia id Ireland ie Israel il Isle of Man im India in British Indian Ocean Territory io Iraq iq Iran ir Iceland is Italy it Jersey je Jamaica jm Jordan jo Japan jp Cambodia kh Kiribati ki Comoros km Kuwait kw Cayman Islands ky Lebanon lb Liechtenstein li Sri Lanka lk Liberia lr Lesotho ls Lithuania lt Luxembourg lu Latvia lv Libya ly Morocco ma Monaco mc Moldova md Montenegro me French Saint Martin mf Madagascar mg Marshall Islands mh Macedonia mk Mali ml Myanmar mm Macau mo Martinique mq Mauritania mr Montserrat ms Malta mt Maldives mv Malawi mw Mexico mx Malaysia my Namibia na Niger ne Norfolk Island nf Nigeria ng Nicaragua ni Netherlands nl Norway no Nepal np Nauru nr Oman om Panama pa Peru pe French Polynesia pf Papua New Guinea pg Philippines ph Pakistan pk Poland pl Pitcairn Islands pn Puerto Rico pr Palestine ps Palau pw Paraguay py Qatar qa Réunion re Romania ro Serbia rs Russia ru Rwanda rw Solomon Islands sb Seychelles sc Sudan sd Sweden se Singapore sg Slovenia si Slovakia sk Sierra Leone sl San Marino sm Senegal sn Somalia so Suriname sr South Sudan ss São Tomé and Príncipe st El Salvador sv Syria sy Eswatini sz Turks and Caicos Islands tc Chad td Togo tg Thailand th Tokelau tk East Timor tl Tunisia tn Tonga to Turkey tr Tuvalu tv Tanzania tz Ukraine ua Uganda ug Uruguay uy Vatican City va Venezuela ve British Virgin Islands vg United States Virgin Islands vi Vietnam vn Wallis and Futuna wf Samoa ws Yemen ye Mayotte yt South Africa za Zambia zm Zimbabwe zw Congo (Brazzaville) cg Congo (Kinshasa) cd Mozambique mz Guernsey gg Gambia gm Northern Mariana Islands mp Ethiopia et New Caledonia nc Vanuatu vu French Southern Territories tf Niue nu United States Minor Outlying Islands um Cook Islands ck United Kingdom gb Trinidad and Tobago tt Saint Vincent and the Grenadines vc Taiwan tw New Zealand nz Saudi Arabia sa Laos la North Korea kp South Korea kr Portugal pt Kyrgyzstan kg Kazakhstan kz Tajikistan tj Turkmenistan tm Uzbekistan uz Saint Kitts and Nevis kn Saint Pierre and Miquelon pm Saint Helena sh Saint Lucia lc Mauritius mu Ivory Coast ci Kenya ke Mongolia mn</p><h3>Fixed IP</h3><p>Similar to the above content, we can achieve a fixed IP for a period of time by adding session in the username followed by a 5-digit fixed number. The effective period is about 10 minutes.</p><p>For example, if you want to achieve a fixed IP for a period of time, and the original username is 1f78266a, you can change the username to 1f78266a-session-12345, where 12345 remains the same, thus the IP will remain unchanged for a period of time. The above curl command can be rewritten as follows:</p><pre>curl -x 1f78266a-session-12345:eff0896726224fa2a99fe82dd1f07562@global.proxy.acedata.cloud:30007 https://ipinfo.io</pre><h3>Purchase More</h3><p>If your package has run out, you need to purchase more to continue using the proxy service.</p><p>To purchase more, please go to the “<a href="https://platform.acedata.cloud/services/87ae4a5a-59d9-4c50-86d4-c0b5d393e5af">Application Page</a>” and directly click the “Purchase More” button to make a selection. The more you buy at one time, the cheaper the unit price.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2d33414dba9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build your own AI application site in ten minutes with Vercel]]></title>
            <link>https://medium.com/@jun.xu708/build-your-own-ai-application-site-in-ten-minutes-with-vercel-028194323839?source=rss-83cb5733d394------2</link>
            <guid isPermaLink="false">https://medium.com/p/028194323839</guid>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Jun Xu]]></dc:creator>
            <pubDate>Mon, 02 Sep 2024 03:53:41 GMT</pubDate>
            <atom:updated>2024-09-02T03:53:41.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quickly Set Up the Nexior AI Platform Using Vercel</h3><p><a href="https://github.com/AceDataCloud/Nexior">Nexior</a> is an open-source project on GitHub. With it, we can deploy our own AI application site with one click, including AI Q&amp;A, Midjourney drawing, knowledge base Q&amp;A, artistic QR codes, and other applications. It requires no AI system development, AI account procurement, API support concerns, or payment system configuration, offering zero startup costs and risk-free AI revenue generation.</p><p>This article will introduce the deployment process of the Nexior project on Vercel, allowing you to set up your own AI site in just a few minutes without any programming skills and easily earn income from it.</p><h3>Preparation</h3><p>First, open the Nexior GitHub repository at: <a href="https://github.com/AceDataCloud/Nexior">https://github.com/AceDataCloud/Nexior</a>. Then, register or log in to your GitHub account, click Fork, and clone the code to your local repository as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*btbqUNDvfTq9s6Tc.png" /></figure><p>After forking, you will get your personal repository as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D7hHZ-_nF-bjCcKZ.png" /></figure><p>The example account here is Germey, so you can see that we have forked it to the Germey user, with a forked from <a href="https://github.com/AceDataCloud/Nexior">AceDataCloud/Nexior</a> label. This completes the preparation.</p><h3>Vercel Deployment</h3><p>Vercel is a platform that helps quickly deploy project websites. We can use it to directly connect with the GitHub repository and quickly deploy the source code of the GitHub repository online. Below is the process for deploying the Nexior project on Vercel.</p><p>Open <a href="https://vercel.com/">https://vercel.com/</a> and log in using GitHub.</p><p>You will see a page similar to the one below. Click the Import button as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KJaEXCSA0o3qufiq.png" /></figure><p>At this point, Vercel will display your GitHub repositories. Select the Nexior repository you just forked, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t9TQKPCsEGxDquQ3.png" /></figure><p>After finding the Nexior repository, click the Import button to import it.</p><p>Next, a configuration page will pop up. Keep the default configuration and click the Deploy button, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fxxCzufoWkBNYSeH.png" /></figure><p>After clicking Deploy, Vercel will start building and deploying the entire project. No action is needed from you, just wait for about 1–2 minutes, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dKcDJSJkAHTa3mOB.png" /></figure><p>Once the deployment is complete, Vercel will pop up a page congratulating you on the successful deployment. You have now successfully deployed the Nexior project to your online environment, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-JC4YwQgvnMvYZ5v.png" /></figure><p>Click Continue to Dashboard, and you will see the preview domain name generated by Vercel for you, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XsWx7AW2QioLfDpR.png" /></figure><p>Now, open this link. For example, the sample address here is <a href="https://nexior-germeys-projects.vercel.app/">https://nexior-germeys-projects.vercel.app/</a>. After opening it, you can see the running status of the Nexior project.</p><p>After opening it, register and log in, either with email or GitHub. After logging in, you will see a configuration page, such as Site Configuration, where you can modify the title, logo, favicon, administrator, and other information of the site, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w9VRx1WX-jBroIzx.png" /></figure><p>There is also an important part: the distribution promotion configuration, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PuoO5usFR5xph7QR.png" /></figure><p>Here, you can modify two pieces of information: Default Inviter ID and Forced Inviter ID. The explanations are as follows:</p><ul><li>Default Inviter ID: If only the default inviter ID is set, anyone can distribute and promote the site. Whoever invites customers will receive the rebate from the customer’s consumption. If the URL of the site does not contain any promotion information (no inviter_id in the URL), registered users will be bound to this default inviter ID by default. Initially, this ID is the personal ID of the site owner.</li><li>Forced Inviter ID: If a forced inviter ID is set, no one other than the forced inviter can receive distribution rebates from the site, and the distribution promotion entrance will not be visible in the background. All registered users of the site will be bound to this forced inviter, and all consumption rebates will go to the forced inviter.</li></ul><p>Therefore, the choice between these two modes depends on the promotion strategy of the site owner and is situation-dependent.</p><p>Another configuration option is feature switches, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/0*T2kRuT7el74pA75H.png" /></figure><p>Currently, Nexior provides multiple functions, and the site owner can selectively enable or disable certain specific functions.</p><h3>Custom Domain</h3><p>Now that we have successfully deployed a site, the domain name is a subdomain assigned by Vercel, which is not conducive to external promotion. If we can change it to our custom domain, it will be much better.</p><p>For example, I have a domain <a href="https://chictem.com/">https://chictem.com</a>. Here’s how to configure a custom domain.</p><blockquote>If you don’t have a domain, you can register one with major domain providers such as <a href="https://www.namecheap.com/">namecheap</a> or <a href="https://godaddy.com/">Godaddy</a>, or with some domestic service providers in China.</blockquote><p>Next, open the custom domain configuration page of Vercel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8M5wRhtGvJolF9bh.png" /></figure><p>Enter the custom domain you want to configure here. For example, if you want to configure <a href="https://chictem.com/">https://chictem.com</a>, just enter chictem.com without the https:// prefix and click Add:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qJSEF2qztdu9SYvT.png" /></figure><p>Next, Vercel will prompt you to choose the domain configuration option. It is recommended to add a www prefix domain as well. This is optional. Adding it allows the www-prefixed domain to also access this site. Here, we directly choose the last option to add the root domain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zxRxa6gkpaU4RDfw.png" /></figure><p>Once confirmed, we find a prompt indicating a DNS to be configured:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZXlUZ-SxTSrqF56_.png" /></figure><p>Here, we are asked to add an A record pointing to 76.76.21.21. At this point, we need to go to the domain service provider to configure the DNS.</p><blockquote>Note: The domain service provider depends on where you purchased your domain. Generally, the site where you bought your domain will have a DNS configuration entry in the backend.</blockquote><p>Below is a sample DNS backend configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*30ksDsHdP26AA_PW.png" /></figure><p>Once configured, we can access the newly configured website using a custom domain, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nER9HVGMEgnLF5ST.png" /></figure><blockquote>Note: After configuring the new domain, remember that we need to go to the site configuration page to reconfigure site options such as the title and logo because these configurations are bound to the domain. When a new domain is enabled, the site needs to be newly configured.</blockquote><h3>Code Updates</h3><p>Since Nexior’s source code is continuously updated, with new features or bug fixes, the code will be directly synced to the source code repository <a href="https://github.com/AceDataCloud/Nexior">https://github.com/AceDataCloud/Nexior</a>.</p><p>So, how do we synchronize the latest code updates for our deployed site?</p><p>It’s straightforward. Go back to the code repository we Forked on GitHub. Here, you will see that the code repository we originally Forked is several versions behind the official Nexior source code. We can directly click the Sync fork button, then click Update branch:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AkZGndYL9_m_iSdg.png" /></figure><p>Once clicked, the code in our forked repository will be updated. After the code is updated, the website on Vercel will also automatically update. Wait a moment, refresh the webpage, and you will see the site updated.</p><h3>Earning Income</h3><p>Now that we have a custom domain and have configured the above content, we can share this site to start earning money.</p><p>All users with a paid bill will have a portion converted into earnings that reach the distributor’s account. Then, just add customer service for withdrawal.</p><p>Enter the distribution interface to check the current number of invites, total distribution amount, total rewards, etc., at any time. Simply add customer service for withdrawal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=028194323839" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use MidJourney API in detail]]></title>
            <link>https://medium.com/@jun.xu708/how-to-use-midjourney-api-in-detail-34635185c1e9?source=rss-83cb5733d394------2</link>
            <guid isPermaLink="false">https://medium.com/p/34635185c1e9</guid>
            <category><![CDATA[midjourney]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Jun Xu]]></dc:creator>
            <pubDate>Fri, 30 Aug 2024 12:12:59 GMT</pubDate>
            <atom:updated>2024-08-30T12:30:25.347Z</atom:updated>
            <content:encoded><![CDATA[<h3>Midjourney Imagine API Application and Use</h3><p>Midjourney is a very powerful AI drawing tool that can generate exquisite images in just a minute or two by inputting keywords. With its outstanding drawing capabilities, Midjourney stands out in the industry and is now widely applied across various industries and fields, with its influence becoming increasingly significant.</p><p>This document mainly introduces the usage process of the Imagine operation in the Midjourney API, which allows us to easily generate the required images from text.</p><h3>Trial Link</h3><p>You can register our <a href="https://surl.id/1uHAKZJLhT">website</a> and have a trial, we provide user interface and API, if you want to use our API, send me email: jun.xu708@gmail.com .</p><h3>Application Process</h3><p>To use the Midjourney Imagine API, first visit the <a href="https://platform.acedata.cloud/documents/e52c028d-897a-4d51-b110-60fccbe6118d">Midjourney Imagine API</a> page and click the “Acquire” button to obtain the credentials needed for the request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MUHqBtOGICQsk4_H.png" /></figure><p>If you have not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in. After logging in or registering, you will be automatically returned to the current page.</p><p>On your first application, a free quota will be provided, allowing you to use the API for free.</p><h3>Basic Use</h3><p>Next, you can fill in the corresponding content on the interface, as shown in the figure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8W9LwCUQxFKmSKhd.png" /></figure><p>When using this interface for the first time, we need to fill in at least two pieces of information: one is authorization, which can be selected directly from the dropdown list. The other parameter is prompt, which is the description of the image we want to generate. It is recommended to describe it in English for more accurate results. Here we used the example content Lamborghini speeds inside a volcano, which indicates that we want to draw a Lamborghini speeding inside a volcano.</p><p>You can also notice that there is corresponding code generation on the right side, and you can copy the code to run directly or click the “Try” button for testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*LJ7nKZ6J3cARm_EM.png" /></figure><p>After the call, we find the returned result as follows:</p><pre>{<br>  &quot;imageurl&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1233387694839697411/1234197197067915365/36rgqit64j90qptsxnyq_Lamborghini_speeds_inside_a_volcano_id0494f47263b6-ff92-44a3-88ee-51cf0e706aae.png?ex=662fdb36&amp;is=662e89b6&amp;hm=ca9be54907726937ed02517a13466bef2afb2825b7cda4b313de56a3c3310d0d&amp;width=1024&amp;height=1024&quot;,<br>  &quot;image_width&quot;: 1024,<br>  &quot;image_height&quot;: 1024,<br>  &quot;image_id&quot;: &quot;1234197197067915365&quot;,<br>  &quot;rawimage_url&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1233387694839697411/1234197197067915365/36rgqit64j90qptsxnyq_Lamborghini_speeds_inside_a_volcano_id0494f47263b6-ff92-44a3-88ee-51cf0e706aae.png?ex=662fdb36&amp;is=662e89b6&amp;hm=ca9be54907726937ed02517a13466bef2afb2825b7cda4b313de56a3c3310d0d&amp;&quot;,<br>  &quot;rawimagewidth&quot;: 2048,<br>  &quot;rawimageheight&quot;: 2048,<br>  &quot;progress&quot;: 100,<br>  &quot;actions&quot;: [<br>    &quot;upscale1&quot;,<br>    &quot;upscale2&quot;,<br>    &quot;upscale3&quot;,<br>    &quot;upscale4&quot;,<br>    &quot;reroll&quot;,<br>    &quot;variation1&quot;,<br>    &quot;variation2&quot;,<br>    &quot;variation3&quot;,<br>    &quot;variation4&quot;<br>  ],<br>  &quot;task_id&quot;: &quot;1bae3bec-3ac4-4180-a148-74ee6cb68b98&quot;,<br>  &quot;success&quot;: true<br>}</pre><p>The returned result has several fields, described as follows:</p><ul><li>task_id: the ID of the task generating this image, used to uniquely identify this image generation task.</li><li>image_id: the unique identifier of the image, which needs to be passed when performing transformation operations on the image next time.</li><li>image_url: the URL of the thumbnail, which can be directly opened to view the generated effect.</li><li>image_width: the pixel width of the thumbnail.</li><li>image_height: the pixel height of the thumbnail.</li><li>raw<em>image</em>url: the URL of the original image, which has the same content as the thumbnail but is of higher definition and will load a bit slower.</li><li>raw<em>image</em>width: the pixel width of the original image.</li><li>raw<em>image</em>height: the pixel height of the original image.</li><li>actions: a list of further operations that can be performed on the generated image. Here a total of 8 options are listed, where upscale means to enlarge, and variation means to transform. So upscale1 represents the enlargement operation for the first image in the top left, while variation3 represents the transformation operation based on the third image in the bottom left.</li></ul><p>By opening the link corresponding to image<em>url or </em><em>raw_image</em>url, we can see the result as shown in the figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lR9RnIj_1awOgAyt.png" /></figure><p>It can be seen that a 2x2 preview image has been generated here. As of now, the first API call has been completed.</p><h3>Image Upscaling and Transformation</h3><p>Next, we will try to perform further operations on the currently generated photo. For example, if we think the second image in the top right is quite good but we want to make some transformations, we can fill in the action as variation2 and pass the image_id:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tnD1pMNDmGyfEvRS.png" /></figure><p>At this point, the result obtained is as follows:</p><pre>{<br>  &quot;imageurl&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1233387694839697411/1234201336543969401/36rgqit64j90qptsxnyq_Lamborghini_speeds_inside_a_volcano_id049410dc56a7-ec16-4bac-878e-2338f2ae5f5d.png?ex=662fdf10&amp;is=662e8d90&amp;hm=9aec96bca35ae20b6f9ab536101b9c4ea255eb6216cbf7000ac554937da071f3&amp;width=1024&amp;height=1024&quot;,<br>  &quot;image_width&quot;: 1024,<br>  &quot;image_height&quot;: 1024,<br>  &quot;image_id&quot;: &quot;1234201336543969401&quot;,<br>  &quot;rawimage_url&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1233387694839697411/1234201336543969401/36rgqit64j90qptsxnyq_Lamborghini_speeds_inside_a_volcano_id049410dc56a7-ec16-4bac-878e-2338f2ae5f5d.png?ex=662fdf10&amp;is=662e8d90&amp;hm=9aec96bca35ae20b6f9ab536101b9c4ea255eb6216cbf7000ac554937da071f3&amp;&quot;,<br>  &quot;rawimagewidth&quot;: 2048,<br>  &quot;rawimageheight&quot;: 2048,<br>  &quot;progress&quot;: 100,<br>  &quot;actions&quot;: [<br>    &quot;upscale1&quot;,<br>    &quot;upscale2&quot;,<br>    &quot;upscale3&quot;,<br>    &quot;upscale4&quot;,<br>    &quot;reroll&quot;,<br>    &quot;variation1&quot;,<br>    &quot;variation2&quot;,<br>    &quot;variation3&quot;,<br>    &quot;variation4&quot;<br>  ],<br>  &quot;task_id&quot;: &quot;f4961620-1104-409f-9dc1-ba3ed15c2f4d&quot;,<br>  &quot;success&quot;: true<br>}</pre><p>By opening image_url, the newly generated image is shown as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qsSFKVMpUP7Iiwdl.png" /></figure><p>As we can see, regarding the image in the upper right corner of the last picture, we have obtained four similar photos again.</p><p>At this time, we can select one of them for a refined enlargement operation, for example, if we choose the fourth one, we can pass action as upscale4, and pass the current image&#39;s ID again through image_id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rnUiFsPzPj2-8rC6.png" /></figure><blockquote>Note: The upscale operation takes less time compared to variation in Midjourney.</blockquote><p>The return result is as follows:</p><pre>{<br>  &quot;imageurl&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1233387694839697411/1234202545208033400/36rgqit64j90qptsxnyq_Lamborghini_speeds_inside_a_volcano_id049434edc3f5-2bd0-4f5b-a372-03270b02289b.png?ex=662fe031&amp;is=662e8eb1&amp;hm=f8006c4d33a03dfd027dffe4eb46ab0d113a4910aef07497f0b335c8998b7858&amp;width=512&amp;height=512&quot;,<br>  &quot;image_width&quot;: 512,<br>  &quot;image_height&quot;: 512,<br>  &quot;image_id&quot;: &quot;1234202545208033400&quot;,<br>  &quot;rawimage_url&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1233387694839697411/1234202545208033400/36rgqit64j90qptsxnyq_Lamborghini_speeds_inside_a_volcano_id049434edc3f5-2bd0-4f5b-a372-03270b02289b.png?ex=662fe031&amp;is=662e8eb1&amp;hm=f8006c4d33a03dfd027dffe4eb46ab0d113a4910aef07497f0b335c8998b7858&amp;&quot;,<br>  &quot;rawimagewidth&quot;: 1024,<br>  &quot;rawimageheight&quot;: 1024,<br>  &quot;progress&quot;: 100,<br>  &quot;actions&quot;: [<br>    &quot;upscale_2x&quot;,<br>    &quot;upscale_4x&quot;,<br>    &quot;variation_subtle&quot;,<br>    &quot;variation_strong&quot;,<br>    &quot;zoomout2x&quot;,<br>    &quot;zoomout_15x&quot;,<br>    &quot;pan_left&quot;,<br>    &quot;pan_right&quot;,<br>    &quot;pan_up&quot;,<br>    &quot;pan_down&quot;<br>  ],<br>  &quot;task_id&quot;: &quot;03f62b17-a6f1-4c8e-9b4d-1fc7bd5b1180&quot;,<br>  &quot;success&quot;: true<br>}</pre><p>Among them, the image_url is shown as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*AysH9FL78LwwOPuL.png" /></figure><p>Thus, we have successfully obtained a photo of a Lamborghini.</p><p>At the same time, note that the actions contain several available operations, as described below:</p><ul><li>upscale_2x: enlarge the image 2 times to obtain a 2x high-definition image.</li><li>upscale_4x: enlarge the image 4 times to obtain a 4x high-definition image.</li><li>zoom<em>out</em>2x: reduce the image size by two times (surrounding area filled).</li><li>zoom<em>out_1</em>5x: reduce the image size by 1.5 times (surrounding area filled).</li><li>pan_left: shift the image to the left.</li><li>pan_right: shift the image to the right.</li><li>pan_up: shift the image upward.</li><li>pan_down: shift the image downward.</li></ul><p>You can continue to input the corresponding transformation commands for continuous image generation operations.</p><h3>Image Rewrite (Base Image)</h3><p>This API also supports image rewriting, commonly known as base image, where we can input an image URL and a descriptive text to be rewritten, and the API can return the rewritten image.</p><blockquote>Note: The input image URL must be a pure image and cannot be a webpage displaying an image, otherwise image rewriting will not be possible. It is recommended to use an image hosting service to upload and obtain the image URL.</blockquote><p>For example, here we have an image of a sunset on the highway, with some trees and buildings beside the road, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FN80LL2qFhBq7ePF.png" /></figure><p>Now we want to rewrite it to a beachside scene with a car parked by the roadside. We can construct the following prompt:</p><pre>https://cdn.acedata.cloud/v014oc.png an illustration of a car parked on the beach --iw 2</pre><p>As we can see, the beginning of our prompt is an HTTPS image link followed by a space and the descriptive content. Here we have also used an additional advanced parameter, such as —iw 2 to adjust the weight of the image.</p><p>We can pass the above content as a whole to the prompt field, as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5HJ_1KXo6JL7W-oL.png" /></figure><p>The output result is as follows:</p><pre>{<br>  &quot;imageurl&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1234427310434947145/1234539663515975690/atmateosa5693_An_illustration_of_a_car_parked_on_the_beach_id26cc8650ec-7e4b-4685-8911-78172430d8a7.png?ex=66311a28&amp;is=662fc8a8&amp;hm=c39707a1f22bc7f12874060ea6ed58ba37c188139ccc9a13c61ed9f37e66ea74&amp;width=1456&amp;height=816&quot;,<br>  &quot;image_width&quot;: 1456,<br>  &quot;image_height&quot;: 816,<br>  &quot;image_id&quot;: &quot;1234539663515975690&quot;,<br>  &quot;rawimage_url&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1234427310434947145/1234539663515975690/atmateosa5693_An_illustration_of_a_car_parked_on_the_beach_id26cc8650ec-7e4b-4685-8911-78172430d8a7.png?ex=66311a28&amp;is=662fc8a8&amp;hm=c39707a1f22bc7f12874060ea6ed58ba37c188139ccc9a13c61ed9f37e66ea74&amp;&quot;,<br>  &quot;rawimagewidth&quot;: 2912,<br>  &quot;rawimageheight&quot;: 1632,<br>  &quot;progress&quot;: 100,<br>  &quot;actions&quot;: [<br>    &quot;upscale1&quot;,<br>    &quot;upscale2&quot;,<br>    &quot;upscale3&quot;,<br>    &quot;upscale4&quot;,<br>    &quot;reroll&quot;,<br>    &quot;variation1&quot;,<br>    &quot;variation2&quot;,<br>    &quot;variation3&quot;,<br>    &quot;variation4&quot;<br>  ],<br>  &quot;task_id&quot;: &quot;24a79e8b-a79d-471a-aef7-089dc0627ee8&quot;,<br>  &quot;success&quot;: true<br>}</pre><p>At this point, we have obtained the following generated image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VsHXMUYa3LC49XhT.png" /></figure><p>As we can see, while maintaining the original overall style and composition of the image, the entire scene has transformed into a beachside, with a car appearing on the road, which is the Prompt with Image.</p><h3>Image Fusion</h3><p>This API also supports image fusion, allowing us to input multiple images to achieve different image fusion effects.</p><p>For instance, here we have two images, one of a teddy bear and the other of a chainsaw, shown respectively below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QP0KkyE5gWPwe64G.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PAVUJptHpYKAadwk.png" /></figure><p>Now we want to merge the two, making this bear hold this chainsaw. How do we do it?</p><p>We can construct the following prompt:</p><pre>https://cdn.acedata.cloud/8fapzl.png https://cdn.acedata.cloud/c1igbw.png The bear is holding the chainsaw --iw 2</pre><p>As we can see, similar to Image with Prompt, we have placed multiple image URLs at the beginning of the prompt, separated by spaces, and finally added the text prompt, passing the above content as a whole to the prompt parameter. The running effect is as follows:</p><pre>{<br>  &quot;imageurl&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234547236830973972/kcisok_The_bear_is_holding_the_chainsaw_id8873344ad605bc4-ba19-4807-b94f-367dab672f7a.png?ex=66312136&amp;is=662fcfb6&amp;hm=0fb1e2261c9a30b04de9da9b23b7562eb73677f1bbda1fae52c7243b12d25aac&amp;width=1024&amp;height=1024&quot;,<br>  &quot;image_width&quot;: 1024,<br>  &quot;image_height&quot;: 1024,<br>  &quot;image_id&quot;: &quot;1234547236830973972&quot;,<br>  &quot;rawimage_url&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234547236830973972/kcisok_The_bear_is_holding_the_chainsaw_id8873344ad605bc4-ba19-4807-b94f-367dab672f7a.png?ex=66312136&amp;is=662fcfb6&amp;hm=0fb1e2261c9a30b04de9da9b23b7562eb73677f1bbda1fae52c7243b12d25aac&amp;&quot;,<br>  &quot;rawimagewidth&quot;: 2048,<br>  &quot;rawimageheight&quot;: 2048,<br>  &quot;progress&quot;: 100,<br>  &quot;actions&quot;: [<br>    &quot;upscale1&quot;,<br>    &quot;upscale2&quot;,<br>    &quot;upscale3&quot;,<br>    &quot;upscale4&quot;,<br>    &quot;reroll&quot;,<br>    &quot;variation1&quot;,<br>    &quot;variation2&quot;,<br>    &quot;variation3&quot;,<br>    &quot;variation4&quot;<br>  ],<br>  &quot;task_id&quot;: &quot;891f2645-ee15-4c7b-ac24-d98163c8e57e&quot;,<br>  &quot;success&quot;: true<br>}</pre><p>We have obtained the following result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AwNj8M0QYZ1TiBEC.png" /></figure><p>As we can see, we have successfully achieved the image fusion.</p><blockquote>Note: The image fusion supports a maximum of 5 image URLs as input, which means it can support a maximum of 5 images fused together, with the input format as above.</blockquote><h3>Local Transformation</h3><p>This API also supports the local painting function of images, but only for images generated under the above content. We can pass in the unique ID of the generated image, the behavior parameter action for local redrawing, and the mask of the area that needs to be redrawn to achieve redrawing in that masked area.</p><p>For example, here we have a generated image of a cat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*QcyiIusYoG8RQZNP" /></figure><p>Now we want to redraw this cat’s face, how do we do it?</p><p>First, we need to obtain the mask of that area; this mask is obtained through Base64 encoding of a grayscale image. Below are some tools and code to obtain the mask:</p><p>Python code example to obtain the mask:</p><pre>import sys<br>import os<br>from PySide6.QtWidgets import *<br>from PySide6.QtGui import QPainter, QMouseEvent, QPen, QColor, QImage<br>from PySide6.QtCore import Qt, QPoint<br> <br>class DrawingWidget(QWidget):<br>    def _init_(self, imagePath):<br>        super()._init_()<br>        self.setAttribute(Qt.WA_StaticContents)<br>        self.background_image = QImage(imagePath)<br>        imageSize = self.background_image.size()*0.8<br>        self.setFixedSize(imageSize)<br>        self.foregroundimage = QImage(self.size(), QImage.FormatARGB32)<br>        self.foreground_image.fill(Qt.transparent)<br>        self.drawing = False<br>        self.lastPoint = QPoint()<br>        self.pen_color = QColor(255, 255, 255, 255)<br>        self.pen_size = 50<br> <br>    def setpensize(self, size):<br>        self.pen_size = size<br> <br>    def mousePressEvent(self, event: QMouseEvent):<br>        if event.button() == Qt.LeftButton:<br>            self.drawing = True<br>            self.lastPoint = event.pos()<br> <br>    def mouseMoveEvent(self, event: QMouseEvent):<br>        if event.buttons() &amp; Qt.LeftButton and self.drawing:<br>            painter = QPainter(self.foreground_image)<br>            painter.setRenderHint(QPainter.Antialiasing, True)<br>            pen = QPen(self.pencolor, self.pensize,<br>                       Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)<br>            painter.setPen(pen)<br>            painter.drawLine(self.lastPoint, event.pos())<br>            self.lastPoint = event.pos()<br>            self.update()<br> <br>    def mouseReleaseEvent(self, event: QMouseEvent):<br>        if event.button() == Qt.LeftButton and self.drawing:<br>            self.drawing = False<br> <br>    def paintEvent(self, event):<br>        canvasPainter = QPainter(self)<br>        canvasPainter.drawImage(<br>            self.rect(), self.backgroundimage, self.backgroundimage.rect())<br>        canvasPainter.drawImage(<br>            self.rect(), self.foregroundimage, self.foregroundimage.rect())<br> <br>    def save_image(self, path):<br>        self.foreground_image.save(path)<br> <br>class MainWindow(QDialog):<br>    def _init_(self, imagePath):<br>        super()._init_()<br>        self.setWindowTitle(&quot;mask tool&quot;)<br>        self.drawing_widget = DrawingWidget(imagePath)<br>        self.currentPath = os.getcwd().replace(&quot;\\&quot;, &quot;/&quot;)<br>        self.tempPath = self.currentPath + &quot;/temp.jpg&quot;<br>        self.projectPath = &quot;&quot;<br>        self.setDone = False<br> <br>    def init_ui(self):<br>        layout = QVBoxLayout()<br>        layout.addWidget(self.drawing_widget)<br>        controls_layout = QHBoxLayout()<br>        size_label = QLabel(&quot;pen size:&quot;)<br>        controlslayout.addWidget(sizelabel)<br>        self.size_slider = QSlider(Qt.Horizontal)<br>        self.size_slider.setMinimum(100)<br>        self.size_slider.setMaximum(400)<br>        self.size_slider.setValue(400)<br>        self.sizeslider.valueChanged.connect(self.update_pensize)<br>        controlslayout.addWidget(self.sizeslider)<br>        self.lineEdit_addPromp = QLineEdit()<br>        layout.addWidget(self.lineEdit_addPromp)<br>        save_button = QPushButton(&quot;   Start partial redrawing   &quot;)<br>        savebutton.clicked.connect(self.saveimage)<br>        controlslayout.addWidget(savebutton)<br>        dont_button = QPushButton(&quot;   Cancel partial redraw   &quot;)<br>        dontbutton.clicked.connect(self.dontimage)<br>        controlslayout.addWidget(dontbutton)<br>        layout.addLayout(controls_layout)<br>        self.setLayout(layout)<br> <br>    def updatepensize(self):<br>        size = self.size_slider.value()<br>        self.drawingwidget.set_pensize(size)<br> <br>    def save_image(self):<br>        tempImage = self.currentPath + &quot;/temp.jpg&quot;<br>        self.drawingwidget.saveimage(self.tempPath)<br>        self.prompt = self.lineEdit_addPromp.text()<br>        self.setDone = True<br>        self.close()<br> <br>    def dont_image(self):<br>        self.setDone = False<br>        self.close()<br> <br>    def closeEvent(self, event):<br>        if self.setDone:<br>            pass<br>        else:<br>            self.setDone = False<br>        event.accept()<br> <br>if _name__ == &#39;__main_&#39;:<br>    imagePath = &quot;test.png&quot;<br>    app = QApplication(sys.argv)<br>    mainWindow = MainWindow(imagePath)<br>    mainWindow.init_ui()<br>    mainWindow.exec()</pre><p>By using the above code, we can obtain the mask image. During this process, we need to ensure that the mask image has the same dimensions as the original image, and the white area in the mask image is the area that needs to be redrawn. Below is a comparison between the mask image that needs to be redrawn from the cat image and the original image:</p><p>Original image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*LggbFXU5d_cppXU-.png" /></figure><p>Mask image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*dLIBRja5t21qT_G1.png" /></figure><p>Finally, we also need to convert the mask image into a Base64-encoded format. Below is the code for converting to Base64 encoding:</p><pre>import cv2<br>import base64<br> <br>image_path = &#39;temp.jpg&#39;<br>grayimage = cv2.imread(imagepath)<br>, buffer = cv2.imencode(&#39;.jpg&#39;, grayimage)<br>base64_encoded = base64.b64encode(buffer).decode(&#39;utf-8&#39;)<br>with open(&#39;grayscaleimagebase64.txt&#39;, &#39;w&#39;) as f:<br>    f.write(base64_encoded)<br> <br>print(&quot;success!&quot;)</pre><blockquote>Note: The above Python code describes the process of generating a mask. If you want to integrate it into your product, please write the corresponding code in the appropriate language based on its principles.</blockquote><p>Through the above code, we have obtained the mask mask that needs to be redrawn. Next, we also need to set the parameter action to variation<em>region, generate the image ID </em><em>image</em>id (refer to the content above for how to obtain this parameter), and pass the corresponding mask mask. The other parameter information is as follows:</p><ul><li>action: The action performed on the image, here it is variation_region, indicating partial redrawing of the image.</li><li>prompt: Descriptive words for partially redrawing the image (optional parameter).</li><li>image_id: The unique identifier of the image for easy partial redrawing.</li><li>mask: The base64 encoding of the mask area corresponding to the image (the image is specified by the above image_id).</li></ul><p>Therefore, based on the above rules, we need to set the correct parameters. The parameter prompt is a non-mandatory parameter; here, for ease of comparison, the mask area&#39;s prompt is set to A cute cat. The specific parameter settings are shown in the figure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/0*7hR9IGGzlxNZEFlV.png" /></figure><h3>Code Example</h3><p>It can be seen that various language codes have been automatically generated on the right side of the page, as shown in the figure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*PPyLtG4i3uwdN-5I.png" /></figure><p>Some code examples are as follows:</p><h3>Response Example</h3><p>After a successful request, the API will return the result information of the face-swapped backend image. For example:</p><pre>{<br>  &quot;image_url&quot;: &quot;https://platform.cdn.acedata.cloud/midjourney/6c9450d8-1c22-4f85-a527-e7a7bfb4a61b.png?imageMogr2/thumbnail/!50p&quot;,<br>  &quot;image_width&quot;: 1024,<br>  &quot;image_height&quot;: 1024,<br>  &quot;actions&quot;: [<br>    &quot;upscale1&quot;,<br>    &quot;upscale2&quot;,<br>    &quot;upscale3&quot;,<br>    &quot;upscale4&quot;,<br>    &quot;reroll&quot;,<br>    &quot;variation1&quot;,<br>    &quot;variation2&quot;,<br>    &quot;variation3&quot;,<br>    &quot;variation4&quot;<br>  ],<br>  &quot;rawimageurl&quot;: &quot;https://platform.cdn.acedata.cloud/midjourney/6c9450d8-1c22-4f85-a527-e7a7bfb4a61b.png&quot;,<br>  &quot;rawimagewidth&quot;: 2048,<br>  &quot;rawimageheight&quot;: 2048,<br>  &quot;progress&quot;: 100,<br>  &quot;image_id&quot;: &quot;1265876571323891712&quot;,<br>  &quot;task_id&quot;: &quot;6c9450d8-1c22-4f85-a527-e7a7bfb4a61b&quot;,<br>  &quot;success&quot;: true<br>}</pre><p>It can be seen that this is a redrawing operation on the image of the mask area, and the returned results are consistent with the content above, as shown in the results below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E_z1kLNtRdCb0EAA.png" /></figure><p>It can be seen that we have successfully achieved partial redrawing in the custom area of the generated image.</p><h4>CURL</h4><pre>curl -X POST &#39;https://api.acedata.cloud/midjourney/imagine&#39; \<br>-H &#39;accept: application/json&#39; \<br>-H &#39;authorization: Bearer {token}&#39; \<br>-H &#39;content-type: application/json&#39; \<br>-d &#39;{<br>  &quot;prompt&quot;: &quot;A cute cat &quot;,<br>  &quot;action&quot;: &quot;variation_region&quot;,<br>  &quot;image_id&quot;: &quot;1265875488702726144&quot;,<br>  &quot;mask&quot;: &quot;/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAGaAZoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+f+iiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigA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mTy/MjzjGRnNAH8J9Fb3i7wj4q8C+KtU8DeM/DWoaNrmiX8llq+k6nYyW9zYXMUhjkhljkxJFLG/7sxkZBBzjFYNABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAfpP/AMG73/BaG3/4Jd/tCXnw4+PHiPXpvgh47UJ4isbJ/Pg8Pap+5EWvJbeWZJPLjjMU0duY5JYmEmLmS1toT/VR8I/i58MPjn4Asfij8G/iVoPi/wAN6o039n+IfDOrxahYXRimkil8m5hJilEcsckeQTzGc81/BhX64/8ABs//AMFu/jD+yJ8efB//AAT1+KKaj4t+FnxK8XWmi+FrFLnNz4P1m/ulijktfMbH2Ka4lH2m2zwZDcxfvfOiugD+ouiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigA<br>#### Python<br> <br>```python<br>import requests <br> <br>url = &quot;https://api.acedata.cloud/midjourney/imagine&quot; <br> <br>headers = {<br>    &quot;accept&quot;: &quot;application/json&quot;,<br>    &quot;authorization&quot;: &quot;Bearer {token}&quot;,<br>    &quot;content-type&quot;: &quot;application/json&quot;<br>} <br> <br>payload =<br>{<br>    &quot;prompt&quot;: &quot;A cute cat &quot;,<br>    &quot;action&quot;: &quot;variation_region&quot;,<br>    &quot;image_id&quot;: &quot;1265875488702726144&quot;,<br>    &quot;mask&quot;: &quot;/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAGaAZoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+f+iiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiv12/4Jcf8GoX7XX7X+nab8af2y9Tvfgt4GmvZYZPDOpaHI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iigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAC<br>```python<br>response = requests.post(url, json=payload, headers=headers)<br>print(response.text)</pre><h3>Asynchronous Callback</h3><p>Since generating images with Midjourney requires some waiting time, this API is also designed for long wait mode by default. However, in some scenarios, long waiting may incur additional resource overhead, so this API also provides an asynchronous webhook callback method. When the image generation is successful or fails, the results will be sent to the specified webhook callback URL via HTTP requests. After the callback URL receives the results, further processing can be done.</p><p>The specific calling process is demonstrated below.</p><p>First, the webhook callback is a service that can receive HTTP requests, and developers should replace it with the URL of their own HTTP server. For demonstration purposes, a public webhook sample site <a href="https://webhook.site/">https://webhook.site/</a> is used. Opening this site will provide a webhook URL, as shown in the image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7kpNd2NN1J5td7SL.png" /></figure><p>Copy this URL, and it can be used as a webhook. The sample here is <a href="https://webhook.site/995d0a91-d737-40a7-a3b9-5baf68ed924c">https://webhook.site/995d0a91-d737-40a7-a3b9-5baf68ed924c</a>.</p><p>Next, we can set the field callback_url to the webhook URL above and fill in prompt, as shown in the image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y4AHgqa-ApTWR-Ho.png" /></figure><p>After clicking test, an immediate response with a task_id will be received to identify the current generation task&#39;s ID, as shown in the image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*l68B-fsuMXwxkidY.png" /></figure><p>After waiting a moment for the image generation to complete, you will find that the webhook URL has received an HTTP request, as shown in the image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QpU9398v1QiBRqoX.png" /></figure><p>The result is the outcome of the current task, as follows:</p><pre>{<br>  &quot;success&quot;: true,<br>  &quot;task_id&quot;: &quot;f6e39eaf-652a-4bf5-a15c-79d8b143b80a&quot;,<br>  &quot;imageurl&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234551030549839932/kcisok_A_cat_sitting_on_a_table_id2724480591c5c85-ec80-42ab-9fe5-9adfbed192e4.png?ex=663124be&amp;is=662fd33e&amp;hm=da725eb74aae375d60beec38b4cd26c5a7b373b1662f222ff838a8ea6fd5e798&amp;width=1024&amp;height=1024&quot;,<br>  &quot;image_width&quot;: 1024,<br>  &quot;image_height&quot;: 1024,<br>  &quot;image_id&quot;: &quot;1234551030549839932&quot;,<br>  &quot;rawimage_url&quot;: &quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234551030549839932/kcisok_A_cat_sitting_on_a_table_id2724480591c5c85-ec80-42ab-9fe5-9adfbed192e4.png?ex=663124be&amp;is=662fd33e&amp;hm=da725eb74aae375d60beec38b4cd26c5a7b373b1662f222ff838a8ea6fd5e798&amp;&quot;,<br>  &quot;rawimagewidth&quot;: 2048,<br>  &quot;rawimageheight&quot;: 2048,<br>  &quot;progress&quot;: 100,<br>  &quot;actions&quot;: [<br>    &quot;upscale1&quot;,<br>    &quot;upscale2&quot;,<br>    &quot;upscale3&quot;,<br>    &quot;upscale4&quot;,<br>    &quot;reroll&quot;,<br>    &quot;variation1&quot;,<br>    &quot;variation2&quot;,<br>    &quot;variation3&quot;,<br>    &quot;variation4&quot;<br>  ]<br>}</pre><p>The success field indicates whether the task was executed successfully. If successful, there will also be the same actions, image<em>id, </em><em>image_url fields, which are the same as the return results mentioned earlier. Additionally, there is a </em><em>task</em>id used to identify the task, enabling the association of webhook results with the initial API request.</p><p>If the image generation fails, the webhook URL will receive content similar to the following:</p><pre>{<br>  &quot;success&quot;: false,<br>  &quot;task_id&quot;: &quot;7ba0feaf-d20b-4c22-a35a-31ec30fc7715&quot;,<br>  &quot;error&quot;: {<br>    &quot;code&quot;: &quot;bad_request&quot;,<br>    &quot;message&quot;: &quot;Unrecognized argument(s): `-c`, `x`&quot;<br>  }<br>}</pre><p>Here, the success field will be false, and there will also be error.code and error.message fields describing the details of the task error. The webhook server can process according to the corresponding results.</p><h3>Streaming Output</h3><p>Midjourney officially has progress when generating images. Initially, it starts as a blurry photo, and after several iterations, the image gradually becomes clearer until a complete picture is obtained.</p><p>Thus, the image generation process can be roughly divided into three stages: “send command” -&gt; “start generating image (multiple iterations gradually getting clear)” -&gt; “image generation completed”.</p><p>In the case where streaming output is not enabled, this API’s process from initiating the request to returning the results actually covers the entire process from “sending command” to “image generation completed,” including the image generation process itself. Since Midjourney itself generates images relatively slowly, the entire process takes about a minute or longer.</p><p>Therefore, to enhance user experience, this API supports streaming output, meaning that results are returned as soon as “image generation starts,” and whenever there is a change in drawing progress, the results will be streamed until the image generation ends.</p><p>If you want a streaming response, you can change the accept parameter in the request header to application/x-ndjson. However, the calling code needs to be modified accordingly to support streaming responses.</p><p>Python sample code:</p><pre>import requests<br> <br>url = &#39;https://api.acedata.cloud/midjourney/imagine&#39;<br>headers = {<br>    &#39;content-type&#39;: &#39;application/json&#39;,<br>    &#39;accept&#39;: &#39;application/x-ndjson&#39;,<br>    &#39;authorization&#39;: &#39;Bearer {token}&#39;<br>}<br>body = {<br>    &quot;prompt&quot;: &quot;a beautiful cat --v 6&quot;<br>}<br>r = requests.post(url, headers=headers, json=body, stream=True)<br>for line in r.iter_lines():<br>    print(line.decode())</pre><p>Running result:</p><pre>{&quot;imageurl&quot;:&quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234558451443699803/eae94f0f-0ba5-4b3c-9bad-59fb33ac2cbc_grid_0.webp?ex=66312ba7&amp;is=662fda27&amp;hm=4625d5f12158bffc07c4faaf6ce75af6f1396122f148b33b91f3e20b48fecc8b&amp;width=256&amp;height=256&quot;,&quot;image_width&quot;:256,&quot;image_height&quot;:256,&quot;image_id&quot;:&quot;1234558451443699803&quot;,&quot;raw_image_url&quot;:&quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234558451443699803/eae94f0f-0ba5-4b3c-9bad-59fb33ac2cbc_grid_0.webp?ex=66312ba7&amp;is=662fda27&amp;hm=4625d5f12158bffc07c4faaf6ce75af6f1396122f148b33b91f3e20b48fecc8b&amp;&quot;,&quot;raw_image_width&quot;:512,&quot;raw_image_height&quot;:512,&quot;progress&quot;:35,&quot;actions&quot;:[],&quot;taskid&quot;:&quot;49589d2c-b6b3-4fbf-9f82-93068509c76f&quot;,&quot;success&quot;:true}<br>{&quot;imageurl&quot;:&quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234558458595115149/eae94f0f-0ba5-4b3c-9bad-59fb33ac2cbc_grid_0.webp?ex=66312ba9&amp;is=662fda29&amp;hm=9af53fa645127131a88dfbb3930add7abda710c12a3d6c30c457d6a067b36bab&amp;width=256&amp;height=256&quot;,&quot;image_width&quot;:256,&quot;image_height&quot;:256,&quot;image_id&quot;:&quot;1234558458595115149&quot;,&quot;raw_image_url&quot;:&quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234558458595115149/eae94f0f-0ba5-4b3c-9bad-59fb33ac2cbc_grid_0.webp?ex=66312ba9&amp;is=662fda29&amp;hm=9af53fa645127131a88dfbb3930add7abda710c12a3d6c30c457d6a067b36bab&amp;&quot;,&quot;raw_image_width&quot;:512,&quot;raw_image_height&quot;:512,&quot;progress&quot;:75,&quot;actions&quot;:[],&quot;taskid&quot;:&quot;49589d2c-b6b3-4fbf-9f82-93068509c76f&quot;,&quot;success&quot;:true}<br>{&quot;imageurl&quot;:&quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234558483408490566/kcisok_A_landscape_painting_of_a_beautiful_sunset_id5963392_eae94f0f-0ba5-4b3c-9bad-59fb33ac2cbc.png?ex=66312baf&amp;is=662fda2f&amp;hm=185ea8f130806bf8bd96911bd251808455fd65596edcdb459f9b3cfd7860387c&amp;width=1024&amp;height=1024&quot;,&quot;image_width&quot;:1024,&quot;image_height&quot;:1024,&quot;image_id&quot;:&quot;1234558483408490566&quot;,&quot;raw_image_url&quot;:&quot;https://midjourney.cdn.acedata.cloud/attachments/1234291876639674388/1234558483408490566/kcisok_A_landscape_painting_of_a_beautiful_sunset_id5963392_eae94f0f-0ba5-4b3c-9bad-59fb33ac2cbc.png?ex=66312baf&amp;is=662fda2f&amp;hm=185ea8f130806bf8bd96911bd251808455fd65596edcdb459f9b3cfd7860387c&amp;&quot;,&quot;raw_image_width&quot;:2048,&quot;raw_image_height&quot;:2048,&quot;progress&quot;:100,&quot;actions&quot;:[&quot;upscale1&quot;,&quot;upscale2&quot;,&quot;upscale3&quot;,&quot;upscale4&quot;,&quot;reroll&quot;,&quot;variation1&quot;,&quot;variation2&quot;,&quot;variation3&quot;,&quot;variation4&quot;],&quot;taskid&quot;:&quot;49589d2c-b6b3-4fbf-9f82-93068509c76f&quot;,&quot;success&quot;:true}</pre><p>You can see that after enabling stream output, the returned result is a line-by-line JSON.</p><p>In a Node.js environment, the implementation code can be written as follows:</p><pre>const axios = require(&quot;axios&quot;);<br> <br>const url = &quot;https://api.acedata.cloud/midjourney/imagine&quot;;<br>const headers = {<br>  &quot;content-type&quot;: &quot;application/json&quot;,<br>  accept: &quot;application/x-ndjson&quot;,<br>  authorization: &quot;Bearer {token}&quot;,<br>};<br>const body = {<br>  prompt: &quot;a beautiful cat --v 6&quot;,<br>  action: &quot;generate&quot;,<br>};<br> <br>axios<br>  .post(url, body, { headers: headers, responseType: &quot;stream&quot; })<br>  .then((response) =&gt; {<br>    console.log(response.status);<br>    response.data.on(&quot;data&quot;, (chunk) =&gt; {<br>      console.log(chunk.toString());<br>    });<br>  })<br>  .catch((error) =&gt; {<br>    console.error(error);<br>  });</pre><p>The results of these examples are all similar.</p><p>Please note that in the streaming output result, there is a field called progress, which indicates the generation progress, ranging from 0 to 100. You can display this information on the page if needed.</p><blockquote>Note: When the generation is not fully completed, the actions field is empty, indicating that further processing operations cannot be performed on the intermediate image. After the generation is completed, the image_url generated during the process will be destroyed.</blockquote><p>In addition, you can combine streaming results with asynchronous callbacks by specifying the request header accept=application/x-ndjson and the request body of callback<em>url, then the callback</em>url can receive multiple POST requests of streaming results.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34635185c1e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>