Quick Start
This guide helps you complete your first API call in minutes.
1) Create an API Key
V2Fun uses API keys for authentication. Open the API Console, sign in or register for a V2Fun account on the corresponding regional site, then select Create API Key. Copy and securely store the full Key immediately after creation. It is shown only once and cannot be viewed again after you close the dialog. If you already have a valid Key and have saved its full value, continue to the next step. Eligible accounts receive 100 API credits after successfully creating their first API Key, once per account.
2) Authentication
All API requests must use Bearer Token authentication. Include your API key in the HTTP header:
Authorization: Bearer YOUR_API_KEY3) Send your first request
Let us generate an image from a text prompt using the image generation API.
curl -X POST "https://api.v2fun.ai/api/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image",
"prompt": "A beautiful sunset over the mountains",
"size": "1024x1024"
}'const response = await fetch("https://api.v2fun.ai/api/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "qwen-image",
prompt: "A beautiful sunset over the mountains",
size: "1024x1024"
})
});
const data = await response.json();
console.log(data);import requests
url = "https://api.v2fun.ai/api/v1/images/generations"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"model": "qwen-image",
"prompt": "A beautiful sunset over the mountains",
"size": "1024x1024"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
String body = "{\"model\":\"qwen-image\",\"prompt\":\"A beautiful sunset over the mountains\",\"size\":\"1024x1024\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.v2fun.ai/api/v1/images/generations"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());4) Response example
Since V2Fun API uses a task-based workflow, most requests return immediately with a task_uuid.
{
"task_uuid": "fa3c24dc-22bf-4163-9ab9-f9836b605638",
"task_type": "image_generation",
"model": "qwen-image",
"status": "QUEUED",
"created_at": 1715358176,
"queue_position": 0,
"estimated_queue_time": 0
}5) Check task status
Because the API is task-based, results are usually returned asynchronously. Use the task ID to query status and results.
Endpoint
GET https://api.v2fun.ai/api/v1/images/generations/{task_uuid}
Request examples
curl -X GET "https://api.v2fun.ai/api/v1/images/generations/{task_uuid}" \
-H "Authorization: Bearer YOUR_API_KEY"const response = await fetch(
`https://api.v2fun.ai/api/v1/images/generations/${task_uuid}`,
{
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY"
}
}
);
const data = await response.json();
console.log(data);import requests
url = f"https://api.v2fun.ai/api/v1/images/generations/{task_uuid}"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
print(response.json())import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.v2fun.ai/api/v1/images/generations/" + taskUuid))
.header("Authorization", "Bearer YOUR_API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());Response example
{
"task_uuid": "fa3c24dc-22bf-4163-9ab9-f9836b605638",
"task_type": "image_generation",
"model": "qwen-image",
"status": "COMPLETED",
"created_at": 1715358176,
"completed_at": 1715358276,
"result": [
"images/9b895fbe-cb3c-4704-aaba-bbd717f3f16e.png"
],
"metadata": {
"downloads": [
{
"asset_path": "images/9b895fbe-cb3c-4704-aaba-bbd717f3f16e.png",
"download_url": "https://asset.v2fun.ai/download/images/9b895fbe-cb3c-4704-aaba-bbd717f3f16e.png",
"download_expires_at": 1786525274
}
]
}
}Usage notes
- You may need to poll this endpoint until the task is completed. To avoid excessive requests, we recommend polling every 2-5 seconds.
- When
status = COMPLETED, theresultfield will contain the output.
Next steps
Now that you have made your first API request, explore the scenario guides below to learn how to chain V2Fun's atomic APIs into production workflows:
TIP
Click a scenario below to see the full API chaining logic, code examples, and best practices.
