Get Task Details
curl --request GET \
--url https://api.kie.ai/api/v1/jobs/recordInfo \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.kie.ai/api/v1/jobs/recordInfo"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.kie.ai/api/v1/jobs/recordInfo', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kie.ai/api/v1/jobs/recordInfo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.kie.ai/api/v1/jobs/recordInfo"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.kie.ai/api/v1/jobs/recordInfo")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kie.ai/api/v1/jobs/recordInfo")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"model": "grok-imagine/text-to-image",
"state": "success",
"param": "{\"model\":\"grok-imagine/text-to-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Cinematic portrait...\",\"aspect_ratio\":\"3:2\"}}",
"resultJson": "{\"resultUrls\":[\"https://example.com/generated-content.jpg\"]}",
"failCode": "",
"failMsg": "",
"completeTime": 1698765432000,
"createTime": 1698765400000,
"updateTime": 1698765432000
}
}
Get Task Details
Query the status and results of any task created in the Market models
GET
/
api
/
v1
/
jobs
/
recordInfo
Get Task Details
curl --request GET \
--url https://api.kie.ai/api/v1/jobs/recordInfo \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.kie.ai/api/v1/jobs/recordInfo"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.kie.ai/api/v1/jobs/recordInfo', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kie.ai/api/v1/jobs/recordInfo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.kie.ai/api/v1/jobs/recordInfo"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.kie.ai/api/v1/jobs/recordInfo")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kie.ai/api/v1/jobs/recordInfo")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"model": "grok-imagine/text-to-image",
"state": "success",
"param": "{\"model\":\"grok-imagine/text-to-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Cinematic portrait...\",\"aspect_ratio\":\"3:2\"}}",
"resultJson": "{\"resultUrls\":[\"https://example.com/generated-content.jpg\"]}",
"failCode": "",
"failMsg": "",
"completeTime": 1698765432000,
"createTime": 1698765400000,
"updateTime": 1698765432000
}
}
Overview
Use this endpoint to query the status and results of any task created through Market model APIs. This is a unified query interface that works with all models under the Market category.This endpoint works with all Market models including Seedream, Grok Imagine, Kling, Claude, and any future models added to the Market.
API Endpoint
GET https://api.kie.ai/api/v1/jobs/recordInfo
Query Parameters
string
required
The unique task identifier returned when you created the task.Example:
task_12345678Request Example
curl -X GET "https://api.kie.ai/api/v1/jobs/recordInfo?taskId=task_12345678" \
-H "Authorization: Bearer YOUR_API_KEY"
const response = await fetch('https://api.kie.ai/api/v1/jobs/recordInfo?taskId=task_12345678', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const result = await response.json();
console.log('Task Status:', result.data.state);
console.log('Result:', result.data.resultJson);
import requests
response = requests.get(
'https://api.kie.ai/api/v1/jobs/recordInfo',
params={'taskId': 'task_12345678'},
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
result = response.json()
print('Task Status:', result['data']['state'])
print('Result:', result['data']['resultJson'])
Response Format
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"model": "grok-imagine/text-to-image",
"state": "success",
"param": "{\"model\":\"grok-imagine/text-to-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Cinematic portrait...\",\"aspect_ratio\":\"3:2\"}}",
"resultJson": "{\"resultUrls\":[\"https://example.com/generated-content.jpg\"]}",
"failCode": "",
"failMsg": "",
"completeTime": 1698765432000,
"createTime": 1698765400000,
"updateTime": 1698765432000
}
}
Response Fields
integer
Response status code.
200 indicates success.string
Response message. Typically
"success" for successful queries.object
The task data object containing all task information.
Show data properties
Show data properties
string
The unique identifier for this task.
string
The model used for this task (e.g.,
grok-imagine/text-to-image, seedream-4.0, kling-1.0).string
Current state of the task. See Task States below for details.Possible values:
waiting, queuing, generating, success, failstring
JSON string containing the original request parameters used to create the task.
string
JSON string containing the generated content URLs. Only present when
state is success.Example: {"resultUrls":["https://example.com/image.jpg"]}string
Error code if the task failed. Empty string if successful.
string
Error message if the task failed. Empty string if successful.
integer
Unix timestamp (in milliseconds) when the task completed.
integer
Unix timestamp (in milliseconds) when the task was created.
integer
Unix timestamp (in milliseconds) when the task was last updated.
integer
Generation progress (0-100). Only returned when model is
sora2 or sora2 pro.Task States
| State | Description | Action |
|---|---|---|
waiting | Task is queued and waiting to be processed | Continue polling |
queuing | Task is in the processing queue | Continue polling |
generating | Task is currently being processed | Continue polling |
success | Task completed successfully | Parse resultJson to get results |
fail | Task failed | Check failCode and failMsg for details |
Polling Best Practices
Recommended Polling Intervals
Recommended Polling Intervals
- Initial polls (first 30 seconds): Every 2-3 seconds
- After 30 seconds: Every 5-10 seconds
- After 2 minutes: Every 15-30 seconds
- Maximum polling duration: Stop after 10-15 minutes and investigate
Use exponential backoff to reduce server load and API costs.
Using Callbacks Instead of Polling
Using Callbacks Instead of Polling
For production applications, we strongly recommend using the
callBackUrl parameter when creating tasks:- No polling needed: Your server receives notifications automatically
- Lower API costs: Eliminates continuous polling requests
- Better performance: Immediate notifications when tasks complete
- Reduced latency: No delay between completion and notification
Handling Completed Tasks
Handling Completed Tasks
When
state is success:- Parse the
resultJsonstring to JSON - Extract the
resultUrlsarray - Download generated content immediately
- Store content in your own storage
Error Handling
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"model": "grok-imagine/text-to-image",
"state": "fail",
"param": "{\"model\":\"grok-imagine/text-to-image\",\"input\":{\"prompt\":\"...\"}}",
"resultJson": "",
"failCode": "422",
"failMsg": "Invalid prompt: prompt contains prohibited content",
"completeTime": 1698765432000,
"createTime": 1698765400000,
"updateTime": 1698765432000
}
}
Common Error Codes
| Code | Description | Solution |
|---|---|---|
401 | Unauthorized - Invalid or missing API key | Check your API key |
404 | Task not found | Verify the taskId is correct |
422 | Validation error in original request | Check the failMsg for details |
500 | Internal server error | Retry after a few minutes |
501 | Generation failed | Check failMsg for specific error details |
Example: Complete Polling Flow
Node.js
async function pollTaskStatus(taskId, maxAttempts = 60, interval = 5000) {
for (let attempt = 0; attempt < maxAttempts; attempt++) {
const response = await fetch(
`https://api.kie.ai/api/v1/jobs/recordInfo?taskId=${taskId}`,
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
const result = await response.json();
const { state, resultJson, failMsg } = result.data;
console.log(`Attempt ${attempt + 1}: State = ${state}`);
if (state === 'success') {
const results = JSON.parse(resultJson);
console.log('✅ Task completed!');
console.log('Results:', results.resultUrls);
return results;
}
if (state === 'fail') {
console.error('❌ Task failed:', failMsg);
throw new Error(failMsg);
}
// Still processing, wait before next poll
await new Promise(resolve => setTimeout(resolve, interval));
}
throw new Error('Task timed out after maximum attempts');
}
// Usage
try {
const results = await pollTaskStatus('task_12345678');
console.log('Generated content URLs:', results.resultUrls);
} catch (error) {
console.error('Error:', error.message);
}
Rate Limits
- Maximum query rate: 10 requests per second per API key
- Recommended interval: 2-5 seconds between polls
Excessive polling may result in rate limiting. Use callbacks for production applications.
Related Resources
Market Overview
Explore all available models
Get Account Credits
Check your remaining credits
Authorizations
All APIs require authentication via Bearer Token.
Get API Key:
- Visit API Key Management Page to get your API Key
Usage: Add to request header: Authorization: Bearer YOUR_API_KEY
Note:
- Keep your API Key secure and do not share it with others
- If you suspect your API Key has been compromised, reset it immediately in the management page
Query Parameters
The unique task identifier returned when you created the task.
Example:
"task_12345678"
Response
Request successful
Response status code
- 200: Success - Request has been processed successfully
- 401: Unauthorized - Authentication credentials are missing or invalid
- 402: Insufficient Credits - Account does not have enough credits to perform the operation
- 404: Not Found - The requested resource or endpoint does not exist
- 422: Validation Error - The request parameters failed validation checks
- 429: Rate Limited - Request limit has been exceeded for this resource
- 455: Service Unavailable - System is currently undergoing maintenance
- 500: Server Error - An unexpected error occurred while processing the request
- 501: Generation Failed - Content generation task failed
- 505: Feature Disabled - The requested feature is currently disabled
Available options:
200, 401, 402, 404, 422, 429, 455, 500, 501, 505 Response message, error description when failed
Example:
"success"
The task data object containing all task information
Show child attributes
Show child attributes
