Skip to main content

Get Task Details

Query the status and results of any task created in the Market models

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.apikley.ru/api/v1/jobs/recordInfo

Query Parameters

taskId
string
required
The unique task identifier returned when you created the task.Example: task_12345678

Request Example

curl -X GET "https://api.apikley.ru/api/v1/jobs/recordInfo?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"

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

code
integer
Response status code. 200 indicates success.
message
string
Response message. Typically "success" for successful queries.
data
object
The task data object containing all task information.

Task States

StateDescriptionAction
waitingTask is queued and waiting to be processedContinue polling
queuingTask is in the processing queueContinue polling
generatingTask is currently being processedContinue polling
successTask completed successfullyParse resultJson to get results
failTask failedCheck failCode and failMsg for details

Polling Best Practices

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
See individual model documentation for callback implementation details.
When state is success:
  1. Parse the resultJson string to JSON
  2. Extract the resultUrls array
  3. Download generated content immediately
  4. Store content in your own storage
Important: Generated content URLs typically expire after 24 hours.

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

CodeDescriptionSolution
401Unauthorized - Invalid or missing API keyCheck your API key
404Task not foundVerify the taskId is correct
422Validation error in original requestCheck the failMsg for details
500Internal server errorRetry after a few minutes
501Generation failedCheck 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.apikley.ru/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.

OpenAPI

market/common/get-task-detail.json get /api/v1/jobs/recordInfo
openapi: 3.0.0
info:
  title: Kie.ai Common API
  description: Kie.ai Common API Documentation - Task Status Query
  version: 1.0.0
  contact:
    name: Technical Support
    email: [email protected]
servers:
  - url: https://api.kie.ai
    description: API Server
security:
  - BearerAuth: []
paths:
  /api/v1/jobs/recordInfo:
    get:
      summary: Get Task Details
      description: >-
        Query the status and results of any task created in the Market models.
        This is a unified query interface that works with all models under the
        Market category.


        ### Supported Models

        This endpoint works with all Market models including:

        - **Seedream**: seedream, seedream-v4-text-to-image, etc.

        - **Grok Imagine**: text-to-image, image-to-video, text-to-video,
        upscale

        - **Kling**: text-to-video, image-to-video models

        - **ElevenLabs**: Audio processing models

        - **Claude**: Language models

        - **And any future models added to the Market**


        ### Task States

        - **waiting**: Task is queued and waiting to be processed

        - **queuing**: Task is in the processing queue

        - **generating**: Task is currently being processed

        - **success**: Task completed successfully

        - **fail**: Task failed


        ### Best Practices

        - **Use callbacks for production**: Include `callBackUrl` when creating
        tasks to avoid polling

        - **Implement exponential backoff**: Start with 2-3 second intervals,
        increase gradually

        - **Handle timeouts**: Stop polling after 10-15 minutes

        - **Download results immediately**: Generated content URLs typically
        expire after 24 hours
      operationId: get-task-details
      parameters:
        - name: taskId
          in: query
          description: The unique task identifier returned when you created the task.
          required: true
          schema:
            type: string
            example: task_12345678
      responses:
        '200':
          description: Request successful
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        description: The task data object containing all task information
                        properties:
                          taskId:
                            type: string
                            description: The unique identifier for this task
                            example: task_12345678
                          model:
                            type: string
                            description: >-
                              The model used for this task (e.g.,
                              grok-imagine/text-to-image, seedream-4.0,
                              kling-1.0)
                            example: grok-imagine/text-to-image
                          state:
                            type: string
                            description: Current state of the task
                            enum:
                              - waiting
                              - queuing
                              - generating
                              - success
                              - fail
                            example: success
                          param:
                            type: string
                            description: >-
                              JSON string containing the original request
                              parameters used to create the task
                            example: >-
                              {"model":"grok-imagine/text-to-image","callBackUrl":"https://your-domain.com/api/callback","input":{"prompt":"Cinematic
                              portrait...","aspect_ratio":"3:2"}}
                          resultJson:
                            type: string
                            description: >-
                              JSON string containing the generated content URLs.
                              Only present when state is success. Structure
                              depends on outputMediaType: {resultUrls: []} for
                              image/media/video, {resultObject: {}} for text
                            example: >-
                              {"resultUrls":["https://example.com/generated-content.jpg"]}
                          failCode:
                            type: string
                            description: >-
                              Error code if the task failed. Empty string if
                              successful
                            example: ''
                          failMsg:
                            type: string
                            description: >-
                              Error message if the task failed. Empty string if
                              successful
                            example: ''
                          costTime:
                            type: integer
                            format: int64
                            description: >-
                              Processing time in milliseconds (available when
                              successful)
                            example: 15000
                          completeTime:
                            type: integer
                            format: int64
                            description: >-
                              Completion timestamp (Unix timestamp in
                              milliseconds)
                            example: 1698765432000
                          createTime:
                            type: integer
                            format: int64
                            description: >-
                              Creation timestamp (Unix timestamp in
                              milliseconds)
                            example: 1698765400000
                          updateTime:
                            type: integer
                            format: int64
                            description: Update timestamp (Unix timestamp in milliseconds)
                            example: 1698765432000
              example:
                code: 200
                msg: 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: ''
                  costTime: 15000
                  completeTime: 1698765432000
                  createTime: 1698765400000
                  updateTime: 1698765432000
        '400':
          description: Bad Request - Missing or invalid taskId parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
              example:
                code: 400
                msg: taskId parameter is required
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
              example:
                code: 401
                msg: Unauthorized
        '404':
          description: Task Not Found - The specified taskId does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
              example:
                code: 404
                msg: Task not found
        '429':
          description: Rate Limited - Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
              example:
                code: 429
                msg: Rate limit exceeded
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 200
            - 401
            - 402
            - 404
            - 422
            - 429
            - 455
            - 500
            - 501
            - 505
          description: >-
            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
        msg:
          type: string
          description: Response message, error description when failed
          example: success
  responses:
    Error:
      description: Server Error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        All APIs require authentication via Bearer Token.


        Get API Key:

        1. Visit [API Key Management Page](https://kie.ai/api-key) 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


To find navigation and other pages in this documentation, fetch the llms.txt file at: https://docs.kie.ai/llms.txt