AkashKumarave commited on
Commit
28842aa
·
verified ·
1 Parent(s): deafa91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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-singapore.klingai.com/v1/images/image2image" # Updated endpoint
18
 
19
  def generate_jwt_token():
20
  """Generate JWT token for Kling AI API authentication."""
@@ -81,7 +81,7 @@ def generate_image(image, prompt=""):
81
  return None, "Error: No task ID returned. Check API endpoint or keys at https://app.klingai.com/global/dev."
82
 
83
  # Poll for task completion
84
- status_url = f"https://api-singapore.klingai.com/v1/tasks/{task_id}"
85
  for _ in range(60): # Poll for up to 5 minutes
86
  logger.debug(f"Polling status at {status_url}")
87
  status_response = requests.get(status_url, headers=headers, timeout=30)
@@ -128,7 +128,7 @@ def generate_image(image, prompt=""):
128
  return None, "Error: Invalid request method (1202). Check https://app.klingai.com/global/dev for correct endpoint."
129
  elif service_code == 1203:
130
  return None, "Error: Resource does not exist (1203). Verify model or endpoint."
131
- return None, f"Error: Endpoint not found (404). Check https://app.klingai.com/global/dev for the correct endpoint."
132
  elif status_code == 401:
133
  if service_code == 1000:
134
  return None, "Error: Authentication failed (1000). Verify API keys are correct."
 
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/images/image2image" # Correct endpoint
18
 
19
  def generate_jwt_token():
20
  """Generate JWT token for Kling AI API authentication."""
 
81
  return None, "Error: No task ID returned. Check API endpoint or keys at https://app.klingai.com/global/dev."
82
 
83
  # Poll for task completion
84
+ status_url = f"https://api.klingai.com/v1/tasks/{task_id}" # Updated status endpoint
85
  for _ in range(60): # Poll for up to 5 minutes
86
  logger.debug(f"Polling status at {status_url}")
87
  status_response = requests.get(status_url, headers=headers, timeout=30)
 
128
  return None, "Error: Invalid request method (1202). Check https://app.klingai.com/global/dev for correct endpoint."
129
  elif service_code == 1203:
130
  return None, "Error: Resource does not exist (1203). Verify model or endpoint."
131
+ return None, f"Error: Endpoint not found (404). Verify https://api.klingai.com/v1/images/image2image at https://app.klingai.com/global/dev."
132
  elif status_code == 401:
133
  if service_code == 1000:
134
  return None, "Error: Authentication failed (1000). Verify API keys are correct."