> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Task Info

> Query the status and results of all model generation tasks.

## API Endpoint

```
GET https://api.crun.ai/api/v1/client/job/TaskInfo
```

<Info>
  This endpoint is used to query the execution status and retrieve the results of tasks created via the `/api/v1/client/job/CreateTask` API.
  It provides a unified query interface that is compatible with **all models** under the *Models* category, enabling consistent task tracking and result retrieval regardless of the underlying model.
</Info>

## Query Parameters

<ParamField query="task_id" type="string" required>
  The unique task identifier returned when you created the task.

  **Example**: `task_12345678`
</ParamField>

## Request Example

<CodeGroup>
  ```bash cURL theme={null} theme={null}
  curl -X GET "https://api.crun.ai/api/v1/client/job/TaskInfo?task_id=task_12345678" \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json"

  ```

  ```python Python theme={null} theme={null}
  import requests

  API_KEY = "YOUR_API_KEY"

  headers = {
    "X-API-KEY": API_KEY,
    "Content-Type": "application/json"
  }
  params = {
    "task_id": "task_12345678",
  }

  GET_TASK_STATUS_URL = "https://api.crun.ai/api/v1/client/job/TaskInfo"

  response = requests.get(GET_TASK_STATUS_URL, params=params, headers=headers)
  print(response.json())
  ```

  ```javascript Node.js theme={null} theme={null}
  const API_KEY = "YOUR_API_KEY";
  const taskId = "task_12345678";

  const url = new URL("https://api.crun.ai/api/v1/client/job/TaskInfo");
  url.searchParams.append("task_id", taskId);

  fetch(url.toString(), {
    method: "GET",
    headers: {
        "X-API-KEY": API_KEY,
        "Content-Type": "application/json",
    },
  })
    .then(res => res.json())
    .then(data => {
        console.log(data);
    })
    .catch(err => {
        console.error("Request failed:", err);
    });
  ```
</CodeGroup>

<ResponseExample title="Response Example">
  ```json Task Running theme={null}
  {
    "code": 200,
    "message": "success",
    "data": {
      "task_id": "d6956973-2f17-43d4-8514-af6cc3a2f55d",
      "provider": "Google",
      "model_version": "nano-banana",
      "status": "running",
      "param": {
        "model": "google/nano-banana",
        "callback_url": null,
        "input": {
          "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A teenager, painted with ...",
          "output_format": "png",
          "aspect_ratio": "16:9"
        }
      },
      "create_at": 1768900378,
      "result": null,
      "credits": 3,
      "duration_s": null,
      "complete_at": null,
      "source": "api"
    }
  }
  ```

  ```json Task Success theme={null}
  {
    "code": 200,
    "message": "success",
    "data": {
      "task_id": "d6956973-2f17-43d4-8514-af6cc3a2f55d",
      "provider": "Google",
      "model_version": "nano-banana",
      "status": "success",
      "param": {
        "model": "google/nano-banana",
        "callback_url": null,
        "input": {
          "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A teenager, painted with ...",
          "output_format": "png",
          "aspect_ratio": "16:9"
        }
      },
      "create_at": 1768900378,
      "result": {
        "code": 200,
        "message": "generation success",
        "media_urls": [
          "https://example.com/example.png"
        ],
        "usage": {
          "prompt_tokens": 126,
          "completion_tokens": 32,
          "total_tokens": 158
        }
      },
      "credits": 3,
      "duration_s": 137,
      "complete_at": 1768900515,
      "source": "api"
    }
  }
  ```

  ```json Task Failed theme={null}
  {
    "code": 200,
    "message": "success",
    "data": {
      "task_id": "d6956973-2f17-43d4-8514-af6cc3a2f55d",
      "provider": "Google",
      "model_version": "nano-banana",
      "status": "failed",
      "param": {
        "model": "google/nano-banana",
        "callback_url": null,
        "input": {
          "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A teenager, painted with ...",
          "output_format": "png",
          "aspect_ratio": "16:9"
        }
      },
      "create_at": 1768900378,
      "result": {
        "code": 501,
        "message": "generation failed"
      },
      "credits": 0,
      "duration_s": 137,
      "complete_at": 1768900515,
      "source": "api"
    }
  }
  ```
</ResponseExample>

## Response Format

