Guides, references, and API documentation for DeepAI's tools
Explore our artificially intelligent tools here at DeepAI
Chat, search the web, and get help with anything
Create cool pics with our different image generators
Edit your own cool pics with our AI image editor
Create amazing videos from your own images or ideas
Describe your site and build it without writing code
Music, background removal, colorizing, upscaling, and more
What DeepAI Pro includes and what it costs
Explore what APIs we offer by reading through the docs
DeepAI is a fantastic digital space packed with AI tools. We make content creation easier and more accessible to everyone! Whether you're working on a project for school, work, or simply want to experiment with creative ideas, you can try our tools, including AI Chat, AI Image Generation, AI Photo Editor, AI Characters, and much more. DeepAI also offers resources to help you learn and stay up to date with the latest advancements in this field.
AI Chat is an assistant that responds to text prompts.
You can use it to create stories, compose messages, or write code. It's like chatting with a super-intelligent AI friend who can talk about anything. Equipped with advanced algorithms, AI Chat understands and responds to a wide variety of questions with knowledge and reasoning.
Want a user-friendly, spoken interaction? With our AI Voice Chat, you can! From asking questions and consulting on topics you need to work on to reviewing documents you want to improve without typing a single word.
With this tool, you can try it with a free account for 60 seconds a day or with a DeepAI Pro subscription to get the best version of our Voice Chat.
Online search lets you find information on the web; it's great for learning new things or discovering interesting topics. Log in to your DeepAI account to access this mode.
This mode is an excellent option for searching the web in real time; with it, you can find much more comprehensive and detailed information about current events and emerging topics.
The Memory tool helps the chat system gather information and better criteria for more accurate responses. It takes into account information you've shared before to understand your likes, preferences, and interests. All this information is based on conversations you've had with the chat system since you activated this option. The chat system has access to information you previously provided, and it's only available while the option is enabled and you have a chat history. If you delete your history, it won't take any previous conversations into account.
Let the chat browse the web in real time to find more accurate, up-to-date information and complete data on what you're looking for.
The Create Image tool lets you generate images from the chat according to the chat model you're using: Standard, Genius Pro, or Super Genius Pro. Just enter the prompt for what you want to generate, and you're done!
Delegate real-world tasks to the chat; it can be a great help with everyday tasks. Want to buy something you forgot at the last minute? Looking for the best prices on airline tickets? Just ask, and it will do it for you.
This version is an improvement over Standard AI Chat, with superior performance, more detailed responses, and greater intelligence.
This model is designed to outperform Genius Mode in tasks that require advanced reasoning, logical analysis, and mathematical problem-solving. While its estimated response time may be slightly longer, it provides greater depth, broader contextual understanding, and more comprehensive responses, resulting in a more capable and reliable experience for complex tasks.
With this add-on, you can solve math and science problems, including equations, derivatives, word problems, algebra, calculus, and much more! This mode is excellent for both solving technical problems and checking an assignment you're unsure about.
The AI Image Generator is our text-to-image tool that lets you explore your creativity and create using Artificial Intelligence. Try describing an image of your dream place or anything you desire, and let the AI do the rest!
To generate high-quality images, choose your prompt, then select from over 100 styles and shapes.
For more detail, higher artistic quality, and images that follow your instructions better than HD, with a resolution up to 1024x1024px, with the possibility of using it in horizontal, square, or vertical formats.
For ultra-high-resolution 2K images with stunning detail. Whether you're just experimenting or looking to create something epic, this tool offers a mode to suit every need. This format works perfectly if you want to print the image.
The AI Photo Editor is a tool that lets you get creative and recreate or modify any image, whether new or old, using a text description of the changes you want to see.
You can start by simply uploading an image or URL, entering the prompt with the information you want to edit or add, generating it, and you're done. For best results, be specific and concise with your instructions, such as "make the sky red" or "add flowers to the background."
You can also create an edit using up to 3 reference images, indicating with examples such as:
Our AI Video Generator turns your images and text into videos. You can use it to create educational, entertaining, or short-story videos.
By uploading to the video generator, you give DeepAI the right to share the image and video publicly. Please make sure you understand how it works by reading below.
Our DeepAI Pro membership includes 25 seconds of HD video generation per month. Additional HD video seconds are deducted from your wallet at a rate of $0.20 per second. Hollywood Mode (with 2K resolution) includes 8 seconds of video per month, and additional Hollywood Mode videos are deducted from your credits at a rate of $0.30 per second.
A versatile generation mode designed for creating realistic everyday objects, environments, and common scenes with sharp visuals and fine details. It performs especially well for practical and familiar subjects such as household appliances, furniture, bedrooms, kitchens, offices, living rooms, and everyday objects. Best value for money at $0.20 per second.
High-quality, cinematic videos with professional audio and images. Maximum creative quality at $0.30 per second.
You can generate videos using an image as a guide. Our AI Video Generator takes the image as a baseline to begin the scene, and better understands your prompt to deliver a result as close as possible to the image with the entered text.
Do you have a reference you'd like to use in your project? You can add it, and the AI Video Generator will work with your prompt to create the best possible result based on it.
Transform your video with artificial intelligence. Add, modify, or remove elements from your scenes with simple instructions and give your content exactly the result you're looking for.
The Website Builder is a web-based platform built to simplify the creation, customization, and management of websites without requiring advanced technical or coding knowledge.
It provides users with an intuitive interface and a set of configurable components that allow them to build responsive websites, customize layouts and content, manage pages, and adjust the visual appearance of their projects.
Explore each of our tools, and you'll discover that, with your knowledge and imagination, you can create incredible things!
Create unique music effortlessly with DeepAI's music generator. Perfect for Foley, sound effects, and background tracks for your videos. Transform your projects with custom-generated soundscapes tailored to your needs.
If you have DeepAI Pro, your first 100 songs are free each month, with additional songs costing $0.10 each.
Do you have an image you need the background removed from, or do you simply not like the background? Try this tool, and it will remove it effortlessly.
Would you like to see what an old black-and-white photo would look like? Add your old family photos and bring them to life with color.
The Super Resolution tool uses machine learning to clarify, sharpen, and upscale the photo without losing its content and defining characteristics. Blurry images are unfortunately common and are a problem for professionals and hobbyists alike. Super Resolution uses machine learning techniques to upscale images in a fraction of a second.
Don't like something in the photo? This tool lets you easily change objects; by specifying exactly what you want, you can improve your image.
Are you unsure whether an image is real? Upload an image to estimate whether it was AI-generated or digitally manipulated; results are probabilistic and should not be treated as definitive proof.
DeepAI Pro is a subscription that provides access to DeepAI's full suite of tools for $9.99 per month or $89.99 per year, with monthly-renewing allowances. You can also add credits to generate more content when the allowances for your current cycle are exhausted. Find more information in our pricing page, available at https://deepai.org/pricing.
Pricing: API calls are included with your DeepAI Pro membership. Each generation is drawn from your monthly allowance or deducted from your prepaid wallet balance.
DeepAI offers a range of image APIs. Each one is a simple HTTP endpoint you can call from any language, such as:Every DeepAI API is a single POST request. Send the model's inputs as multipart/form-data and authenticate with your API key in a request header.
Sign in and copy your key from your account dashboard. API access requires a DeepAI Pro subscription. Keep your key secret — treat it like a password, and never expose it in client-side code.
Pass your key in the api-key header and the model's inputs as form fields. The endpoint URL is https://api.deepai.org/api/<model>, where <model> is the model id (shown with each model below).
curl -X POST https://api.deepai.org/api/text2img \
-H 'api-key:YOUR_API_KEY' \
-F 'text=a serene mountain lake at sunrise'
On success you receive 200 OK with a JSON body. output_url links to the generated file and id is the unique job identifier:
{
"id": "59a0e8a9-...",
"output_url": "https://api.deepai.org/job-view-file/.../output.jpg"
}
Errors return a non-200 status and a JSON body with an err or status message:
Generate videos from a text prompt or a source image. Video generation takes minutes, so unlike the image APIs it is asynchronous: submit a job, receive a job id, then poll the status endpoint until the video is ready.
Pricing: video generation requires DeepAI Pro and bills per second of generated video, drawn from your monthly allowance first (25 standard seconds, 8 Hollywood Mode seconds) and then from your prepaid wallet (20¢ per standard second, 30¢ per Hollywood Mode second). See Pricing.
Text to video: POST https://api.deepai.org/video-api/text2video
Image to video: POST https://api.deepai.org/video-api/img2video
Job status: GET https://api.deepai.org/video-api/status/<id>
Send parameters as multipart/form-data, form-urlencoded, or an application/json body (with image as a URL or base64 data) with your key in the api-key header, exactly like the image APIs. The header is required on every call, including status polls; a browser session does not authenticate these routes.
| Parameter | Type | Required | Default |
|---|---|---|---|
prompt | string | text2video: Yes img2video: No | — |
image | file, URL, or base64 | img2video only: Yes | — |
mode | string | No | hd |
duration | integer | No | 5 |
shape | string | No | auto |
prompt — what to generate, up to 3000 characters (longer prompts are rejected with a 400). Optional on img2video (the source image alone is enough).
image — the source image for img2video: upload it as a file field, pass a public http(s) URL, or send base64 data (raw or as a data:image/...;base64, URL). Max 20MB, and it must decode as an image. Redirects are followed.
mode — hd for standard videos, or hollywood for 2K cinematic-quality videos.
duration — length of the generated video in seconds, from 5 to 15. Billing is per second.
shape — square, landscape, standard, vertical, portrait, or auto. With auto, img2video matches the source image and text2video uses landscape. In hollywood mode img2video always keeps the source image's shape, so shape must be auto there.
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'
Image to video, from a file or a 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'
A successful submission returns the job id to poll:
{
"id": "59a0e8a9-...",
"status": "processing"
}
Poll the status endpoint every few seconds. status is processing, completed, or 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": "..."}
A complete example in 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) is available for one hour after completion, after which the status endpoint returns 404. Download the video when it completes.401 means the api-key header is missing or invalid. A 403 means the account has no active DeepAI Pro subscription.402 response on submission means your wallet balance can't cover the video (the body includes the cost and your balance) or your account is locked after a failed payment. Add credits or enable auto top-up in your dashboard.400, and content the video provider flags during generation surfaces as {"status": "failed", "error": "NSFW detected"}.This is an AI Image Generator. It creates an image from scratch from a text description.
Endpoint: POST https://api.deepai.org/api/text2img
| Parameter | Type | Required | Default |
|---|---|---|---|
text |
text | Yes | — |
text — a string describing what to generate, e.g. "A starry night over a serene lake" or "A portrait of an old pirate".
width, height — pass a string, e.g. "256" or "768" (default 512). Use values between 128 and 1536, in multiples of 32. Recommended for standard images: 1024x576, 1024x720, 512x512, 768x1024, 576x1024. Recommended for HD images: 1216x832, 1152x896, 1024x1024, 896x1152, 832x1216. Values above ~700 or below 256 may produce strange outputs.
image_generator_version — "standard" (default), "hd", "genius", or "super_genius".
resolution — "2k" (default) or "4k". Only used when image_generator_version is "super_genius".
genius_preference — "anime", "photography", "graphic", or "cinematic". Only used when image_generator_version is "genius".
negative_prompt — a string describing what to remove from the image; useful for improving quality and detail. Example: 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 Image Generator cURL Examples
# 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 Image Generator Javascript Examples
// 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 Image Generator Python Examples
# 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 Image Generator Ruby Examples
# 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 Image Generator Php Examples
// 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 Image Generator Go Examples
// 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 Image Generator Java Examples
// 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 Image Generator C# Examples
// 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 Image Generator Swift Examples
// 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 Image Generator Kotlin Examples
// 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 Image Generator Rust Examples
// 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 Image Generator TypeScript Examples
// 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 Image Generator Dart Examples
// 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 Image Generator PowerShell Examples
# 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
Remove image background with AI.
Endpoint: POST https://api.deepai.org/api/background-remover
| Parameter | Type | Required | Default |
|---|---|---|---|
image |
image | Yes | — |
Background Remover cURL Examples
# 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
Background Remover Javascript Examples
// 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);
});
Background Remover Python Examples
# 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())
Background Remover Ruby Examples
# 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
Background Remover Php Examples
// 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();
}
?>
Background Remover Go Examples
// 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))
}
Background Remover Java Examples
// 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());
}
}
}
Background Remover C# Examples
// 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);
}
}
Background Remover Swift Examples
// 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()
Background Remover Kotlin Examples
// 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())
}
}
Background Remover Rust Examples
// 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(())
}
Background Remover TypeScript Examples
// 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();
Background Remover Dart Examples
// 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);
}
Background Remover PowerShell Examples
# 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
Edit photos and images with AI.
Endpoint: POST https://api.deepai.org/api/image-editor
| Parameter | Type | Required | Default |
|---|---|---|---|
image |
image | Yes | — |
text |
text | Yes | — |
image_generator_version — optional. Pass "genius" or "super_genius" for higher-quality, more detailed edits. Defaults to the standard editor.
resolution — "2k" (default) or "4k". Only used when image_generator_version is "super_genius".
AI Photo Editor cURL Examples
# 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 Photo Editor Javascript Examples
// 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 Photo Editor Python Examples
# 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 Photo Editor Ruby Examples
# 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 Photo Editor Php Examples
// 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 Photo Editor Go Examples
// 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 Photo Editor Java Examples
// 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 Photo Editor C# Examples
// 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 Photo Editor Swift Examples
// 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 Photo Editor Kotlin Examples
// 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 Photo Editor Rust Examples
// 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 Photo Editor TypeScript Examples
// 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 Photo Editor Dart Examples
// 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 Photo Editor PowerShell Examples
# 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
Add color to old family photos and historic images, or bring an old film back to life with colorization.
Endpoint: POST https://api.deepai.org/api/colorizer
| Parameter | Type | Required | Default |
|---|---|---|---|
image |
image | Yes | — |
Image Colorizer cURL Examples
# 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
Image Colorizer Javascript Examples
// 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);
});
Image Colorizer Python Examples
# 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())
Image Colorizer Ruby Examples
# 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
Image Colorizer Php Examples
// 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();
}
?>
Image Colorizer Go Examples
// 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))
}
Image Colorizer Java Examples
// 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());
}
}
}
Image Colorizer C# Examples
// 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);
}
}
Image Colorizer Swift Examples
// 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()
Image Colorizer Kotlin Examples
// 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())
}
}
Image Colorizer Rust Examples
// 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(())
}
Image Colorizer TypeScript Examples
// 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();
Image Colorizer Dart Examples
// 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);
}
Image Colorizer PowerShell Examples
# 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
The Super Resolution API uses machine learning to clarify, sharpen, and upscale the photo without losing its content and defining characteristics. Blurry images are unfortunately common and are a problem for professionals and hobbyists alike. Super resolution uses machine learning techniques to upscale images in a fraction of a second.
Endpoint: POST https://api.deepai.org/api/torch-srgan
| Parameter | Type | Required | Default |
|---|---|---|---|
image |
image | Yes | — |
Super Resolution cURL Examples
# 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
Super Resolution Javascript Examples
// 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);
});
Super Resolution Python Examples
# 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())
Super Resolution Ruby Examples
# 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
Super Resolution Php Examples
// 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();
}
?>
Super Resolution Go Examples
// 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))
}
Super Resolution Java Examples
// 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());
}
}
}
Super Resolution C# Examples
// 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);
}
}
Super Resolution Swift Examples
// 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()
Super Resolution Kotlin Examples
// 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())
}
}
Super Resolution Rust Examples
// 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(())
}
Super Resolution TypeScript Examples
// 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();
Super Resolution Dart Examples
// 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);
}
Super Resolution PowerShell Examples
# 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 is an algorithm that upscales images while reducing noise within the image. It gets its name from the anime-style art known as 'waifu' that it was largely trained on. Even though waifus made up most of the training data, this waifu2x api still performs well on photographs and other types of imagery. You can use Waifu2x to double the size of your images while reducing noise.
Endpoint: POST https://api.deepai.org/api/waifu2x
| Parameter | Type | Required | Default |
|---|---|---|---|
image |
image | Yes | — |
Waifu2x cURL Examples
# 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 Examples
// 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 Examples
# 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 Examples
# 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 Examples
// 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 Examples
// 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 Examples
// 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# Examples
// 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 Examples
// 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 Examples
// 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 Examples
// 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 Examples
// 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 Examples
// 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 Examples
# 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
Endpoint: POST https://api.deepai.org/api/creative-upscale
| Parameter | Type | Required | Default |
|---|---|---|---|
image |
image | Yes | — |
Creative Upscale cURL Examples
# 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
Creative Upscale Javascript Examples
// 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);
});
Creative Upscale Python Examples
# 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())
Creative Upscale Ruby Examples
# 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
Creative Upscale Php Examples
// 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();
}
?>
Creative Upscale Go Examples
// 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))
}
Creative Upscale Java Examples
// 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());
}
}
}
Creative Upscale C# Examples
// 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);
}
}
Creative Upscale Swift Examples
// 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()
Creative Upscale Kotlin Examples
// 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())
}
}
Creative Upscale Rust Examples
// 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(())
}
Creative Upscale TypeScript Examples
// 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();
Creative Upscale Dart Examples
// 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);
}
Creative Upscale PowerShell Examples
# 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
Replace and edit objects in images with AI.
Endpoint: POST https://api.deepai.org/api/image-replace
| Parameter | Type | Required | Default |
|---|---|---|---|
image |
image | Yes | — |
mask |
image | Yes | — |
text |
text | Yes | — |
Image Replace cURL Examples
# 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
Image Replace Javascript Examples
// 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);
})()
Image Replace Python Examples
# 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())
Image Replace Ruby Examples
# 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
Image Replace Php Examples
// 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();
}
?>
Image Replace Go Examples
// 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))
}
Image Replace Java Examples
// 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());
}
}
Image Replace C# Examples
// 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);
}
}
Image Replace Swift Examples
// 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()
Image Replace Kotlin Examples
// 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())
}
Image Replace Rust Examples
// 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(())
}
Image Replace TypeScript Examples
// 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();
Image Replace Dart Examples
// 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);
}
Image Replace PowerShell Examples
# 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
Use your Google Account to sign in to DeepAI