Was geht â und was geht nicht
Direkter API-Zugriff auf Midjourney?
Geht nicht. Midjourney lĂ€uft ĂŒber Discord. Kein REST-Endpunkt. Keine offizielle API.
Aber: Du kannst den Umweg gehen.
Access erzeugt Prompts, ein Bot (z.âŻB. per Node.js oder Power Automate + Discord Webhook) ĂŒbermittelt sie.
SpĂ€ter holst Du Dir das Bild zurĂŒck â per Link oder per Download.
Ich zeig Dir das Setup in zwei Etappen:
- Prompt-Erzeugung in Access
- Ăbergabe via Webhook an Discord/Midjourney
Tabellenstruktur
Tabelle | Zweck |
---|---|
tblPrompts | Prompttexte fĂŒr Midjourney |
tblBilder | Bildlinks, Status, Timestamp |
Beispiel-Prompt aus Access
A futuristic data center in the North Sea, in the style of a technical illustration, orange tones
Access erzeugt daraus einen JSON-String fĂŒr den Webhook.
Discord Webhook vorbereiten
- Discord-Server erstellen
- Textkanal â Einstellungen â Integrationen â Webhook erstellen
- Webhook-URL kopieren
- Bot oder Power Automate bereitstellen (optional)
Hinweis: Midjourney akzeptiert Prompts nur von autorisierten Usern.
Die Discord-Webhook-Variante ist also nur der halbe Weg.
Du brauchst einen Midjourney-Bot-Account mit Discord-Zugriff.
Prompt per VBA an Discord senden
Function SendePromptAnDiscord(prompt As String) As Boolean
Dim http As Object
Dim url As String
Dim json As String
url = "DEINE_DISCORD_WEBHOOK_URL"
json = "{""content"":""/imagine prompt: " & Replace(prompt, """", "'"") & """}"
Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.Open "POST", url, False
http.setRequestHeader "Content-Type", "application/json"
http.send json
SendePromptAnDiscord = (http.Status = 204 Or http.Status = 200)
End Function
Prompt automatisch generieren
Function ErzeugePrompt(kategorie As String, farbschema As String) As String
ErzeugePrompt = "A " & kategorie & " rendered in " & farbschema & " tones, in the style of a concept art illustration"
End Function
Du kannst ein Formular bauen mit Eingabefeldern fĂŒr
- Kategorie
- Farbschema
- Stil
- Auflösung
und daraus die Prompt-Zeile bauen lassen.
Bildlink zurĂŒckholen?
Nicht ganz einfach. Discord liefert keine Webhook-Antwort mit Bild.
Aber Du kannst per Python, PowerShell oder Power Automate im Kanal mitlesen
(siehe Discord API + Bot-Token).
Oder: Du trÀgst die Bild-URL manuell in tblBilder
ein.
Langfristig: Discord-Bot selbst hosten.
Alternative Workaround: GPT + DALL·E + Access
Wenn Du nicht auf Midjourney bestehst:
- DALL·E 3 lÀsst sich per OpenAI API direkt aus Access nutzen
- Siehe:
https://api.openai.com/v1/images/generations
- Prompt per VBA senden, Bildlink zurĂŒckholen, fertig
Siehe Beispiel:
Function ErzeugeBildMitDalle(prompt As String) As String
Dim http As Object
Dim apiKey As String
Dim jsonRequest As String
Dim jsonResponse As String
apiKey = "DEIN_OPENAI_API_KEY"
jsonRequest = "{""prompt"":""" & Replace(prompt, """", "\""") & """, ""n"":1, ""size"":""1024x1024""}"
Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.Open "POST", "https://api.openai.com/v1/images/generations", False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "Authorization", "Bearer " & apiKey
http.send jsonRequest
jsonResponse = http.responseText
ErzeugeBildMitDalle = ExtrahiereBildUrl(jsonResponse)
End Function
Bild-URL extrahieren
Function ExtrahiereBildUrl(json As String) As String
Dim sc As Object
Set sc = CreateObject("ScriptControl")
sc.Language = "JScript"
sc.AddCode "function getUrl(j){return JSON.parse(j).data[0].url;}"
ExtrahiereBildUrl = sc.Run("getUrl", json)
End Function
Was sinnvoll ist
- Access fĂŒr Prompt-Bibliothek und Generator
- DALL·E fĂŒr einfache API-Anbindung
- Midjourney fĂŒr höhere BildqualitĂ€t (aber mehr Aufwand)
- Kombination mit Power Automate/Node.js fĂŒr Discord-Schnittstelle
„Access kann keine Bilder malen â aber sagen, was gemalt werden soll.“
Wenn Du das automatisieren willst â ich helf Dir beim Setup.
Auch mit Discord, DALL·E oder Bot-Logik.
Keine Antworten