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

# Query Task

export const QueryTaskOfficial = ({taskId}) => {
  const baseUrl = `https://aiandgpu.com/api/v3/contents/generations/tasks/${taskId}`;
  const curlExample = `curl -X GET '${baseUrl}' \\
-H 'Content-Type: application/json' \\
-H 'Authorization: Bearer <YOUR_API_KEY>'`;
  const pythonExample = `import requests

url = "${baseUrl}"

headers = {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json",
}

response = requests.get(url, headers=headers)

print(response.json())`;
  const jsExample = `const response = await fetch('${baseUrl}', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <YOUR_API_KEY>',
    'Content-Type': 'application/json',
  },
});

const data = await response.json();
console.log(data);`;
  const goExample = `package main

import (
\t"fmt"
\t"io"
\t"net/http"
)

func main() {
\turl := "${baseUrl}"

\treq, _ := http.NewRequest("GET", url, nil)

\treq.Header.Add("Authorization", "Bearer <YOUR_API_KEY>")
\treq.Header.Add("Content-Type", "application/json")

\tres, _ := http.DefaultClient.Do(req)
\tdefer res.Body.Close()

\tbody, _ := io.ReadAll(res.Body)
\tfmt.Println(string(body))
}`;
  const javaExample = `import java.net.http.*;
import java.net.URI;

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("${baseUrl}"))
    .header("Authorization", "Bearer <YOUR_API_KEY>")
    .header("Content-Type", "application/json")
    .GET()
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());`;
  const phpExample = `<?php

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "${baseUrl}",
    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 <YOUR_API_KEY>",
        "Content-Type: application/json",
    ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;`;
  const csharpExample = `using System.Net.Http;

var client = new HttpClient();

var request = new HttpRequestMessage(HttpMethod.Get, "${baseUrl}");
request.Headers.Add("Authorization", "Bearer <YOUR_API_KEY>");
request.Headers.TryAddWithoutValidation("Content-Type", "application/json");

var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);`;
  return <>
      <h2>Request Examples</h2>

      <CodeGroup>
        <CodeBlock language="shellscript" filename="cURL">
          {curlExample}
        </CodeBlock>
        <CodeBlock language="python" filename="Python">
          {pythonExample}
        </CodeBlock>
        <CodeBlock language="javascript" filename="JavaScript">
          {jsExample}
        </CodeBlock>
        <CodeBlock language="go" filename="Go">
          {goExample}
        </CodeBlock>
        <CodeBlock language="java" filename="Java">
          {javaExample}
        </CodeBlock>
        <CodeBlock language="php" filename="PHP">
          {phpExample}
        </CodeBlock>
        <CodeBlock language="csharp" filename="C#">
          {csharpExample}
        </CodeBlock>
      </CodeGroup>
    </>;
};

export const ByteDanceChatResponse = ({successJson, successTitle = "200 - Success"}) => {
  const error400 = `{
    "error": {
        "code": "invalid_params",
        "message": "parameter 'messages' is required",
        "param": null,
        "type": "invalid_request_error"
    }
}`;
  const error401 = `{
    "error": {
        "code": "auth_missing",
        "message": "Missing Authorization Header",
        "param": null,
        "type": "authentication_error"
    }
}`;
  const error402 = `{
   "error": {
        "code": "insufficient_balance",
        "message": "Insufficient balance",
        "param": null,
        "type": "authentication_error"
   }
}`;
  const error403 = `{
   "error": {
        "code": "permission_denied",
        "message": "Permission denied on this model",
        "param": null,
        "type": "authentication_error"
   }
}`;
  const error404 = `{
   "error": {
        "code": "invalid_url",
        "message": "Invalid URL",
        "param": null,
        "type": "invalid_request_error"
   }
}`;
  const error429 = `{
   "error": {
        "code": "rate_limit_exceeded",
        "message": "Too many requests",
        "param": null,
        "type": "rate_limit_error"
   }
}`;
  const error500 = `{
    "error": {
        "code": "internal_server_error",
        "message": "Internal server error",
        "param": null,
        "type": "server_error"
   }
}`;
  return <>
      <h2>Response Examples</h2>

      <CodeGroup>
        <CodeBlock language={"json"} filename={successTitle}>
          {successJson}
        </CodeBlock>
        <CodeBlock language="json" filename="400 - Bad Request">
          {error400}
        </CodeBlock>
        <CodeBlock language="json" filename="401 - Unauthorized">
          {error401}
        </CodeBlock>
        <CodeBlock language="json" filename="402 - Insufficient Balance">
          {error402}
        </CodeBlock>
        <CodeBlock language="json" filename="403 - Permission Denied">
          {error403}
        </CodeBlock>
        <CodeBlock language="json" filename="404 - Invalid URL">
          {error404}
        </CodeBlock>
        <CodeBlock language="json" filename="429 - Too Many Requests">
          {error429}
        </CodeBlock>
        <CodeBlock language="json" filename="500 - Internal Server Error">
          {error500}
        </CodeBlock>
      </CodeGroup>
    </>;
};

