> ## 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 Chat Result

> Query the result of an asynchronous chat task using the task ID

export const QueryResultRequest = () => {
  const curlExample = `curl --request GET \\
  --url https://aiandgpu.com/v1/tasks/{task_id} \\
  --header 'Authorization: Bearer <YOUR_API_KEY>'`;
  const pythonExample = `import requests

task_id = "f8b30625-e38d-4950-8e13-76b72cfcb965"
url = f"https://aiandgpu.com/v1/tasks/{task_id}"

headers = {
    "Authorization": "Bearer <YOUR_API_KEY>"
}

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

print(response.json())`;
  const jsExample = `const taskId = 'f8b30625-e38d-4950-8e13-76b72cfcb965';

const options = {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <YOUR_API_KEY>'
  }
};

fetch(\`https://aiandgpu.com/v1/tasks/\${taskId}\`, options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));`;
  const goExample = `package main

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

func main() {
\ttaskId := "f8b30625-e38d-4950-8e13-76b72cfcb965"
\turl := "https://aiandgpu.com/v1/tasks/" + taskId

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

\treq.Header.Add("Authorization", "Bearer <YOUR_API_KEY>")

\tres, _ := http.DefaultClient.Do(req)

\tdefer res.Body.Close()
\tbody, _ := io.ReadAll(res.Body)

\tfmt.Println(string(body))
}`;
  const javaExample = `HttpResponse<String> response = Unirest.get("https://aiandgpu.com/v1/tasks/f8b30625-e38d-4950-8e13-76b72cfcb965")
  .header("Authorization", "Bearer <YOUR_API_KEY>")
  .asString();

System.out.println(response.getBody());`;
  const phpExample = `<?php

$taskId = "f8b30625-e38d-4950-8e13-76b72cfcb965";

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://aiandgpu.com/v1/tasks/" . $taskId,
  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>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}`;
  const csharpExample = `using RestSharp;

var taskId = "f8b30625-e38d-4950-8e13-76b72cfcb965";
var options = new RestClientOptions($"https://aiandgpu.com/v1/tasks/{taskId}");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <YOUR_API_KEY>");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.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 ClaudeChatResult = ({successJson}) => {
  const error400 = `{
    "error": {
        "code": "invalid_url",
        "message": "Invalid URL",
        "param": null,
        "type": "invalid_request_error"
    }
}`;
  const error401 = `{
    "error": {
        "code": "auth_invalid",
        "message": "Invalid API Key",
        "param": null,
        "type": "authentication_error"
    }
}`;
  const error404 = `{
    "error": {
        "code": "task_not_found",
        "message": "Task not found",
        "param": null,
        "type": "invalid_request_error"
    }
}`;
  return <>
      <h2>Response Examples</h2>

      <CodeGroup>
        <CodeBlock language="json" filename={"200 - Success"}>
          {successJson}
        </CodeBlock>
        <CodeBlock language="json" filename="400 - Bad Request">
          {error400}
        </CodeBlock>
        <CodeBlock language="json" filename="401 - Unauthorized">
          {error401}
        </CodeBlock>
        <CodeBlock language="json" filename="404 - Task Not Found">
          {error404}
        </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 Parameter

<ParamField query="id" path="id" type="string" required>
  The task ID returned from the async chat creation. Example: <b>f8b30625-e38d-4950-8e13-76b72cfcb965</b>
</ParamField>

<QueryResultRequest />

<ClaudeChatResult
  successJson={`{
"id": "f8b30625-e38d-4950-8e13-76b72cfcb965",
"status": "success",
"result": {
    "content": [
        {
            "text": "Hello! How can I help you today?",
            "type": "text"
        }
    ],
    "id": "msg_bdrk_01Dr1Hff6WvnpdjiYzkSd4SE",
    "model": "claude-sonnet-4-5-20250929-thinking",
    "role": "assistant",
    "stop_reason": "end_turn",
    "stop_sequence": null,
    "type": "message",
    "usage": {
        "cache_creation": {
            "ephemeral_1h_input_tokens": 0,
            "ephemeral_5m_input_tokens": 0
        },
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0,
        "input_tokens": 12,
        "output_tokens": 32
    }
},
"created_at": 1769094930
}`}
/>