<ResponseField name="code" type="integer">
  Response status code. 200 indicates the request was successfully processed (the task was found and returned, regardless of execution result).
</ResponseField>

<ResponseField name="message" type="string">
  Response message. Typically `"success"`.
</ResponseField>

<ResponseField name="data" type="object">
  The task data object containing all task information.

  <Expandable title="data properties">
    <ResponseField name="task_id" type="string">
      The unique identifier of the task.
    </ResponseField>

    <ResponseField name="provider" type="string">
      The model provider name.

      **Examples**: `Google`, `Wan`, `Bytedance`
    </ResponseField>

    <ResponseField name="model_version" type="string">
      A specific model version used when creating a task.
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status of the task. See [Task Status](#task-status-enum) below for details.

      **Possible values**: `pending`, `running`, `success`, `failed`
    </ResponseField>

    <ResponseField name="param" type="object">
      Original parameters used to create the task.

      <Expandable title="param properties">
        <ResponseField name="model" type="string">
          Model identifier used when creating the task.
        </ResponseField>

        <ResponseField name="callback_url" type="string | null">
          Webhook callback URL configured for this task.
        </ResponseField>

        <ResponseField name="input" type="object">
          Model-specific input parameters. The structure varies depending on the selected model.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="result" type="object | null">
      Task generation results.
      valid value is returned only if the task status is `success` or `failed`; otherwise, `null` is returned.

      <Expandable title="result properties">
        <ResponseField name="code" type="integer">
          Task generation result status code. `200` indicates generation success. Non-200 values indicate generation failure.
        </ResponseField>

        <ResponseField name="message" type="string">
          Explanation of task success or failure.
        </ResponseField>

        <ResponseField name="media_urls" type="array<string>">
          Task generated media URLs.
          It will only return if the task status is `success`.
        </ResponseField>

        <ResponseField name="usage" type="object">
          Optional token usage information returned when available. This field is a dictionary and may include values such as `prompt_tokens`, `completion_tokens`, and `total_tokens`.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="credits" type="number">
      Credits consumed by tasks. When the task status is `pending` or `running`, it indicates credits reserved in advance; when the task status is `success` or `failed`, it indicates the actual consumed credits.
    </ResponseField>

    <ResponseField name="create_at" type="integer">
      Unix timestamp (in seconds) when the task was created.
    </ResponseField>

    <ResponseField name="complete_at" type="integer | null">
      Unix timestamp (in milliseconds) when the task was created.
      `null` if the task has not finished.
    </ResponseField>

    <ResponseField name="duration_s" type="integer | null">
      Task execution duration in seconds. Null if the task has not completed.
    </ResponseField>

    <ResponseField name="source" type="string">
      Source of task creation.
    </ResponseField>
  </Expandable>
</ResponseField>

## Task Status Enum

| Status    | Description                                | Action                                                |
| --------- | ------------------------------------------ | ----------------------------------------------------- |
| `pending` | Task is queued and waiting to be processed | Continue polling                                      |
| `running` | Task is currently being processed          | Continue polling                                      |
| `success` | Task successfully completed                | Access result.media\_url to get the result            |
| `failed`  | Task failed                                | Access result object  to view error code and message. |

## Get Task Result Best Practices

<AccordionGroup>
  <Accordion title="Recommended Polling Intervals">
    * **Polling Interval**: Use a polling interval between 15 and 30 seconds
    * **Interval Dynamically**: For long-running video generation tasks, consider increasing the polling interval dynamically
    * **Delayed Polling**: Wait at least one polling interval before the first status check to reduce unnecessary requests
    * **Maximum polling duration**: Stop after 15-20 minutes and investigate

    <Warning>
      Excessive polling may result in rate limiting. Use callbacks for production applications.
    </Warning>
  </Accordion>

  <Accordion title="Using Callbacks Instead of Polling">
    For production applications, we strongly recommend using the `callback_url` 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

    <Tip>
      Recommended method
    </Tip>
  </Accordion>

  <Accordion title="Handling Completed Tasks">
    When `status` is `success`:

    1. Retrieve the task result from the `result` field in the response
    2. Extract generated media URLs from `result.media_urls`
    3. Download media files to your own storage
    4. Persist result metadata to your storage or database

    <Warning>
      **Important**: Generated media URLs are typically permanently deleted after 14 days
    </Warning>
  </Accordion>
</AccordionGroup>

## Common Error Codes

| Code  | Description                               | Solution                                                    |
| ----- | ----------------------------------------- | ----------------------------------------------------------- |
| `401` | Unauthorized - Invalid or missing API key | Check your API key                                          |
| `404` | Task not found                            | Verify the task\_id is correct                              |
| `429` | Exceeding the request rate limit          | Reduce request frequency                                    |
| `500` | Internal server error                     | Retry after a few minutes                                   |
| `501` | Generation failed                         | View the `result` object to get the error code and message. |

## Rate Limits

* **Maximum query rate**: 15 requests per second, per account limit
* **Recommended interval**: 15-30 seconds between polls

## Related Resources

<CardGroup cols={2}>
  <Card title="Models Overview" icon="store" href="/models/quickstart">
    Explore all available models
  </Card>

  <Card title="Get Account Credits" icon="coins" href="/common-api/get-account-credits">
    Check your remaining credits
  </Card>
</CardGroup>


## OpenAPI

````yaml models/common/get-task-info.json get /api/v1/client/job/TaskInfo
openapi: 3.0.0
info:
  title: Get Task Status
  description: Query the status and results of all model generation tasks.
  version: 1.0.0
  contact:
    name: Technical Support
    email: support@crun.ai
servers:
  - url: https://api.crun.ai
    description: API Server
security:
  - ApiKeyAuth: []
paths:
  /api/v1/client/job/TaskInfo:
    get:
      summary: Query the status and results of all model generation tasks.
      operationId: get-task-info
      parameters:
        - name: task_id
          in: query
          required: true
          description: Task ID used to retrieve task result.
          schema:
            type: string
            minLength: 36
            maxLength: 36
            example: task_1234567
      responses:
        '200':
          description: Task information retrieved successfully or task not found.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/TaskResponseModel'
        '401':
          description: API key missing
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
              example:
                code: 401
                message: API key missing
                data: null
        '403':
          description: API key disabled
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
              example:
                code: 403
                message: API key disabled
                data: null
        '404':
          description: Task not found
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
              example:
                code: 404
                message: Task not found
                data: null
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          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
        message:
          type: string
          description: Response message
        data:
          nullable: true
      required:
        - code
        - message
    TaskResponseModel:
      type: object
      description: Task record and result information.
      properties:
        task_id:
          type: string
          description: Task ID
          example: task_1234567
        provider:
          type: string
          description: Model provider
          example: bytedance
        model_version:
          type: string
          description: Model version
          example: seedream-4.5
        status:
          type: string
          description: task status
          enum:
            - pending
            - running
            - success
            - failed
          example: success
        param:
          type: object
          description: Original parameters used to create the task.
        create_at:
          type: integer
          description: Task creation timestamp (seconds)
          example: 1715750400
        result:
          type: object
          nullable: true
          description: >-
            Task result. When available, this object can include token usage
            information.
          properties:
            code:
              type: integer
              description: Task generation result status code.
            message:
              type: string
              description: Task success or failure message.
            media_urls:
              type: array
              description: Generated media URLs returned for successful tasks.
              items:
                type: string
            usage:
              type: object
              description: >-
                Optional token usage information. This field is a dictionary
                (Dict[str, Any]) and may include values such as prompt_tokens,
                completion_tokens, and total_tokens.
              additionalProperties: true
        credits:
          type: number
          description: >-
            Credits consumed by tasks. When the task status is `pending` or
            `running`, it indicates credits reserved in advance; when the task
            status is `success` or `failed`, it indicates the actual consumed
            credits.
          example: 3
        duration_s:
          type: integer
          nullable: true
          description: Task execution duration in seconds
          example: 12
        complete_at:
          type: integer
          nullable: true
          description: Task completion timestamp (seconds)
          example: 1715750412
        source:
          type: string
          description: Task source
          enum:
            - api
            - playground
          example: api
      required:
        - task_id
        - provider
        - model_version
        - status
        - param
        - create_at
        - source
  responses:
    Error:
      description: Server Error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        All APIs require authentication via API Key.


        Get API Key:

        1. Visit [API Key Management Page](https://crun.ai/user-api-key) to get
        your API Key


        Usage:

        Add to request header:


        x-api-key: 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

````