Here's a sample Python script to generate images using the **DeepSeek Janus-Pro API** via the **Fal.ai platform**:
### **Python Code for AI Image Generation**
python
import requests
# API endpoint for DeepSeek Janus-Pro
API_URL = "https://api.fal.ai/v1/predict"
# Your API Key (Replace with your actual API key)
API_KEY = "your_api_key_here"
# Set up headers with authentication
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Define the request payload
payload = {
"model": "fal-ai/janus",
"inputs": {
"prompt": "A futuristic cyberpunk city at night with neon lights",
"num_images": 1, # Number of images to generate
"image_size": "1024x1024" # Image resolution
}
}
# Send the request
response = requests.post(API_URL, json=payload, headers=headers)
# Process response
if response.status_code == 200:
result = response.json()
image_url = result['outputs'][0]['image_url']
print(f"Image generated successfully: {image_url}")
else:
print(f"Error: {response.status_code} - {response.text}")
### **How to Use:**
1. **Get API Key**: Sign up at [Fal.ai](https://fal.ai/models/fal-ai/janus/api) and generate your API key.
2. **Install Dependencies**: Ensure you have
requests
installed:
bash
pip install requests
3. **Run the Script**: Replace
"your_api_key_here"
with your actual API key and execute the script.
This will generate an AI image based on the given text prompt and return the image URL.