Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
|
|
| 14 |
# Kling AI API configuration (keys hardcoded as requested)
|
| 15 |
ACCESS_KEY_ID = "AGBGmadNd9hakFYfahytyQQJtN8CJmDJ"
|
| 16 |
ACCESS_KEY_SECRET = "dp3pAe4PpdmnAHCAPgEd3PyLmBQrkMde"
|
| 17 |
-
API_URL = "https://api.klingai.com/v1/
|
| 18 |
|
| 19 |
def generate_jwt_token():
|
| 20 |
"""Generate JWT token for Kling AI API authentication."""
|
|
@@ -114,7 +114,7 @@ def generate_image(image, prompt=""):
|
|
| 114 |
time.sleep(5)
|
| 115 |
|
| 116 |
logger.error("Image generation timed out")
|
| 117 |
-
return None, "Error: Image generation timed out. Try during off-peak hours or check account status."
|
| 118 |
|
| 119 |
except requests.exceptions.HTTPError as e:
|
| 120 |
status_code = e.response.status_code if e.response else None
|
|
@@ -127,7 +127,7 @@ def generate_image(image, prompt=""):
|
|
| 127 |
return None, "Error: Invalid request method (1202). Check https://klingai.com/global/dev for correct endpoint."
|
| 128 |
elif service_code == 1203:
|
| 129 |
return None, "Error: Resource does not exist (1203). Verify model or endpoint."
|
| 130 |
-
return None, f"Error: Endpoint not found (404). Try https://api.klingai.com/v1/
|
| 131 |
elif status_code == 401:
|
| 132 |
if service_code == 1000:
|
| 133 |
return None, "Error: Authentication failed (1000). Verify API keys are correct."
|
|
@@ -197,6 +197,7 @@ with gr.Blocks() as iface:
|
|
| 197 |
"""
|
| 198 |
# Kling AI Single-Reference Face Generator
|
| 199 |
Upload a PNG/JPEG image (<10 MB, ≥512x512 pixels) with a clear face to generate a transformed image using Kling AI API (reference strength 0.97). Avoid NSFW or sensitive content.
|
|
|
|
| 200 |
"""
|
| 201 |
)
|
| 202 |
with gr.Row():
|
|
|
|
| 14 |
# Kling AI API configuration (keys hardcoded as requested)
|
| 15 |
ACCESS_KEY_ID = "AGBGmadNd9hakFYfahytyQQJtN8CJmDJ"
|
| 16 |
ACCESS_KEY_SECRET = "dp3pAe4PpdmnAHCAPgEd3PyLmBQrkMde"
|
| 17 |
+
API_URL = "https://api.klingai.com/v1/generations" # Updated endpoint
|
| 18 |
|
| 19 |
def generate_jwt_token():
|
| 20 |
"""Generate JWT token for Kling AI API authentication."""
|
|
|
|
| 114 |
time.sleep(5)
|
| 115 |
|
| 116 |
logger.error("Image generation timed out")
|
| 117 |
+
return None, "Error: Image generation timed out. Try during off-peak hours (e.g., 2 AM IST) or check account status."
|
| 118 |
|
| 119 |
except requests.exceptions.HTTPError as e:
|
| 120 |
status_code = e.response.status_code if e.response else None
|
|
|
|
| 127 |
return None, "Error: Invalid request method (1202). Check https://klingai.com/global/dev for correct endpoint."
|
| 128 |
elif service_code == 1203:
|
| 129 |
return None, "Error: Resource does not exist (1203). Verify model or endpoint."
|
| 130 |
+
return None, f"Error: Endpoint not found (404). Try https://api.klingai.com/v1/image or check https://klingai.com/global/dev."
|
| 131 |
elif status_code == 401:
|
| 132 |
if service_code == 1000:
|
| 133 |
return None, "Error: Authentication failed (1000). Verify API keys are correct."
|
|
|
|
| 197 |
"""
|
| 198 |
# Kling AI Single-Reference Face Generator
|
| 199 |
Upload a PNG/JPEG image (<10 MB, ≥512x512 pixels) with a clear face to generate a transformed image using Kling AI API (reference strength 0.97). Avoid NSFW or sensitive content.
|
| 200 |
+
If you see a 404 error, check the correct API endpoint at https://klingai.com/global/dev.
|
| 201 |
"""
|
| 202 |
)
|
| 203 |
with gr.Row():
|