2. Text to Image Generation
  • 14 Nov 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light

2. Text to Image Generation

  • Dark
    Light

Article summary

Dataoorts AI: Text To Image Generation

Dataoorts AI API Endpoint: https://cloud.dataoorts.com/api/v1

Get Your API Credential From: https://cloud.dataoorts.com/llms

Example Request Format

import requests
import json

# Define the endpoint URL
url = 'https://cloud.dataoorts.com/api/v1'

# Define the headers Auth
headers = {
    'Content-Type': 'application/json',
    'email': '<Email>',
    'api': '<API>'
}

# Define the Model Name and Data Payload
payload = {
    "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
    "data": {
        "prompt": "futuristic spacecraft"
    }
}

# Make the POST request and save the output to a file
response = requests.post(url, headers=headers, data=json.dumps(payload))

# Save the response content as an output.png
with open('output.png', 'wb') as f:
  f.write(response.content)
print("Image saved as output.png")

Example Response Format

Image saved as output.png
<output.png>


Was this article helpful?