## Authorization

* **Auth Type**: `Bearer Auth` (In: `header`)
* **Format**: `Authorization: Bearer <YOUR_API_KEY>`
* **Description**: Use `Bearer <YOUR_API_KEY>`. Format: `Authorization: Bearer sk-xxxxxx.`
* **API Key**: where <strong>API Key</strong> is your <a href="https://developer.aiandgpu.com" target="_blank" rel="noopener noreferrer">AGCloud API KEY</a>

## Path Parameters

<ParamField path="id" type="string" required>
  The processing task ID.
</ParamField>

<QueryTaskOfficial taskId="<your-task-id-here>" />

<ByteDanceChatResponse
  successJson={`{
    "id": "xxxxx",
    "model": "doubao-seedance-2-0-filter-off",
    "status": "succeeded",
    "content": {
        "video_url": "https://xxxxxx.mp4"
    },
    "usage": {
        "completion_tokens": 324900,
        "total_tokens": 324900
    },
    "created_at": 1774708030,
    "updated_at": 1774708309,
    "seed": 75036,
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 15,
    "framespersecond": 24,
    "service_tier": "default",
    "execution_expires_after": 172800,
    "generate_audio": true,
    "draft": false
}
`}
/>

## Field Description

| Field                     | Type      | Description                                                                                                 |
| :------------------------ | :-------- | :---------------------------------------------------------------------------------------------------------- |
| `id`                      | `string`  | Task identifier (same value as `result.id` from the create task response when present).                     |
| `model`                   | `string`  | Model used for generation.                                                                                  |
| `status`                  | `string`  | Task lifecycle status (e.g. `queued`, `pending`, `running`, `succeeded`, `failed`, `expired`, `cancelled`). |
| `content`                 | `object`  | Result payload when the task completes; shape may vary by status.                                           |
| `content.video_url`       | `string`  | URL of the generated video when `status` indicates success.                                                 |
| `usage`                   | `object`  | Token usage for this task.                                                                                  |
| `usage.completion_tokens` | `integer` | Tokens attributed to completion / output.                                                                   |
| `usage.total_tokens`      | `integer` | Total tokens counted for billing or reporting.                                                              |
| `created_at`              | `integer` | Task creation time (Unix timestamp).                                                                        |
| `updated_at`              | `integer` | Last update time (Unix timestamp).                                                                          |
| `seed`                    | `integer` | Random seed used for this generation when applicable.                                                       |
| `resolution`              | `string`  | Output resolution (e.g. `720p`).                                                                            |
| `ratio`                   | `string`  | Output aspect ratio.                                                                                        |
| `duration`                | `integer` | Video duration in seconds.                                                                                  |
| `framespersecond`         | `integer` | Frame rate used for encoding.                                                                               |
| `service_tier`            | `string`  | Service tier applied to the task.                                                                           |
| `execution_expires_after` | `integer` | Task execution expiry window from creation (seconds), when returned.                                        |
| `generate_audio`          | `boolean` | Whether audio output was requested.                                                                         |
| `draft`                   | `boolean` | Whether generation ran in draft mode.                                                                       |
