Ich versuche über die DEEP API ein Bild generieren zu lassen.
Der Curl code dazu ist:
curl \
-F 'text=YOUR_TEXT_URL' \
-H 'api-key:quickstart-QUdJIGlzIGNvbWluZy4uLi4K' \
https://api.deepai.org/api/text2img
Mein Java Code ist:
URL url = new URL("https://api.deepai.org/api/text2img");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
JSONObject data = new JSONObject();
data.put("text", "TEXT");
data.put("api-key", "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
con.setDoOutput(true);
con.getOutputStream().write(data.toString().getBytes());
try(BufferedReader br = new BufferedReader(
new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
return response.toString();
}
Ich bekomme jedoch folgende Fehlermeldung:
Server returned HTTP response code: 401 for URL: https://api.deepai.org/api/text2img
Kann mir jemand weiterhelfen?