Anleitungen, Referenzmaterialien und API-Dokumentation zu den Tools von DeepAI
Entdecke hier bei DeepAI unsere KI-Tools
Chatten, im Internet suchen und Hilfe zu jedem Thema bekommen
Erstelle coole Bilder mit unseren verschiedenen Bildgeneratoren
Bearbeite deine eigenen coolen Bilder mit unserem KI-Fotoeditor
Erstelle fantastische Videos aus deinen eigenen Bildern oder Ideen
Beschreibe deine Website und erstelle sie, ohne Code zu schreiben
Musik, Hintergrundentfernung, Kolorierung, Hochskalierung und vieles mehr
Was DeepAI Pro beinhaltet und was es kostet
Schau dir die Dokumentation an und finde heraus, welche APIs wir anbieten
DeepAI ist ein fantastischer digitaler Raum voller KI-Tools. Wir machen die Erstellung von Inhalten einfacher und für alle zugänglicher! Egal, ob du an einem Projekt für die Schule oder die Arbeit arbeitest oder einfach nur mit kreativen Ideen experimentieren möchtest – probier doch mal unsere Tools aus, darunter den KI-Chat, die KI-Bildgenerierung, den KI-Fotoeditor, KI-Charaktere und vieles mehr. DeepAI bietet außerdem Ressourcen, die dir helfen, dazuzulernen und über die neuesten Entwicklungen in diesem Bereich auf dem Laufenden zu bleiben.
Der KI-Chat ist ein Assistent, der auf Textanfragen reagiert.
Du kannst damit Geschichten erfinden, Nachrichten verfassen oder Code schreiben. Es ist, als würdest du mit einem superintelligenten KI-Freund chatten, der über alles reden kann. Dank fortschrittlicher Algorithmen versteht der KI-Chat eine Vielzahl von Fragen und antwortet darauf mit Wissen und logischem Denken.
Lust auf eine benutzerfreundliche Interaktion per Sprache? Mit unserem KI-Sprachchat ist das möglich! Von Fragen und Ratschlägen zu Themen, an denen du arbeiten musst, bis hin zur Überprüfung von Dokumenten, die du verbessern möchtest – und das alles, ohne auch nur ein einziges Wort zu tippen.
Du kannst dieses Tool mit einem kostenlosen Konto täglich 60 Sekunden lang ausprobieren oder ein DeepAI Pro-Abonnement abschließen, um die beste Version unseres Sprachchats zu nutzen.
Mit der Online-Suche kannst du Informationen im Internet finden; das ist super, um Neues zu lernen oder interessante Themen zu entdecken. Melde dich bei deinem DeepAI-Konto an, um diesen Modus zu nutzen.
Dieser Modus eignet sich hervorragend für die Echtzeit-Suche im Internet; damit kannst du viel umfassendere und detailliertere Informationen zu aktuellen Ereignissen und neuen Themen finden.
Das Tool „Chat-Speicher“ hilft dem Chat-System dabei, Informationen und bessere Kriterien für präzisere Antworten zu sammeln. Es berücksichtigt Informationen, die du zuvor geteilt hast, um deine Vorlieben, Präferenzen und Interessen zu verstehen. All diese Informationen basieren auf Unterhaltungen, die du mit dem Chat-System geführt hast, seit du diese Option aktiviert hast. Das Chat-System hat Zugriff auf Informationen, die du zuvor bereitgestellt hast, und diese stehen nur zur Verfügung, solange die Option aktiviert ist und du einen Chat-Verlauf hast. Wenn du deinen Verlauf löschst, werden frühere Unterhaltungen nicht mehr berücksichtigt.
Lass den Chat in Echtzeit im Internet suchen, um genauere, aktuellere Informationen und vollständige Daten zu dem zu finden, wonach du suchst.
Mit dem Tool „Bild erstellen“ kannst du Bilder aus dem Chat generieren, je nachdem, welches Chat-Modell du verwendest: Standard, Genius Pro oder Super Genius Pro. Gib einfach die Eingabe für das ein, was du generieren möchtest, und schon bist du fertig!
Übertrage alltägliche Aufgaben an den Chat – er kann dir bei den täglichen Aufgaben eine große Hilfe sein. Willst du in letzter Minute noch etwas kaufen, das du vergessen hast? Suchst du nach den besten Preisen für Flugtickets? Frag einfach, und er erledigt das für dich.
Diese Version ist eine Weiterentwicklung des Standard-KI-Chats und bietet eine bessere Leistung, detailliertere Antworten und mehr Intelligenz.
Dieses Modell wurde entwickelt, um den Genius-Modus bei Aufgaben zu übertreffen, die fortgeschrittenes logisches Denken, logische Analyse und mathematische Problemlösung erfordern. Auch wenn die geschätzte Antwortzeit etwas länger sein mag, bietet es mehr Tiefe, ein breiteres Kontextverständnis und umfassendere Antworten, was bei komplexen Aufgaben zu einer leistungsfähigeren und zuverlässigeren Erfahrung führt.
Mit diesem Add-on kannst du Aufgaben aus den Bereichen Mathematik und Naturwissenschaften lösen, darunter Gleichungen, Ableitungen, Textaufgaben, Algebra, Analysis und vieles mehr! Dieser Modus eignet sich hervorragend sowohl zum Lösen von technischen Aufgaben als auch zum Überprüfen einer Hausaufgabe, bei der du dir unsicher bist.
Der KI-Bildgenerator ist unser Text-zu-Bild-Tool, mit dem du deine Kreativität ausleben und mithilfe künstlicher Intelligenz etwas erschaffen kannst. Versuch doch mal, ein Bild von deinem Traumort oder von allem, was du dir wünschst, zu beschreiben – den Rest übernimmt die KI!
Um hochwertige Bilder zu erstellen, wähle deine Eingabe aus und wähle dann aus über 100 Stilen und Formen aus.
Für mehr Details, höhere künstlerische Qualität und Bilder, die deinen Vorgaben besser entsprechen als HD, mit einer Auflösung von bis zu 1024x1024px und der Möglichkeit, sie im Quer-, Quadrat- oder Hochformat zu verwenden.
Für ultrahochauflösende 2K-Bilder mit atemberaubender Detailtreue. Egal, ob du einfach nur ein bisschen herumprobierst oder etwas Großartiges schaffen möchtest – dieses Tool bietet für jeden Bedarf den passenden Modus. Dieses Format eignet sich perfekt, wenn du das Bild ausdrucken möchtest.
Der KI-Fotoeditor ist ein Tool, mit dem du kreativ werden und jedes Bild – egal ob neu oder alt – neu gestalten oder bearbeiten kannst, indem du die gewünschten Änderungen einfach in Textform beschreibst.
Du kannst einfach damit anfangen, ein Bild oder eine URL hochzuladen, die Eingabeaufforderung mit den Informationen einzugeben, die du bearbeiten oder hinzufügen möchtest, das Bild zu generieren – und schon bist du fertig. Für beste Ergebnisse solltest du deine Anweisungen konkret und prägnant formulieren, zum Beispiel „Mach den Himmel rot“ oder „Füge Blumen im Hintergrund hinzu“.
Du kannst auch eine Bearbeitung mit bis zu 3 Referenzbildern erstellen, zum Beispiel mit Angaben wie:
Unser KI-Videogenerator verwandelt deine Bilder und Texte in Videos. Du kannst damit lehrreiche, unterhaltsame oder Kurzgeschichten-Videos erstellen.
Indem du das Material in den Videogenerator hochlädst, erteilst du DeepAI das Recht, das Bild und das Video öffentlich zu teilen. Bitte lies dir die folgenden Informationen durch, um zu verstehen, wie das funktioniert.
Unsere DeepAI Pro-Mitgliedschaft umfasst 25 Sekunden HD-Videogenerierung pro Monat. Zusätzliche HD-Videosekunden werden mit 0,20 $ pro Sekunde von deinem Guthaben abgezogen. Der Hollywood-Modus (mit 2K-Auflösung) umfasst 8 Sekunden Video pro Monat, und zusätzliche Videos im Hollywood-Modus werden mit 0,30 $ pro Sekunde von deinem Guthaben abgezogen.
Ein vielseitiger Generierungsmodus, der dafür entwickelt wurde, realistische Alltagsgegenstände, Umgebungen und alltägliche Szenen mit scharfen Bildern und feinen Details zu erstellen. Er eignet sich besonders gut für praktische und vertraute Motive wie Haushaltsgeräte, Möbel, Schlafzimmer, Küchen, Büros, Wohnzimmer und Alltagsgegenstände. Mit 0,20 $ pro Sekunde bietet er das beste Preis-Leistungs-Verhältnis.
Hochwertige, filmreife Videos mit professionellem Ton und Bildmaterial. Maximale kreative Qualität für 0,30 $ pro Sekunde.
Du kannst Videos erstellen, indem du ein Bild als Vorlage verwendest. Unser KI-Videogenerator nutzt das Bild als Ausgangspunkt für die Szene und versteht deine Eingabe besser, um ein Ergebnis zu liefern, das dem Bild und dem eingegebenen Text so nahe wie möglich kommt.
Hast du eine Vorlage, die du in deinem Projekt verwenden möchtest? Du kannst sie hinzufügen, und der KI-Videogenerator wird anhand deiner Eingabe das bestmögliche Ergebnis erstellen.
Verwandle dein Video mit künstlicher Intelligenz. Füge mit einfachen Anweisungen Elemente zu deinen Szenen hinzu, ändere sie oder entferne sie – und gib deinen Inhalten genau das Ergebnis, das du dir wünschst.
Der Website Builder ist eine webbasierte Plattform, die entwickelt wurde, um die Erstellung, Anpassung und Verwaltung von Websites zu vereinfachen, ohne dass dafür fortgeschrittene technische Kenntnisse oder Programmierkenntnisse erforderlich sind.
Es bietet den Nutzern eine intuitive Benutzeroberfläche und eine Reihe konfigurierbarer Komponenten, mit denen sie responsive Websites erstellen, Layouts und Inhalte anpassen, Seiten verwalten und das Erscheinungsbild ihrer Projekte gestalten können.
Probier doch mal jedes unserer Tools aus – du wirst sehen: Mit deinem Wissen und deiner Fantasie kannst du unglaubliche Dinge erschaffen!
Erstelle mühelos einzigartige Musik mit dem Musikgenerator von DeepAI. Perfekt für Foley, Soundeffekte und Hintergrundmusik für deine Videos. Verleihe deinen Projekten eine ganz neue Note mit individuell generierten Klanglandschaften, die genau auf deine Bedürfnisse zugeschnitten sind.
Wenn du DeepAI Pro hast, sind deine ersten 100 Songs jeden Monat kostenlos; jeder weitere Song kostet 0,10 $.
Hast du ein Bild, bei dem du den Hintergrund entfernen möchtest, oder gefällt dir der Hintergrund einfach nicht? Probier dieses Tool aus – damit lässt er sich mühelos entfernen.
Möchtest du sehen, wie ein altes Schwarz-Weiß-Foto aussehen würde? Lade deine alten Familienfotos hoch und erwecke sie mit Farbe zum Leben.
Das Tool „Superauflösung“ nutzt maschinelles Lernen, um das Foto klarer und schärfer zu machen und hochzuskalieren, ohne dass dabei der Inhalt oder die charakteristischen Merkmale verloren gehen. Unscharfe Bilder kommen leider häufig vor und sind sowohl für Profis als auch für Hobbyfotografen ein Problem. Superauflösung nutzt Techniken des maschinellen Lernens, um Bilder in einem Bruchteil einer Sekunde hochzuskalieren.
Gefällt dir etwas auf dem Foto nicht? Mit diesem Tool kannst du Objekte ganz einfach ändern; indem du genau angibst, was du willst, kannst du dein Bild verbessern.
Bist du dir nicht sicher, ob ein Bild echt ist? Lade ein Bild hoch, um abzuschätzen, ob es von einer KI generiert oder digital bearbeitet wurde; die Ergebnisse sind probabilistisch und sollten nicht als endgültiger Beweis angesehen werden.
DeepAI Pro ist ein Abonnement, das dir für 9,99 $ pro Monat oder 89,99 $ pro Jahr Zugriff auf die gesamte Tool-Suite von DeepAI bietet, mit monatlich erneuerbaren Kontingenten. Du kannst außerdem Guthaben hinzufügen, um weitere Inhalte zu generieren, wenn die Kontingente für deinen aktuellen Abrechnungszeitraum aufgebraucht sind. Weitere Informationen findest du auf unserer Preisseite unter https://deepai.org/pricing.
Preise: API-Aufrufe sind in deiner DeepAI Pro-Mitgliedschaft enthalten. Jede Generierung wird von deinem monatlichen Kontingent oder von deinem Prepaid-Guthaben abgezogen.
DeepAI bietet eine Reihe von Bild-APIs an. Jede davon ist ein einfacher HTTP-Endpunkt, den du aus jeder Programmiersprache heraus aufrufen kannst, zum Beispiel:Jede DeepAI-API ist eine einzelne Anfrage vom Typ „POST“. Sende die Eingaben des Modells als „multipart/form-data“ und authentifiziere dich mit deinem API-Schlüssel im Request-Header.
Melde dich an und kopiere deinen Schlüssel aus dem Dashboard deines Kontos. Für den API-Zugriff ist ein DeepAI Pro-Abonnement erforderlich. Behandle deinen Schlüssel vertraulich – wie ein Passwort – und gib ihn niemals im clientseitigen Code preis.
Übergib deinen Schlüssel im Header „api-key“ und die Eingaben des Modells als Formularfelder. Die Endpunkt-URL lautet https://api.deepai.org/api/<model>, wobei <model> die Modell-ID ist (wird unten bei jedem Modell angezeigt).
curl -X POST https://api.deepai.org/api/text2img \
-H 'api-key:YOUR_API_KEY' \
-F 'text=a serene mountain lake at sunrise'
Bei Erfolg erhältst du 200 OK mit einem JSON-Body. output_url verweist auf die generierte Datei und id ist die eindeutige Job-ID:
{
"id": "59a0e8a9-...",
"output_url": "https://api.deepai.org/job-view-file/.../output.jpg"
}
Fehler geben einen Status ungleich 200 und einen JSON-Body mit einer err- oder status-Meldung zurück:
Erstelle Videos anhand einer Textvorgabe oder eines Quellbildes. Die Videoerstellung dauert mehrere Minuten, daher läuft sie – anders als die Bild-APIs – asynchron ab: Sende einen Auftrag ab, erhalte eine Auftrags-id und frage dann den Status-Endpunkt ab, bis das Video fertig ist.
Preise: Für die Videoerstellung ist DeepAI Pro erforderlich. Die Kosten werden pro Sekunde des erstellten Videos abgerechnet und zunächst von deinem monatlichen Kontingent (25 Standardsekunden, 8 Sekunden im Hollywood-Modus) und anschließend von deinem Prepaid-Guthaben (20¢ pro Standardsekunde, 30¢ pro Sekunde im Hollywood-Modus) abgezogen. Siehe Preise.
Text zu Video: POST https://api.deepai.org/video-api/text2video
Bild zu Video: POST https://api.deepai.org/video-api/img2video
Auftragsstatus: GET https://api.deepai.org/video-api/status/<id>
Sende Parameter als „multipart/form-data“, „form-urlencoded“ oder als „application/json“-Body (mit „image“ als URL oder Base64-Daten) und füge deinen Schlüssel in den Header „api-key“ ein – genau wie bei den Bild-APIs. Der Header ist bei jedem Aufruf erforderlich, auch bei Statusabfragen; eine Browsersitzung reicht für die Authentifizierung bei diesen Routen nicht aus.
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
prompt | string | text2video: Ja img2video: Nein | — |
image | Datei, URL oder Base64 | Nur img2video: Ja | — |
mode | string | Nein | hd |
duration | integer | Nein | 5 |
shape | string | Nein | auto |
prompt — Was generiert werden soll, bis zu 3000 Zeichen (längere Eingaben werden mit einem „400“ abgelehnt). Optional bei „img2video“ (das Quellbild allein reicht aus).
image — das Quellbild für img2video: Lade es als Dateifeld hoch, gib eine öffentliche HTTP(S)-URL an oder sende Base64-Daten (im Rohformat oder als data:image/...;base64,-URL). Maximal 20 MB, und es muss sich als Bild dekodieren lassen. Weiterleitungen werden befolgt.
mode — hd für Standardvideos oder hollywood für Videos in 2K-Kinoqualität.
duration — Länge des erstellten Videos in Sekunden, zwischen 5 und 15. Die Abrechnung erfolgt pro Sekunde.
shape — square, landscape, standard, vertical, portrait oder auto. Bei auto übernimmt img2video das Format des Quellbilds, text2video verwendet das Querformat. Im Modus hollywood behält img2video immer das Format des Quellbilds bei, daher muss shape dort auto sein.
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'
Bild in Video umwandeln, aus einer Datei oder einer 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'
Bei erfolgreicher Übermittlung wird die Job-ID zurückgegeben, die du abfragen kannst:
{
"id": "59a0e8a9-...",
"status": "processing"
}
Frage den Status-Endpunkt alle paar Sekunden ab. „status“ lautet processing, completed oder 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": "..."}
Ein vollständiges Beispiel 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) ist nach Abschluss eine Stunde lang verfügbar; danach gibt der Status-Endpunkt den Status 404 zurück. Lade das Video herunter, sobald es fertig ist.401“ bedeutet, dass der Header „api-key“ fehlt oder ungültig ist. Ein „403“ bedeutet, dass das Konto kein aktives DeepAI Pro-Abonnement hat.402-Antwort beim Absenden bedeutet, dass dein Guthaben nicht ausreicht, um das Video zu bezahlen (der Antwort-Body enthält die Kosten und dein Guthaben), oder dass dein Konto nach einer fehlgeschlagenen Zahlung gesperrt wurde. Lade Guthaben auf oder aktiviere die automatische Aufladung in deinem Dashboard.400“ abgelehnt, und Inhalte, die der Videoanbieter während der Erstellung markiert, werden als „{"status": "failed", "error": "NSFW detected"}“ angezeigt.Das ist ein KI-Bildgenerator. Er erstellt anhand einer Textbeschreibung ein Bild von Grund auf neu.
Endpunkt: POST https://api.deepai.org/api/text2img
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
text |
text | Ja | — |
text — eine Zeichenfolge, die beschreibt, was generiert werden soll, z. B. „Eine sternenklare Nacht über einem ruhigen See“ oder „Das Porträt eines alten Piraten“.
width, height — Gib eine Zeichenkette ein, z. B. „256“ oder „768“ (Standardwert 512). Verwende Werte zwischen 128 und 1536, in Vielfachen von 32. Empfohlen für Standardbilder: 1024x576, 1024x720, 512x512, 768x1024, 576x1024. Empfohlen für HD-Bilder: 1216x832, 1152x896, 1024x1024, 896x1152, 832x1216. Werte über ~700 oder unter 256 können zu seltsamen Ergebnissen führen.
image_generator_version — „standard“ (Standard), „hd“, „genius“ oder „super_genius“.
resolution — „2k“ (Standard) oder „4k“. Wird nur verwendet, wenn „image_generator_version“ auf „super_genius“ gesetzt ist.
genius_preference — „anime“, „photography“, „graphic“ oder „cinematic“. Wird nur verwendet, wenn „image_generator_version“ auf „genius“ gesetzt ist.
negative_prompt — eine Zeichenkette, die beschreibt, was aus dem Bild entfernt werden soll; nützlich zur Verbesserung von Qualität und Detailgenauigkeit. Beispiel: anatomische Fehler, unscharf, beschnitten, verzerrt, entstellt, Duplikate, überzählige Gliedmaßen, verwachsene Finger, JPEG-Artefakte, schlechte Qualität, niedrige Auflösung, deformierte Hände, außerhalb des Bildausschnitts, Unterschrift, Text, Wasserzeichen, schlechteste Qualität.
cURL-Beispiele für KI-Bildgenerator
# 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
Javascript-Beispiele für KI-Bildgenerator
// 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);
})()
Python-Beispiele für KI-Bildgenerator
# 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())
Ruby-Beispiele für KI-Bildgenerator
# 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
Php-Beispiele für KI-Bildgenerator
// 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();
}
?>
Go-Beispiele für KI-Bildgenerator
// 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))
}
Java-Beispiele für KI-Bildgenerator
// 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());
}
}
C#-Beispiele für KI-Bildgenerator
// 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);
}
}
Swift-Beispiele für KI-Bildgenerator
// 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()
Kotlin-Beispiele für KI-Bildgenerator
// 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())
}
Rust-Beispiele für KI-Bildgenerator
// 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(())
}
TypeScript-Beispiele für KI-Bildgenerator
// 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();
Dart-Beispiele für KI-Bildgenerator
// 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);
}
PowerShell-Beispiele für KI-Bildgenerator
# 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
Bildhintergrund mit KI entfernen.
Endpunkt: POST https://api.deepai.org/api/background-remover
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
image |
image | Ja | — |
cURL-Beispiele für Hintergrundentferner
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/background-remover
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/background-remover
Javascript-Beispiele für Hintergrundentferner
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
Python-Beispiele für Hintergrundentferner
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/background-remover",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/background-remover",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
Ruby-Beispiele für Hintergrundentferner
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/background-remover', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/background-remover', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
Php-Beispiele für Hintergrundentferner
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/background-remover', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/background-remover', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Go-Beispiele für Hintergrundentferner
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/background-remover"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/background-remover"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Java-Beispiele für Hintergrundentferner
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/background-remover"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/background-remover")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
C#-Beispiele für Hintergrundentferner
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/background-remover", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/background-remover", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Swift-Beispiele für Hintergrundentferner
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/background-remover")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/background-remover")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
Kotlin-Beispiele für Hintergrundentferner
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/background-remover"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/background-remover")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
Rust-Beispiele für Hintergrundentferner
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/background-remover")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/background-remover")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
TypeScript-Beispiele für Hintergrundentferner
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/background-remover', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
Dart-Beispiele für Hintergrundentferner
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/background-remover'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/background-remover'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
PowerShell-Beispiele für Hintergrundentferner
# 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
Fotos und Bilder mit KI bearbeiten.
Endpunkt: POST https://api.deepai.org/api/image-editor
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
image |
image | Ja | — |
text |
text | Ja | — |
image_generator_version — optional. Übergib „genius“ oder „super_genius“, um qualitativ hochwertigere und detailliertere Bearbeitungen zu erhalten. Standardmäßig wird der Standard-Editor verwendet.
resolution — „2k“ (Standard) oder „4k“. Wird nur verwendet, wenn „image_generator_version“ auf „super_genius“ gesetzt ist.
cURL-Beispiele für KI-Fotoeditor
# 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
Javascript-Beispiele für KI-Fotoeditor
// 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);
});
Python-Beispiele für KI-Fotoeditor
# 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())
Ruby-Beispiele für KI-Fotoeditor
# 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
Php-Beispiele für KI-Fotoeditor
// 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();
}
?>
Go-Beispiele für KI-Fotoeditor
// 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))
}
Java-Beispiele für KI-Fotoeditor
// 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());
}
}
}
C#-Beispiele für KI-Fotoeditor
// 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);
}
}
Swift-Beispiele für KI-Fotoeditor
// 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()
Kotlin-Beispiele für KI-Fotoeditor
// 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())
}
}
Rust-Beispiele für KI-Fotoeditor
// 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(())
}
TypeScript-Beispiele für KI-Fotoeditor
// 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();
Dart-Beispiele für KI-Fotoeditor
// 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);
}
PowerShell-Beispiele für KI-Fotoeditor
# 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
Bring Farbe in alte Familienfotos und historische Bilder oder erwecke einen alten Film durch Kolorierung wieder zum Leben.
Endpunkt: POST https://api.deepai.org/api/colorizer
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
image |
image | Ja | — |
cURL-Beispiele für Bild-Kolorierer
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/colorizer
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/colorizer
Javascript-Beispiele für Bild-Kolorierer
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
Python-Beispiele für Bild-Kolorierer
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/colorizer",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/colorizer",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
Ruby-Beispiele für Bild-Kolorierer
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/colorizer', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/colorizer', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
Php-Beispiele für Bild-Kolorierer
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/colorizer', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/colorizer', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Go-Beispiele für Bild-Kolorierer
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/colorizer"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/colorizer"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Java-Beispiele für Bild-Kolorierer
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/colorizer"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/colorizer")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
C#-Beispiele für Bild-Kolorierer
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/colorizer", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/colorizer", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Swift-Beispiele für Bild-Kolorierer
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/colorizer")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/colorizer")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
Kotlin-Beispiele für Bild-Kolorierer
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/colorizer"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/colorizer")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
Rust-Beispiele für Bild-Kolorierer
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/colorizer")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/colorizer")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
TypeScript-Beispiele für Bild-Kolorierer
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/colorizer', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
Dart-Beispiele für Bild-Kolorierer
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/colorizer'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/colorizer'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
PowerShell-Beispiele für Bild-Kolorierer
# 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
Die Super-Resolution-API nutzt maschinelles Lernen, um das Foto klarer, schärfer und hochauflösender zu machen, ohne dass dabei der Inhalt oder die charakteristischen Merkmale verloren gehen. Unscharfe Bilder kommen leider häufig vor und sind sowohl für Profis als auch für Hobbyfotografen ein Problem. Die Super-Resolution-Funktion nutzt Techniken des maschinellen Lernens, um Bilder in einem Bruchteil einer Sekunde hochzuskalieren.
Endpunkt: POST https://api.deepai.org/api/torch-srgan
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
image |
image | Ja | — |
cURL-Beispiele für Superauflösung
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/torch-srgan
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/torch-srgan
Javascript-Beispiele für Superauflösung
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
Python-Beispiele für Superauflösung
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/torch-srgan",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/torch-srgan",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
Ruby-Beispiele für Superauflösung
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/torch-srgan', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/torch-srgan', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
Php-Beispiele für Superauflösung
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/torch-srgan', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/torch-srgan', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Go-Beispiele für Superauflösung
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/torch-srgan"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/torch-srgan"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Java-Beispiele für Superauflösung
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/torch-srgan"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/torch-srgan")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
C#-Beispiele für Superauflösung
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/torch-srgan", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/torch-srgan", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Swift-Beispiele für Superauflösung
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/torch-srgan")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/torch-srgan")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
Kotlin-Beispiele für Superauflösung
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/torch-srgan"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/torch-srgan")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
Rust-Beispiele für Superauflösung
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/torch-srgan")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/torch-srgan")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
TypeScript-Beispiele für Superauflösung
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/torch-srgan', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
Dart-Beispiele für Superauflösung
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/torch-srgan'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/torch-srgan'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
PowerShell-Beispiele für Superauflösung
# 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 ist ein Algorithmus, der Bilder hochskaliert und dabei das Bildrauschen reduziert. Seinen Namen hat er von der als „Waifu“ bekannten Kunst im Anime-Stil, mit der er größtenteils trainiert wurde. Auch wenn Waifus den Großteil der Trainingsdaten ausmachten, liefert diese Waifu2x-API dennoch gute Ergebnisse bei Fotos und anderen Bildarten. Du kannst Waifu2x nutzen, um die Größe deiner Bilder zu verdoppeln und dabei das Bildrauschen zu reduzieren.
Endpunkt: POST https://api.deepai.org/api/waifu2x
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
image |
image | Ja | — |
cURL-Beispiele für Waifu2x
# 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
Javascript-Beispiele für Waifu2x
// 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);
});
Python-Beispiele für Waifu2x
# 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())
Ruby-Beispiele für Waifu2x
# 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
Php-Beispiele für Waifu2x
// 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();
}
?>
Go-Beispiele für Waifu2x
// 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))
}
Java-Beispiele für Waifu2x
// 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());
}
}
}
C#-Beispiele für Waifu2x
// 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);
}
}
Swift-Beispiele für Waifu2x
// 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()
Kotlin-Beispiele für Waifu2x
// 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())
}
}
Rust-Beispiele für Waifu2x
// 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(())
}
TypeScript-Beispiele für Waifu2x
// 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();
Dart-Beispiele für Waifu2x
// 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);
}
PowerShell-Beispiele für Waifu2x
# 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
Endpunkt: POST https://api.deepai.org/api/creative-upscale
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
image |
image | Ja | — |
cURL-Beispiele für Creative Upscale
# Example posting a image URL:
curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/creative-upscale
# Example posting a local image file:
curl \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/creative-upscale
Javascript-Beispiele für Creative Upscale
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('image', this.files[0]);
const resp = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
Python-Beispiele für Creative Upscale
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/creative-upscale",
data={
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/creative-upscale",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
Ruby-Beispiele für Creative Upscale
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/creative-upscale', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/creative-upscale', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
Php-Beispiele für Creative Upscale
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/creative-upscale', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/creative-upscale', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Go-Beispiele für Creative Upscale
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/creative-upscale"
payload := map[string]string{
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/creative-upscale"
var b bytes.Buffer
w := multipart.NewWriter(&b)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Java-Beispiele für Creative Upscale
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/creative-upscale"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/creative-upscale")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
C#-Beispiele für Creative Upscale
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/creative-upscale", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/creative-upscale", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Swift-Beispiele für Creative Upscale
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/creative-upscale")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/creative-upscale")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
Kotlin-Beispiele für Creative Upscale
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/creative-upscale"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/creative-upscale")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
Rust-Beispiele für Creative Upscale
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/creative-upscale")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/creative-upscale")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
TypeScript-Beispiele für Creative Upscale
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/creative-upscale', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
Dart-Beispiele für Creative Upscale
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/creative-upscale'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/creative-upscale'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
PowerShell-Beispiele für Creative Upscale
# 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
Objekte in Bildern mit KI ersetzen und bearbeiten.
Endpunkt: POST https://api.deepai.org/api/image-replace
| Parameter | Typ | Erforderlich | Standard |
|---|---|---|---|
image |
image | Ja | — |
mask |
image | Ja | — |
text |
text | Ja | — |
cURL-Beispiele für Bild ersetzen
# Example posting a image URL:
curl \
-F 'text=YOUR_TEXT_HERE' \
-F 'mask=YOUR_IMAGE_URL' \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-replace
# Example posting a local image file:
curl \
-F 'text=YOUR_TEXT_HERE' \
-F 'mask=@/path/to/your/file.jpg' \
-F 'image=@/path/to/your/file.jpg' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-replace
# Example directly sending a text string:
curl \
-F 'text=YOUR_TEXT_HERE' \
-F 'mask=YOUR_TEXT_HERE' \
-F 'image=YOUR_TEXT_HERE' \
-H 'api-key:YOUR_API_KEY' \
https://api.deepai.org/api/image-replace
Javascript-Beispiele für Bild ersetzen
// Example posting a image URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_HERE",
mask: "YOUR_IMAGE_URL",
image: "YOUR_IMAGE_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input image (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
formData.append('mask', this.files[0]);
formData.append('image', this.files[1]);
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local image file (Node.js only):
const fs = require('fs');
(async function() {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('mask', jpgFileStream);
const jpgFileStream = fs.createReadStream("/path/to/your/file.jpg");
formData.append('image', jpgFileStream);
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example directly sending a text string:
(async function() {
const resp = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_HERE",
mask: "YOUR_TEXT_HERE",
image: "YOUR_TEXT_HERE",
})
});
const data = await resp.json();
console.log(data);
})()
Python-Beispiele für Bild ersetzen
# Example posting a image URL:
import requests
r = requests.post(
"https://api.deepai.org/api/image-replace",
data={
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_IMAGE_URL',
'image': 'YOUR_IMAGE_URL',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example posting a local image file:
import requests
r = requests.post(
"https://api.deepai.org/api/image-replace",
files={
'mask': open('/path/to/your/file.jpg', 'rb'),
'image': open('/path/to/your/file.jpg', 'rb'),
},
data={
'text': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
# Example directly sending a text string:
import requests
r = requests.post(
"https://api.deepai.org/api/image-replace",
data={
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_TEXT_HERE',
'image': 'YOUR_TEXT_HERE',
},
headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())
Ruby-Beispiele für Bild ersetzen
# Example posting a image URL:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-replace', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
'mask' => 'YOUR_IMAGE_URL',
'image' => 'YOUR_IMAGE_URL',
}
)
puts r
# Example posting a local image file:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-replace', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
'mask' => File.new('/path/to/your/file.jpg'),
'image' => File.new('/path/to/your/file.jpg'),
}
)
puts r
# Example directly sending a text string:
require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-replace', timeout: 600,
headers: {'api-key' => 'YOUR_API_KEY'},
payload: {
'text' => 'YOUR_TEXT_HERE',
'mask' => 'YOUR_TEXT_HERE',
'image' => 'YOUR_TEXT_HERE',
}
)
puts r
Php-Beispiele für Bild ersetzen
// Example posting a image URL:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'mask',
'contents' => 'YOUR_IMAGE_URL'
],
[
'name' => 'image',
'contents' => 'YOUR_IMAGE_URL'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-replace', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example posting a local image file:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'mask',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
[
'name' => 'image',
'contents' => Utils::tryFopen('/path/to/your/file.jpg', 'r')
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-replace', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
// Example directly sending a text string:
<?php
require 'vendor/autoload.php'; // Ensure you have Guzzle installed (composer require guzzlehttp/guzzle)
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Utils;
$client = new Client();
$headers = [
'api-key' => 'YOUR_API_KEY'
];
$options = [
'multipart' => [
[
'name' => 'text',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'mask',
'contents' => 'YOUR_TEXT_HERE'
],
[
'name' => 'image',
'contents' => 'YOUR_TEXT_HERE'
],
]
];
$request = new GuzzleHttp\Psr7\Request('POST', 'https://api.deepai.org/api/image-replace', $headers);
try {
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Go-Beispiele für Bild ersetzen
// Example posting a image URL:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/image-replace"
payload := map[string]string{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_IMAGE_URL",
"image": "YOUR_IMAGE_URL",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example posting a local image file:
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.deepai.org/api/image-replace"
var b bytes.Buffer
w := multipart.NewWriter(&b)
w.WriteField("text", "YOUR_TEXT_HERE")
maskFile, _ := os.Open("/path/to/your/file.jpg")
defer maskFile.Close()
maskWriter, _ := w.CreateFormFile("mask", "file.jpg")
io.Copy(maskWriter, maskFile)
imageFile, _ := os.Open("/path/to/your/file.jpg")
defer imageFile.Close()
imageWriter, _ := w.CreateFormFile("image", "file.jpg")
io.Copy(imageWriter, imageFile)
if err := w.Close(); err != nil {
panic(err)
}
req, _ := http.NewRequest("POST", url, &b)
req.Header.Set("Content-Type", w.FormDataContentType())
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
// Example directly sending a text string:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.deepai.org/api/image-replace"
payload := map[string]string{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_TEXT_HERE",
"image": "YOUR_TEXT_HERE",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Java-Beispiele für Bild ersetzen
// Example posting a image URL:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"text\": \"YOUR_TEXT_HERE\"" +
"\"mask\": \"YOUR_IMAGE_URL\"" +
"\"image\": \"YOUR_IMAGE_URL\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// Example posting a local image file:
// Add to build.gradle: implementation 'com.squareup.okhttp3:okhttp:4.12.0'
import okhttp3.*;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("text", "YOUR_TEXT_HERE")
.addFormDataPart("mask", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.addFormDataPart("image", "file.jpg", RequestBody.create(new File("/path/to/your/file.jpg"), MediaType.parse("application/octet-stream")))
.build();
Request request = new Request.Builder()
.url("https://api.deepai.org/api/image-replace")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
// Example directly sending a text string:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String json = "{" +
"\"text\": \"YOUR_TEXT_HERE\"" +
"\"mask\": \"YOUR_TEXT_HERE\"" +
"\"image\": \"YOUR_TEXT_HERE\"" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
C#-Beispiele für Bild ersetzen
// Example posting a image URL:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
text = "YOUR_TEXT_HERE",
mask = "YOUR_IMAGE_URL",
image = "YOUR_IMAGE_URL",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/image-replace", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example posting a local image file:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
using var form = new MultipartFormDataContent();
form.Add(new StringContent("YOUR_TEXT_HERE"), "text");
var maskStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(maskStream), "mask", "file.jpg");
var imageStream = File.OpenRead("/path/to/your/file.jpg");
form.Add(new StreamContent(imageStream), "image", "file.jpg");
var response = await client.PostAsync("https://api.deepai.org/api/image-replace", form);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// Example directly sending a text string:
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("api-key", "YOUR_API_KEY");
var payload = new
{
text = "YOUR_TEXT_HERE",
mask = "YOUR_TEXT_HERE",
image = "YOUR_TEXT_HERE",
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.deepai.org/api/image-replace", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Swift-Beispiele für Bild ersetzen
// Example posting a image URL:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-replace")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_IMAGE_URL",
"image": "YOUR_IMAGE_URL",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
// Keep the program running for async request
RunLoop.main.run()
// Example posting a local image file:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-replace")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let boundary = UUID().uuidString
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
var body = Data()
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"text\"\r\n\r\n".data(using: .utf8)!)
body.append("YOUR_TEXT_HERE".data(using: .utf8)!)
body.append("\r\n".data(using: .utf8)!)
let maskData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"mask\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(maskData)
body.append("\r\n".data(using: .utf8)!)
let imageData = try! Data(contentsOf: URL(fileURLWithPath: "/path/to/your/file.jpg"))
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"image\"; filename=\"file.jpg\"\r\n".data(using: .utf8)!)
body.append("Content-Type: application/octet-stream\r\n\r\n".data(using: .utf8)!)
body.append(imageData)
body.append("\r\n".data(using: .utf8)!)
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
request.httpBody = body
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
// Example directly sending a text string:
import Foundation
let url = URL(string: "https://api.deepai.org/api/image-replace")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "api-key")
let payload: [String: Any] = [
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_TEXT_HERE",
"image": "YOUR_TEXT_HERE",
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8) ?? "")
}
}
task.resume()
RunLoop.main.run()
Kotlin-Beispiele für Bild ersetzen
// Example posting a image URL:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_IMAGE_URL",
"image": "YOUR_IMAGE_URL"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
// Example posting a local image file:
// Add to build.gradle.kts: implementation("com.squareup.okhttp3:okhttp:4.12.0")
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
fun main() {
val client = OkHttpClient()
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("text", "YOUR_TEXT_HERE")
.addFormDataPart("mask", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.addFormDataPart("image", "file.jpg", File("/path/to/your/file.jpg").asRequestBody("application/octet-stream".toMediaType()))
.build()
val request = Request.Builder()
.url("https://api.deepai.org/api/image-replace")
.addHeader("api-key", "YOUR_API_KEY")
.post(requestBody)
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
// Example directly sending a text string:
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val client = HttpClient.newHttpClient()
val json = """{
"text": "YOUR_TEXT_HERE",
"mask": "YOUR_TEXT_HERE",
"image": "YOUR_TEXT_HERE"
}"""
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.deepai.org/api/image-replace"))
.header("Content-Type", "application/json")
.header("api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
}
Rust-Beispiele für Bild ersetzen
// Example posting a image URL:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("text", "YOUR_TEXT_HERE");
payload.insert("mask", "YOUR_IMAGE_URL");
payload.insert("image", "YOUR_IMAGE_URL");
let response = client
.post("https://api.deepai.org/api/image-replace")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example posting a local image file:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
use reqwest::multipart;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let form = multipart::Form::new()
.text("text", "YOUR_TEXT_HERE")
.file("mask", "/path/to/your/file.jpg")?
.file("image", "/path/to/your/file.jpg")?;
let response = client
.post("https://api.deepai.org/api/image-replace")
.header("api-key", "YOUR_API_KEY")
.multipart(form)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
// Example directly sending a text string:
// Add to Cargo.toml: reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1", features = ["full"] }
// serde_json = "1"
use reqwest::header::HeaderMap;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert("api-key", "YOUR_API_KEY".parse()?);
let mut payload = HashMap::new();
payload.insert("text", "YOUR_TEXT_HERE");
payload.insert("mask", "YOUR_TEXT_HERE");
payload.insert("image", "YOUR_TEXT_HERE");
let response = client
.post("https://api.deepai.org/api/image-replace")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
TypeScript-Beispiele für Bild ersetzen
// Example posting a image URL:
interface ApiResponse {
// Define your response type here
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: 'YOUR_TEXT_HERE',
mask: 'YOUR_IMAGE_URL',
image: 'YOUR_IMAGE_URL',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
// Example posting a local image file (Node.js with form-data package):
// npm install form-data
import * as fs from 'fs';
import FormData from 'form-data';
interface ApiResponse {
[key: string]: unknown;
}
async function uploadFile(): Promise<ApiResponse> {
const formData = new FormData();
formData.append('text', 'YOUR_TEXT_HERE');
formData.append('mask', fs.createReadStream('/path/to/your/file.jpg'));
formData.append('image', fs.createReadStream('/path/to/your/file.jpg'));
const response = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
...formData.getHeaders(),
'api-key': 'YOUR_API_KEY'
},
body: formData as unknown as BodyInit
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
uploadFile();
// Example directly sending a text string:
interface ApiResponse {
[key: string]: unknown;
}
async function callApi(): Promise<ApiResponse> {
const response = await fetch('https://api.deepai.org/api/image-replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: 'YOUR_TEXT_HERE',
mask: 'YOUR_TEXT_HERE',
image: 'YOUR_TEXT_HERE',
})
});
const data: ApiResponse = await response.json();
console.log(data);
return data;
}
callApi();
Dart-Beispiele für Bild ersetzen
// Example posting a image URL:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/image-replace'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_IMAGE_URL',
'image': 'YOUR_IMAGE_URL',
}),
);
print(response.body);
}
// Example posting a local image file:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
var request = http.MultipartRequest(
'POST',
Uri.parse('https://api.deepai.org/api/image-replace'),
);
request.headers['api-key'] = 'YOUR_API_KEY';
request.fields['text'] = 'YOUR_TEXT_HERE';
request.files.add(
await http.MultipartFile.fromPath('mask', '/path/to/your/file.jpg'),
);
request.files.add(
await http.MultipartFile.fromPath('image', '/path/to/your/file.jpg'),
);
var response = await request.send();
var responseBody = await response.stream.bytesToString();
print(responseBody);
}
// Example directly sending a text string:
// Add to pubspec.yaml: http: ^1.1.0
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> main() async {
final response = await http.post(
Uri.parse('https://api.deepai.org/api/image-replace'),
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY',
},
body: jsonEncode({
'text': 'YOUR_TEXT_HERE',
'mask': 'YOUR_TEXT_HERE',
'image': 'YOUR_TEXT_HERE',
}),
);
print(response.body);
}
PowerShell-Beispiele für Bild ersetzen
# 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
Melde dich mit deinem Google-Konto bei DeepAI an