Development Guide
This guide helps you integrate our API services into your application.
Asynchronous Processing
Our API uses an asynchronous processing model:
- Submit a task: send a generation request and receive a task ID
- Poll status: periodically check task status
- Get results: fetch generation results when the task completes
Polling example
import time
import requests
def wait_for_completion(api_key, task_id, max_wait=300):
"""Poll the task until it completes"""
url = f"https://api.openveer.com/v1/tasks/{task_id}"
headers = {"Authorization": f"Bearer {api_key}"}
start_time = time.time()
while time.time() - start_time < max_wait:
data = requests.get(url, headers=headers).json()["data"]
status = data["status"]
if status == "completed":
return data["result"]
elif status in ("failed", "cancelled"):
raise Exception(f"Task {status}: {data.get('error')}")
time.sleep(2) # wait 2 seconds before polling again
raise Exception("Task timeout")Error Handling
Common errors
| Status | Description | Resolution |
|---|---|---|
| 400 | Invalid request parameters | Check request parameters and format |
| 401 | Authentication failed | Verify your API key |
| 402 | Insufficient balance | Top up your account balance |
| 429 | Rate limit exceeded | Reduce request frequency |
| 500 | Server error | Retry later |
Example
import requests
response = requests.post(
"https://api.openveer.com/v1/images/generations",
headers={"Authorization": f"Bearer {api_key}"},
json={"model": "gpt-4o-image", "prompt": "a cute panda"},
)
if response.status_code != 200:
error = response.json().get("error", {})
if response.status_code == 401:
print("Invalid API key")
elif response.status_code == 402:
print("Insufficient account balance")
else:
print(f"Error: {error.get('message')}")Best Practices
- Caching: generated image/video links are valid for 24 hours
- Retries: implement exponential backoff on transient errors
- Monitoring: regularly check API usage and quotas
- Security: keep your API key secure
Support
If you run into issues during development, you can get help via:
- Email: zhihong@openveer.com
- Live chat: visit our website
- Docs: browse the full API documentation
This documentation is built and hosted on Mintlify, a developer documentation platform.