DALL-E Bird Images from Text

GRATIS
Da OpenedAI | Aggiornamento hace un mes | Video, Images
Popolaritร 

0.3 / 10

Latenza

60ms

Livello di servizio

0%

Health Check

N/A

Torna a tutti i tutorial (1)

Calling the API & loading base64 in Python

Here is an example for correctly calling the API in Python:

import json
import requests
import base64

url = "https://dall-e-bird-images-from-text.p.rapidapi.com/generate"

text = "a crystal blue bird with a black head"

payload = {"text": text}
payload = json.dumps(payload)
headers = {
'x-rapidapi-host': "dall-e-bird-images-from-text.p.rapidapi.com",
'x-rapidapi-key': "YOURKEY",
โ€˜content-type': "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers)

b64img = json.loads(response.text)["base64img"]

imgdata = base64.b64decode(b64img)
filename = 'dalle-crystal-bird.jpg'
with open(filename, 'wb') as f:
	f.write(imgdata)