DeepAIのツールに関するガイド、リファレンス、およびAPIドキュメント
DeepAIで、当社のAIツールをぜひご覧ください
チャットをしたり、ウェブを検索したり、どんなことでもサポートを受けたりできます
さまざまな画像生成ツールを使って、かっこいい画像を作ってみましょう
当社のAI写真編集ツールを使って、自分だけの素敵な写真を編集しましょう
ご自身の画像やアイデアから、素晴らしい動画を作成しましょう
サイトの概要を説明し、コードを書かずに作成しましょう
音楽、背景の削除、カラー化、解像度向上など
DeepAI Proの機能と価格について
ドキュメントをご覧いただき、当社が提供しているAPIについてご確認ください
DeepAIは、AIツールが満載の素晴らしいデジタル空間です。私たちは、コンテンツ作成をより簡単で、どなたでも利用しやすいものにします!学校や仕事でのプロジェクトに取り組んでいる方も、単にクリエイティブなアイデアを試してみたいという方も、AIチャット、AI画像生成、AI写真編集ツール、AIキャラクターなど、当社のさまざまなツールをぜひお試しください。また、DeepAIでは、この分野の最新動向を学び、常に最新情報を得られるよう支援するリソースも提供しています。
AIチャットは、テキストによる入力に対して応答するアシスタントです。
これを使って、ストーリーを作ったり、メッセージを作成したり、コードを書いたりすることができます。まるで、どんな話題でも話せる超知的なAIの友人とチャットしているようなものです。高度なアルゴリズムを搭載したAIチャットは、幅広い質問を理解し、知識と推論に基づいて回答します。
使いやすい音声でのやり取りをお望みですか?当社のAIボイスチャットなら、それが可能です!質問をしたり、取り組むべき課題について相談したり、改善したい文書を確認したり――そのすべてを、文字を1文字も入力することなく行えます。
このツールでは、無料アカウントで1日60秒間お試しいただくか、DeepAI Proのサブスクリプションをご利用いただくことで、当社のボイスチャットの最高性能版をお楽しみいただけます。
オンライン検索を使えば、ウェブ上で情報を探すことができます。新しいことを学んだり、興味深いトピックを見つけたりするのに最適です。このモードをご利用になるには、DeepAIアカウントにログインしてください。
このモードは、ウェブをリアルタイムで検索するのに最適な選択肢です。これを使えば、時事問題や注目のトピックについて、より包括的で詳細な情報を見つけることができます。
「メモリー」ツールは、チャットシステムが情報を収集し、より正確な回答を行うための基準を向上させるのに役立ちます。このツールは、ユーザーが以前に共有した情報を考慮に入れ、ユーザーの好みや嗜好、興味を理解します。 これらの情報はすべて、このオプションを有効にしてからチャットシステムと交わした会話に基づいています。チャットシステムは、ユーザーが以前提供した情報にアクセスできますが、この情報はオプションが有効で、かつチャット履歴が存在する場合にのみ利用可能です。履歴を削除すると、過去の会話は一切考慮されなくなります。
チャットがリアルタイムでウェブを検索し、お探しの情報について、より正確で最新の情報を得て、完全なデータを収集できるようにします。
「画像生成」ツールを使用すると、ご利用中のチャットモデル(Standard、Genius Pro、またはSuper Genius Pro)に基づいて、チャットから画像を生成することができます。生成したい内容のプロンプトを入力するだけで、完了です!
実際のタスクをチャットに任せてみましょう。日々の作業を大いに助けてくれるはずです。土壇場で買い忘れたものを購入したいですか?航空券の最安値を探していますか?ただ尋ねてみてください。チャットが代わりにやってくれます。
このバージョンは、Standard AIチャットを改良したもので、パフォーマンスが向上し、より詳細な応答が可能になり、知能も高まっています。
このモデルは、高度な推論、論理的分析、および数学的な問題解決を必要とするタスクにおいて、「Genius Mode」を上回る性能を発揮するように設計されています。推定応答時間は若干長くなる可能性がありますが、より深い洞察、より広範な文脈理解、そしてより包括的な回答を提供するため、複雑なタスクにおいて、より高性能で信頼性の高い体験を実現します。
このアドオンを使えば、方程式、微分、文章題、代数、微積分など、数学や理科の問題を解くことができます!このモードは、専門的な問題を解く際にも、自信のない宿題の答えを確認する際にも最適です。
「AI画像生成ツール」は、人工知能を活用して創造性を発揮し、作品を作成できるテキストから画像を生成するツールです。夢の場所や、思い描くどんなイメージでも自由に説明してみてください。あとはAIにお任せください!
高品質な画像を生成するには、プロンプトを選択し、100種類以上のスタイルや形状から選んでください。
より細かなディテール、より高い芸術的クオリティ、そしてHDよりも指示に忠実な画像を生成できます。解像度は最大1024×1024ピクセルで、横長、正方形、縦長のいずれのフォーマットでもご利用いただけます。
驚くほど細部まで鮮明な超高解像度の2K画像を実現します。単に試してみたい場合でも、壮大な作品を作りたい場合でも、このツールにはあらゆるニーズに応えるモードが用意されています。このフォーマットは、画像を印刷したい場合にも最適です。
「AI写真編集ツール」は、変更したい内容をテキストで記述するだけで、新しい画像でも古い画像でも、自由に創作したり、再現・編集したりできるツールです。
まずは、画像やURLをアップロードし、編集や追加したい情報をプロンプトに入力して生成するだけで完了です。最良の結果を得るためには、「空を赤くしてください」や「背景に花を追加してください」など、指示を具体的かつ簡潔に記述してください。
また、最大3枚の参考画像を使用して編集を作成することも可能です。その際は、以下のような例を挙げて示してください:
当社のAI動画生成ツールは、お持ちの画像やテキストを動画に変換します。教育用、娯楽用、あるいは短編ストーリーの動画を作成するのにご利用いただけます。
動画生成ツールにアップロードすることで、DeepAIに対し、その画像や動画を一般に公開する権利を付与することになります。以下の説明をよくお読みになり、その仕組みをご理解ください。
DeepAI Proの会員プランには、毎月25秒分のHD動画生成が含まれています。それ以上のHD動画生成については、1秒あたり0.20ドルの料金がウォレットから差し引かれます。 「Hollywoodモード」(2K解像度)には、毎月8秒分の動画が含まれており、それ以上の「Hollywoodモード」動画については、1秒あたり0.30ドルの料金がクレジットから差し引かれます。
リアルな日常の物体、環境、一般的なシーンを、鮮明なビジュアルと細部までこだわったディテールで作成するために設計された、汎用性の高い生成モードです。家電製品、家具、寝室、キッチン、オフィス、リビングルーム、日常の物体など、実用的で身近な被写体の生成に特に優れています。1秒あたり0.20ドルという、コストパフォーマンスに優れたプランです。
プロ仕様の音声と映像を備えた、高品質で映画のような動画です。1秒あたり0.30ドルで、最高のクリエイティブ品質を実現します。
画像を参考に動画を作成することができます。当社のAI動画生成ツールは、その画像をシーンのベースとして使用し、プロンプトをより正確に理解することで、入力されたテキストと画像にできるだけ近い結果を生成します。
プロジェクトで活用したい参考資料はありますか?それを追加していただければ、AI動画生成ツールがその資料をもとに、プロンプトと組み合わせて、可能な限り最良の結果を作成します。
人工知能を活用して、動画を生まれ変わらせましょう。簡単な指示でシーンの要素を追加・変更・削除し、思い通りの仕上がりを実現できます。
「ウェブサイトビルダー」は、高度な技術的知識やコーディングの知識がなくても、ウェブサイトの作成、カスタマイズ、管理を簡単に行えるように設計されたウェブベースのプラットフォームです。
このツールは、直感的なインターフェースと、設定可能なコンポーネント一式をユーザーに提供し、レスポンシブなウェブサイトの構築、レイアウトやコンテンツのカスタマイズ、ページの管理、およびプロジェクトの見た目の調整を可能にします。
当社の各ツールをぜひお試しください。そうすれば、皆さんの知識と想像力を駆使して、素晴らしいものを作り出すことができると気づくはずです!
DeepAIの音楽生成ツールを使えば、手間をかけずにユニークな音楽を作成できます。動画のフォーリー、効果音、BGMに最適です。ニーズに合わせてカスタマイズされたサウンドスケープで、プロジェクトを一新させましょう。
DeepAI Proをご利用の場合、毎月最初の100曲は無料で、それ以降の曲は1曲につき0.10ドルかかります。
背景を削除したい画像がありますか?それとも、単に背景が気に入らないだけでしょうか?このツールを試してみてください。手間なく背景を削除できます。
古い白黒写真がどんな風になるか、見てみませんか? 昔のご家族の写真を追加して、色を添えて生き生きと蘇らせてみましょう。
超解像ツールは、機械学習を活用して、写真の内容や特徴を損なうことなく、画像を鮮明にし、シャープに、そして高解像度化します。残念ながら、ぼやけた画像はよく見られるものであり、プロの方から愛好家の方まで、多くの人にとっての問題となっています。超解像は、機械学習技術を用いて、ほんの一瞬で画像を高解像度化します。
写真の中に気に入らない部分がありますか?このツールを使えば、被写体を簡単に変更できます。希望する内容を正確に指定することで、画像をより良いものにすることができます。
その画像が本物かどうか、おわかりになりませんか?画像をアップロードして、AIによって生成されたものか、デジタル加工されたものかを推定することができます。結果は確率的なものであり、決定的な証拠として扱うべきではありません。
DeepAI Proは、DeepAIのツール一式をご利用いただけるサブスクリプションサービスで、月額9.99ドル、または年額89.99ドルでご利用いただけます。利用枠は毎月更新されます。また、現在の利用期間の利用枠を使い切った場合でも、クレジットを追加することで、さらにコンテンツを生成することができます。詳細については、料金ページ(https://deepai.org/pricing)をご覧ください。
料金:API呼び出しは、DeepAI Proの会員特典に含まれています。生成ごとに、毎月の利用枠から差し引かれるか、またはプリペイドウォレットの残高から引き落とされます。
DeepAIでは、以下のようなさまざまな画像APIを提供しています。各APIは、どの言語からでも呼び出せるシンプルなHTTPエンドポイントです:DeepAIのAPIはすべて、1回のPOSTリクエストで完結します。モデルの入力をmultipart/form-dataとして送信し、リクエストヘッダーのAPIキーで認証してください。
ログインして、アカウントのダッシュボードからキーをコピーしてください。APIへのアクセスには、DeepAI Proのサブスクリプションが必要です。キーは秘密にしておいてください。パスワードと同様に扱い、クライアントサイドのコード内で決して公開しないでください。
APIキーをapi-keyヘッダーに指定し、モデルの入力をフォームフィールドとして渡してください。エンドポイントのURLはhttps://api.deepai.org/api/<model>で、<model>はモデルIDです(各モデルのIDは、以下の各モデルに記載されています)。
curl -X POST https://api.deepai.org/api/text2img \
-H 'api-key:YOUR_API_KEY' \
-F 'text=a serene mountain lake at sunrise'
成功すると、JSONボディを伴う200 OKが返されます。output_urlは生成されたファイルへのリンクで、idは一意のジョブ識別子です:
{
"id": "59a0e8a9-...",
"output_url": "https://api.deepai.org/job-view-file/.../output.jpg"
}
エラーの場合は、200以外のステータスと、errまたはstatusメッセージを含むJSONボディが返されます:
テキストのプロンプトやソース画像から動画を生成します。動画の生成には数分かかるため、画像APIとは異なり非同期処理となります。つまり、ジョブを送信してジョブのidを受け取った後、動画の準備が整うまでステータスエンドポイントをポーリングします。
料金:動画の生成にはDeepAI Proが必要であり、生成された動画の秒数に応じて課金されます。まず、毎月の利用枠(Standardモード:25秒、Hollywoodモード:8秒)から差し引かれ、その後、プリペイドウォレットから引き落とされます(Standardモード:1秒あたり20¢、Hollywoodモード:1秒あたり30¢)。詳細は料金をご覧ください。
テキストから動画へ: POST https://api.deepai.org/video-api/text2video
画像から動画へ: POST https://api.deepai.org/video-api/img2video
ジョブのステータス: GET https://api.deepai.org/video-api/status/<id>
パラメータは、画像APIとまったく同様に、multipart/form-data、form-urlencoded、またはapplication/json形式のボディ(imageはURLまたはbase64データとして指定)として送信し、api-keyヘッダーにキーを指定してください。このヘッダーは、ステータスのポーリングを含むすべての呼び出しで必須です。ブラウザのセッションでは、これらのルートに対する認証は行われません。
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
prompt | string | text2video:はい img2video:いいえ | — |
image | ファイル、URL、またはbase64 | img2video のみ:はい | — |
mode | string | いいえ | hd |
duration | integer | いいえ | 5 |
shape | string | いいえ | auto |
prompt — 生成する内容。最大3000文字まで(これを超えるプロンプトは400エラーで拒否されます)。img2videoでは任意です(ソース画像だけで十分です)。
image — img2videoのソース画像です。ファイルフィールドとしてアップロードするか、公開されているhttp(s) URLを指定するか、base64データ(生データ、またはdata:image/...;base64,形式のURL)を送信してください。最大20MBまでで、画像としてデコードできる必要があります。リダイレクトは追跡されます。
mode — 標準的な動画の場合はhd、2Kのシネマティック品質の動画の場合はhollywoodを指定してください。
duration — 生成される動画の長さ(秒単位)。5秒から15秒まで指定可能です。課金は1秒単位となります。
shape — square、landscape、standard、vertical、portrait、またはauto。autoを指定した場合、img2videoはソース画像の形状に合わせ、text2videoは横長(landscape)を使用します。hollywoodモードでは、img2videoは常にソース画像の形状を維持するため、その場合はshapeをautoに設定する必要があります。
curl -X POST https://api.deepai.org/video-api/text2video \
-H 'api-key:YOUR_API_KEY' \
-F 'prompt=a golden retriever surfing a wave at sunset' \
-F 'mode=hd' \
-F 'duration=5' \
-F 'shape=landscape'
画像から動画へ(ファイルまたはURLから):
curl -X POST https://api.deepai.org/video-api/img2video \
-H 'api-key:YOUR_API_KEY' \
-F 'image=@/path/to/photo.jpg' \
-F 'prompt=the camera slowly zooms in'
送信が成功すると、ポーリングに使用するジョブIDが返されます:
{
"id": "59a0e8a9-...",
"status": "processing"
}
数秒おきにステータスエンドポイントをポーリングしてください。statusはprocessing、completed、またはfailedのいずれかになります:
curl https://api.deepai.org/video-api/status/59a0e8a9-... \
-H 'api-key:YOUR_API_KEY'
{"status": "processing"}
{"status": "completed", "output_url": "https://...mp4"}
{"status": "failed", "error": "..."}
Pythonでの完全な例:
import time, requests
headers = {'api-key': 'YOUR_API_KEY'}
job = requests.post(
'https://api.deepai.org/video-api/text2video',
data={'prompt': 'a golden retriever surfing a wave at sunset',
'mode': 'hd', 'duration': 5, 'shape': 'landscape'},
headers=headers).json()
while True:
status = requests.get(
'https://api.deepai.org/video-api/status/' + job['id'],
headers=headers).json()
if status['status'] == 'completed':
print(status['output_url'])
break
if status['status'] == 'failed':
raise RuntimeError(status['error'])
time.sleep(5)
output_url)は、処理完了後1時間のみ利用可能です。それ以降は、ステータスエンドポイントから404が返されます。処理が完了したら、動画をダウンロードしてください。401エラーは、api-keyヘッダーが欠落しているか、無効であることを意味します。403エラーは、そのアカウントに有効なDeepAI Proのサブスクリプションがないことを意味します。402レスポンスが返された場合は、ウォレットの残高が動画の料金を賄えないか(レスポンス本文には料金と残高が記載されています)、または支払いの失敗によりアカウントがロックされていることを意味します。ダッシュボードでクレジットを追加するか、自動チャージを有効にしてください。400で拒否されます。また、動画プロバイダーが生成中にフラグを立てたコンテンツは、{"status": "failed", "error": "NSFW detected"} として表示されます。これはAI画像生成ツールです。テキストによる説明をもとに、一から画像を生成します。
エンドポイント: POST https://api.deepai.org/api/text2img
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
text |
text | はい | — |
text — 生成する内容を記述した文字列です。例:「静かな湖に広がる星空」や「老いた海賊の肖像画」など。
width、height — 文字列(例:"256" や "768")を指定してください(デフォルトは 512 です)。128 から 1536 までの範囲で、32 の倍数となる値を使用してください。Standard画像におすすめのサイズ:1024x576、1024x720、512x512、768x1024、576x1024。HD画像におすすめのサイズ:1216x832、1152x896、1024x1024、896x1152、832x1216。約700を超える値や256未満の値を設定すると、予期しない結果になる場合があります。
image_generator_version — "standard"(デフォルト)、"hd"、"genius"、または "super_genius" のいずれかです。
resolution — "2k"(デフォルト)または "4k"。image_generator_version が "super_genius" の場合にのみ使用されます。
genius_preference — "anime"、"photography"、"graphic"、または "cinematic"。image_generator_version が "genius" の場合にのみ使用されます。
negative_prompt — 画像から取り除きたい要素を記述した文字列です。画質やディテールの向上に役立ちます。例:bad anatomy, blurry, cropped, deformed, disfigured, duplicate, extra limbs, fused fingers, jpeg artifacts, low quality, lowres, mutated hands, out of frame, signature, text, watermark, worst quality.
AI画像生成ツール cURL 例
# Example posting a text URL:
curl \
-F 'text=YOUR_TEXT_HERE' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/text2img
# Example posting a local text file:
curl \
-F 'text=YOUR_TEXT_HERE' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/text2img
# Example directly sending a text string:
curl \
-F 'text=YOUR_TEXT_HERE' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/text2img
AI画像生成ツール Javascript 例
// Example posting a text URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/text2img', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_HERE",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input text (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
const resp = await fetch('https://api.deepai.org/api/text2img', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local text file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
const resp = await fetch('https://api.deepai.org/api/text2img', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example directly sending a text string:
(async function() {
const resp = await fetch('https://api.deepai.org/api/text2img', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_HERE",
})
});
const data = await resp.json();
console.log(data);
})()
AI画像生成ツール Python 例
# Example posting a text URL:
import requests
r = requests.post(
"https://api.deepai.org/api/text2img",
data={
'text': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local text file:
import requests
r = requests.post(
"https://api.deepai.org/api/text2img",
data={
'text': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example directly sending a text string:
import requests
r = requests.post(
"https://api.deepai.org/api/text2img",
data={
'text': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
AI画像生成ツール Ruby 例
# Example posting a text URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/text2img', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
}
)
puts r
# Example posting a local text file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/text2img', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
}
)
puts r
# Example directly sending a text string:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/text2img', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
}
)
puts r
AI画像生成ツール Php 例
// Example posting a text URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/text2img', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local text file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/text2img', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example directly sending a text string:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/text2img', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
AI画像生成ツール Go 例
// Example posting a text URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/text2img"
payload := map[string]string{
"text": "YOUR_TEXT_HERE",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local text file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/text2img"
var b bytes.Buffer
w := multipart.NewWriter(&b)
w.WriteField("text", "YOUR_TEXT_HERE")
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example directly sending a text string:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/text2img"
payload := map[string]string{
"text": "YOUR_TEXT_HERE",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
AI画像生成ツール Java 例
// Example posting a text URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"text\": \"YOUR_TEXT_HERE\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/text2img"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local text file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("text", "YOUR_TEXT_HERE")
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/text2img")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
// Example directly sending a text string:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"text\": \"YOUR_TEXT_HERE\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/text2img"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
AI画像生成ツール C# 例
// Example posting a text URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
text = "YOUR_TEXT_HERE",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/text2img", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local text file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
form.Add(new StringContent("YOUR_TEXT_HERE"), "text");
var response = await client.PostAsync("https://api.deepai.org/api/text2img", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example directly sending a text string:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
text = "YOUR_TEXT_HERE",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/text2img", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
AI画像生成ツール Swift 例
// Example posting a text URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/text2img")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"text": "YOUR_TEXT_HERE",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local text file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/text2img")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"text\"\r\n\r\n".data(using: .utf8)!)
body.append("YOUR_TEXT_HERE".data(using: .utf8)!)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
// Example directly sending a text string:
import Foundation
let url = URL(string: "https://api.deepai.org/api/text2img")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"text": "YOUR_TEXT_HERE",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
AI画像生成ツール Kotlin 例
// Example posting a text URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"text": "YOUR_TEXT_HERE"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/text2img"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local text file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("text", "YOUR_TEXT_HERE")
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/text2img")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
// Example directly sending a text string:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"text": "YOUR_TEXT_HERE"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/text2img"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
AI画像生成ツール Rust 例
// Example posting a text URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("text", "YOUR_TEXT_HERE");
let response = client
.post("https://api.deepai.org/api/text2img")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local text file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.text("text", "YOUR_TEXT_HERE");
let response = client
.post("https://api.deepai.org/api/text2img")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example directly sending a text string:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("text", "YOUR_TEXT_HERE");
let response = client
.post("https://api.deepai.org/api/text2img")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
AI画像生成ツール TypeScript 例
// Example posting a text URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/text2img', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: 'YOUR_TEXT_HERE',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local text file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
const response = await fetch('https://api.deepai.org/api/text2img', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
// Example directly sending a text string:
interface ApiResponse {
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/text2img', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: 'YOUR_TEXT_HERE',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
AI画像生成ツール Dart 例
// Example posting a text URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/text2img'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'text': 'YOUR_TEXT_HERE',
}),
);
print(response.body);
}
// Example posting a local text file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/text2img'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.fields['text'] = 'YOUR_TEXT_HERE';
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
// Example directly sending a text string:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/text2img'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'text': 'YOUR_TEXT_HERE',
}),
);
print(response.body);
}
AI画像生成ツール PowerShell 例
# Example posting a text URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/text2img `
-Method Post `
-Form @{
text='YOUR_TEXT_HERE'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local text file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/text2img `
-Method Post `
-Form @{
text='YOUR_TEXT_HERE'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example directly sending a text string:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/text2img `
-Method Post `
-Form @{
text='YOUR_TEXT_HERE'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
AIを使って画像の背景を削除します。
エンドポイント: POST https://api.deepai.org/api/background-remover
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
image |
image | はい | — |
背景除去ツール cURL 例
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/background-remover
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/background-remover
背景除去ツール Javascript 例
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
背景除去ツール Python 例
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/background-remover",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/background-remover",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
背景除去ツール Ruby 例
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/background-remover', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/background-remover', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
背景除去ツール Php 例
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/background-remover', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/background-remover', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
背景除去ツール Go 例
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/background-remover"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/background-remover"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
背景除去ツール Java 例
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/background-remover"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/background-remover")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
背景除去ツール C# 例
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/background-remover", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/background-remover", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
背景除去ツール Swift 例
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/background-remover")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/background-remover")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
背景除去ツール Kotlin 例
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/background-remover"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/background-remover")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
背景除去ツール Rust 例
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/background-remover")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/background-remover")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
背景除去ツール TypeScript 例
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
背景除去ツール Dart 例
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/background-remover'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/background-remover'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
背景除去ツール PowerShell 例
# Example posting a image URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/background-remover `
-Method Post `
-Form @{
image='YOUR_IMAGE_URL'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local image file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/background-remover `
-Method Post `
-Form @{
image=Get-Item -Path '/path/to/your/file.jpg'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
AIを使って写真や画像を編集しましょう。
エンドポイント: POST https://api.deepai.org/api/image-editor
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
image |
image | はい | — |
text |
text | はい | — |
image_generator_version — オプションです。"genius" または "super_genius" を指定すると、より高品質で詳細な編集が行われます。デフォルトはStandardのエディタです。
resolution — "2k"(デフォルト)または "4k"。image_generator_version が "super_genius" の場合にのみ使用されます。
AI写真編集ツール cURL 例
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-F 'text=YOUR_TEXT_HERE' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-editor
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-F 'text=YOUR_TEXT_HERE' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-editor
AI写真編集ツール Javascript 例
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/image-editor', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
text: "YOUR_TEXT_HERE",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
formData.append('text', 'YOUR_TEXT_HERE');
const resp = await fetch('https://api.deepai.org/api/image-editor', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
formData.append('text', 'YOUR_TEXT_HERE');
const resp = await fetch('https://api.deepai.org/api/image-editor', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
AI写真編集ツール Python 例
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/image-editor",
data={
'image': 'YOUR_IMAGE_URL',
'text': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/image-editor",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
data={
'text': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
AI写真編集ツール Ruby 例
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-editor', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
'text' => 'YOUR_TEXT_HERE',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-editor', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
'text' => 'YOUR_TEXT_HERE',
}
)
puts r
AI写真編集ツール Php 例
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-editor', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-editor', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
AI写真編集ツール Go 例
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/image-editor"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
"text": "YOUR_TEXT_HERE",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/image-editor"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
w.WriteField("text", "YOUR_TEXT_HERE")
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
AI写真編集ツール Java 例
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"\"text\": \"YOUR_TEXT_HERE\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-editor"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.addFormDataPart("text", "YOUR_TEXT_HERE")
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/image-editor")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
AI写真編集ツール C# 例
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
text = "YOUR_TEXT_HERE",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/image-editor", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
form.Add(new StringContent("YOUR_TEXT_HERE"), "text");
var response = await client.PostAsync("https://api.deepai.org/api/image-editor", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
AI写真編集ツール Swift 例
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-editor")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
"text": "YOUR_TEXT_HERE",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-editor")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"text\"\r\n\r\n".data(using: .utf8)!)
body.append("YOUR_TEXT_HERE".data(using: .utf8)!)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
AI写真編集ツール Kotlin 例
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL",
"text": "YOUR_TEXT_HERE"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-editor"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.addFormDataPart("text", "YOUR_TEXT_HERE")
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/image-editor")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
AI写真編集ツール Rust 例
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
payload.insert("text", "YOUR_TEXT_HERE");
let response = client
.post("https://api.deepai.org/api/image-editor")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?
.text("text", "YOUR_TEXT_HERE");
let response = client
.post("https://api.deepai.org/api/image-editor")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
AI写真編集ツール TypeScript 例
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/image-editor', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
text: 'YOUR_TEXT_HERE',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
formData.append('text', 'YOUR_TEXT_HERE');
const response = await fetch('https://api.deepai.org/api/image-editor', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
AI写真編集ツール Dart 例
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/image-editor'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
'text': 'YOUR_TEXT_HERE',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/image-editor'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
request.fields['text'] = 'YOUR_TEXT_HERE';
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
AI写真編集ツール PowerShell 例
# Example posting a image URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/image-editor `
-Method Post `
-Form @{
image='YOUR_IMAGE_URL'
text='YOUR_TEXT_HERE'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local image file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/image-editor `
-Method Post `
-Form @{
image=Get-Item -Path '/path/to/your/file.jpg'
text='YOUR_TEXT_HERE'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
古い家族写真や歴史的な写真に色を加えたり、カラー化によって古いフィルムに新たな命を吹き込んだりしましょう。
エンドポイント: POST https://api.deepai.org/api/colorizer
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
image |
image | はい | — |
画像カラー化ツール cURL 例
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/colorizer
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/colorizer
画像カラー化ツール Javascript 例
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
画像カラー化ツール Python 例
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/colorizer",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/colorizer",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
画像カラー化ツール Ruby 例
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/colorizer', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/colorizer', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
画像カラー化ツール Php 例
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/colorizer', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/colorizer', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
画像カラー化ツール Go 例
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/colorizer"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/colorizer"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
画像カラー化ツール Java 例
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/colorizer"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/colorizer")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
画像カラー化ツール C# 例
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/colorizer", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/colorizer", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
画像カラー化ツール Swift 例
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/colorizer")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/colorizer")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
画像カラー化ツール Kotlin 例
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/colorizer"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/colorizer")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
画像カラー化ツール Rust 例
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/colorizer")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/colorizer")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
画像カラー化ツール TypeScript 例
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
画像カラー化ツール Dart 例
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/colorizer'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/colorizer'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
画像カラー化ツール PowerShell 例
# Example posting a image URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/colorizer `
-Method Post `
-Form @{
image='YOUR_IMAGE_URL'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local image file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/colorizer `
-Method Post `
-Form @{
image=Get-Item -Path '/path/to/your/file.jpg'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
超解像APIは、機械学習を活用して、写真の内容や特徴を損なうことなく、画像を鮮明にし、シャープに整え、高解像度化します。残念ながら、ぼやけた画像はよく見られるものであり、プロの方にとっても愛好家の方々にとっても悩みの種となっています。超解像は、機械学習の手法を用いて、わずか数分の1秒で画像を高解像度化します。
エンドポイント: POST https://api.deepai.org/api/torch-srgan
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
image |
image | はい | — |
超解像 cURL 例
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/torch-srgan
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/torch-srgan
超解像 Javascript 例
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
超解像 Python 例
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/torch-srgan",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/torch-srgan",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
超解像 Ruby 例
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/torch-srgan', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/torch-srgan', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
超解像 Php 例
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/torch-srgan', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/torch-srgan', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
超解像 Go 例
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/torch-srgan"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/torch-srgan"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
超解像 Java 例
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/torch-srgan"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/torch-srgan")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
超解像 C# 例
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/torch-srgan", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/torch-srgan", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
超解像 Swift 例
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/torch-srgan")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/torch-srgan")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
超解像 Kotlin 例
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/torch-srgan"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/torch-srgan")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
超解像 Rust 例
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/torch-srgan")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/torch-srgan")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
超解像 TypeScript 例
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
超解像 Dart 例
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/torch-srgan'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/torch-srgan'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
超解像 PowerShell 例
# Example posting a image URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/torch-srgan `
-Method Post `
-Form @{
image='YOUR_IMAGE_URL'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local image file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/torch-srgan `
-Method Post `
-Form @{
image=Get-Item -Path '/path/to/your/file.jpg'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
Waifu2xは、画像内のノイズを低減しながら画像を拡大するアルゴリズムです。その名前は、主に学習に使用された「ワイフ」と呼ばれるアニメ風のアートに由来しています。学習データの大部分をワイフが占めていましたが、このWaifu2x APIは写真やその他の種類の画像に対しても優れた性能を発揮します。 Waifu2xを使用すれば、ノイズを抑えながら画像のサイズを2倍に拡大することができます。
エンドポイント: POST https://api.deepai.org/api/waifu2x
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
image |
image | はい | — |
Waifu2x cURL 例
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/waifu2x
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/waifu2x
Waifu2x Javascript 例
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/waifu2x', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/waifu2x', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/waifu2x', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
Waifu2x Python 例
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/waifu2x",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/waifu2x",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
Waifu2x Ruby 例
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/waifu2x', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/waifu2x', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
Waifu2x Php 例
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/waifu2x', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/waifu2x', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Waifu2x Go 例
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/waifu2x"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/waifu2x"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Waifu2x Java 例
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/waifu2x"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/waifu2x")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
Waifu2x C# 例
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/waifu2x", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/waifu2x", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Waifu2x Swift 例
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/waifu2x")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/waifu2x")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
Waifu2x Kotlin 例
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/waifu2x"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/waifu2x")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
Waifu2x Rust 例
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/waifu2x")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/waifu2x")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
Waifu2x TypeScript 例
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/waifu2x', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/waifu2x', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
Waifu2x Dart 例
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/waifu2x'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/waifu2x'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
Waifu2x PowerShell 例
# Example posting a image URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/waifu2x `
-Method Post `
-Form @{
image='YOUR_IMAGE_URL'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local image file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/waifu2x `
-Method Post `
-Form @{
image=Get-Item -Path '/path/to/your/file.jpg'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
エンドポイント: POST https://api.deepai.org/api/creative-upscale
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
image |
image | はい | — |
クリエイティブアップスケール cURL 例
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/creative-upscale
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/creative-upscale
クリエイティブアップスケール Javascript 例
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
クリエイティブアップスケール Python 例
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/creative-upscale",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/creative-upscale",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
クリエイティブアップスケール Ruby 例
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/creative-upscale', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/creative-upscale', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
クリエイティブアップスケール Php 例
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/creative-upscale', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/creative-upscale', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
クリエイティブアップスケール Go 例
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/creative-upscale"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/creative-upscale"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
クリエイティブアップスケール Java 例
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/creative-upscale"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/creative-upscale")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
クリエイティブアップスケール C# 例
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/creative-upscale", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/creative-upscale", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
クリエイティブアップスケール Swift 例
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/creative-upscale")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/creative-upscale")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
クリエイティブアップスケール Kotlin 例
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/creative-upscale"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/creative-upscale")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
クリエイティブアップスケール Rust 例
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/creative-upscale")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/creative-upscale")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
クリエイティブアップスケール TypeScript 例
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
クリエイティブアップスケール Dart 例
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/creative-upscale'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/creative-upscale'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
クリエイティブアップスケール PowerShell 例
# Example posting a image URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/creative-upscale `
-Method Post `
-Form @{
image='YOUR_IMAGE_URL'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local image file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/creative-upscale `
-Method Post `
-Form @{
image=Get-Item -Path '/path/to/your/file.jpg'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
AIを使って、画像内のオブジェクトを置き換えたり編集したりできます。
エンドポイント: POST https://api.deepai.org/api/image-replace
| パラメータ | 種類 | 必須 | デフォルト |
|---|---|---|---|
image |
image | はい | — |
mask |
image | はい | — |
text |
text | はい | — |
画像置換ツール cURL 例
# Example posting a image URL:
curl \
-F 'text=YOUR_TEXT_HERE' \
-F 'mask=YOUR_IMAGE_URL' \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-replace
# Example posting a local image file:
curl \
-F 'text=YOUR_TEXT_HERE' \
-F 'mask=@/path/to/your/file.jpg' \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-replace
# Example directly sending a text string:
curl \
-F 'text=YOUR_TEXT_HERE' \
-F 'mask=YOUR_TEXT_HERE' \
-F 'image=YOUR_TEXT_HERE' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-replace
画像置換ツール Javascript 例
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_HERE",
mask: "YOUR_IMAGE_URL",
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
formData.append('mask', this.files[0]);
formData.append('image', this.files[1]);
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('mask', jpgFileStream);
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example directly sending a text string:
(async function() {
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_HERE",
mask: "YOUR_TEXT_HERE",
image: "YOUR_TEXT_HERE",
})
});
const data = await resp.json();
console.log(data);
})()
画像置換ツール Python 例
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/image-replace",
data={
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_IMAGE_URL',
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/image-replace",
files={
'mask': open('/path/to/your/file.jpg', 'rb'),
'image': open('/path/to/your/file.jpg', 'rb'),
},
data={
'text': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example directly sending a text string:
import requests
r = requests.post(
"https://api.deepai.org/api/image-replace",
data={
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_TEXT_HERE',
'image': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
画像置換ツール Ruby 例
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-replace', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
'mask' => 'YOUR_IMAGE_URL',
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-replace', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
'mask' => File.new('/path/to/your/file.jpg'),
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
# Example directly sending a text string:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-replace', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
'mask' => 'YOUR_TEXT_HERE',
'image' => 'YOUR_TEXT_HERE',
}
)
puts r
画像置換ツール Php 例
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'mask',
'contents' => 'YOUR_IMAGE_URL'
],
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-replace', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'mask',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-replace', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example directly sending a text string:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'mask',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'image',
'contents' => 'YOUR_TEXT_HERE'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-replace', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
画像置換ツール Go 例
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/image-replace"
payload := map[string]string{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_IMAGE_URL",
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/image-replace"
var b bytes.Buffer
w := multipart.NewWriter(&b)
w.WriteField("text", "YOUR_TEXT_HERE")
maskFile, _ := os.Open("/path/to/your/file.jpg")
defer maskFile.Close()
maskWriter, _ := w.CreateFormFile("mask", "file.jpg")
io.Copy(maskWriter, maskFile)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example directly sending a text string:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/image-replace"
payload := map[string]string{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_TEXT_HERE",
"image": "YOUR_TEXT_HERE",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
画像置換ツール Java 例
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"text\": \"YOUR_TEXT_HERE\"" +
"\"mask\": \"YOUR_IMAGE_URL\"" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("text", "YOUR_TEXT_HERE")
.addFormDataPart("mask", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/image-replace")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
// Example directly sending a text string:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"text\": \"YOUR_TEXT_HERE\"" +
"\"mask\": \"YOUR_TEXT_HERE\"" +
"\"image\": \"YOUR_TEXT_HERE\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
画像置換ツール C# 例
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
text = "YOUR_TEXT_HERE",
mask = "YOUR_IMAGE_URL",
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/image-replace", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
form.Add(new StringContent("YOUR_TEXT_HERE"), "text");
var maskStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(maskStream), "mask", "file.jpg");
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/image-replace", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example directly sending a text string:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
text = "YOUR_TEXT_HERE",
mask = "YOUR_TEXT_HERE",
image = "YOUR_TEXT_HERE",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/image-replace", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
画像置換ツール Swift 例
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-replace")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_IMAGE_URL",
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-replace")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"text\"\r\n\r\n".data(using: .utf8)!)
body.append("YOUR_TEXT_HERE".data(using: .utf8)!)
body.append("\r\n".data(using: .utf8)!)
let maskData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"mask\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(maskData)
body.append("\r\n".data(using: .utf8)!)
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
// Example directly sending a text string:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-replace")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_TEXT_HERE",
"image": "YOUR_TEXT_HERE",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
画像置換ツール Kotlin 例
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_IMAGE_URL",
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("text", "YOUR_TEXT_HERE")
.addFormDataPart("mask", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/image-replace")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
// Example directly sending a text string:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_TEXT_HERE",
"image": "YOUR_TEXT_HERE"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
画像置換ツール Rust 例
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("text", "YOUR_TEXT_HERE");
payload.insert("mask", "YOUR_IMAGE_URL");
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/image-replace")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.text("text", "YOUR_TEXT_HERE")
.file("mask", "/path/to/your/file.jpg")?
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/image-replace")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example directly sending a text string:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("text", "YOUR_TEXT_HERE");
payload.insert("mask", "YOUR_TEXT_HERE");
payload.insert("image", "YOUR_TEXT_HERE");
let response = client
.post("https://api.deepai.org/api/image-replace")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
画像置換ツール TypeScript 例
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: 'YOUR_TEXT_HERE',
mask: 'YOUR_IMAGE_URL',
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
formData.append('mask', fs.createReadStream('/path/to/your/file.jpg'));
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
// Example directly sending a text string:
interface ApiResponse {
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: 'YOUR_TEXT_HERE',
mask: 'YOUR_TEXT_HERE',
image: 'YOUR_TEXT_HERE',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
画像置換ツール Dart 例
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/image-replace'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_IMAGE_URL',
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/image-replace'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.fields['text'] = 'YOUR_TEXT_HERE';
request.files.add(
await http.MultipartFile.fromPath('mask', '/path/to/your/file.jpg'),
);
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
// Example directly sending a text string:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/image-replace'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_TEXT_HERE',
'image': 'YOUR_TEXT_HERE',
}),
);
print(response.body);
}
画像置換ツール PowerShell 例
# Example posting a image URL:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/image-replace `
-Method Post `
-Form @{
text='YOUR_TEXT_HERE'
mask='YOUR_IMAGE_URL'
image='YOUR_IMAGE_URL'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example posting a local image file:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/image-replace `
-Method Post `
-Form @{
text='YOUR_TEXT_HERE'
mask=Get-Item -Path '/path/to/your/file.jpg'
image=Get-Item -Path '/path/to/your/file.jpg'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
# Example directly sending a text string:
$r = Invoke-WebRequest `
-Uri https://api.deepai.org/api/image-replace `
-Method Post `
-Form @{
text='YOUR_TEXT_HERE'
mask='YOUR_TEXT_HERE'
image='YOUR_TEXT_HERE'
} `
-Headers @{
'api-key'='YOUR_API_KEY'
}
$r.Content
Googleアカウントを使ってDeepAIにログインしてください