# Agent APIs

## 1. Prerequisites

Base URL: `https://api.rokid.com`

- Keep a valid `API_KEY` for authentication.
- Make sure your workspace has existing agent invocation logs before querying this API.

## 2. Overview

Agent APIs provide paginated access to AI chat logs so integrations can filter records by user, time range, template name, model name and other conditions, then inspect prompts, responses, models and execution status.

### 2.1 List AI chat logs

**Endpoint** `https://api.rokid.com/ar/assistant/openapi/chatLog/page?pageNum={$pageNum}&pageSize={$pageSize}&type={$type}&keywords={$keywords}&uid={$uid}&startTime={$startTime}&endTime={$endTime}&agentName={$agentName}&modelName={$modelName}`

**Method** `GET`

**Request** `application/x-www-form-urlencoded`

**Response** `*/*`

**Description** Query AI chat logs for the current company with pagination

**Parameters**

| **Name** | **Description** | **Required** | **Type** |
| --- | --- | --- | --- |
| pageNum | Page number, default `1` | false | int |
| pageSize | Page size, default `10` | false | int |
| type | Log type: `0` chat, `1` recognition, default `0` | false | int |
| keywords | Keyword match on question and answer content | false | string |
| uid | User ID, exact match | false | string |
| startTime | Start time, supports `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` | false | string |
| endTime | End time, supports `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` | false | string |
| agentName | Template name, fuzzy match | false | string |
| modelName | Model name, fuzzy match | false | string |

**Response fields**

| **Name** | **Description** | **Required** | **Type** |
| --- | --- | --- | --- |
| pageNum | Current page number | true | int |
| pageSize | Page size | true | int |
| total | Total records | true | long |
| list | Log records | true | array |
| id | Primary key | true | long |
| type | Log type: `0` chat, `1` recognition | true | int |
| deviceId | Device identifier | false | string |
| agentId | Agent identifier | false | string |
| agentName | Template name | false | string |
| modelId | Model identifier | false | string |
| modelName | Model name | false | string |
| modelApiName | Model API name | false | string |
| systemPrompt | System prompt | false | string |
| questionContent | User question | false | string |
| questionImg | Question image URL | false | string |
| answerContent | Model answer | false | string |
| costTime | Latency in milliseconds | false | int |
| status | Execution status | false | string |
| errorMsg | Error message | false | string |
| isMemory | Whether memory is enabled | false | boolean |
| time | Invocation time | false | string |
| uid | User ID | false | string |
| userName | User name | false | string |
| companyId | Company ID | false | string |
| gmtCreated | Creation time | false | string |
| gmtModified | Update time | false | string |
| deleted | Delete flag: `0` active, `1` deleted | false | int |

**Example**

```bash
curl -X GET "https://api.rokid.com/ar/assistant/openapi/chatLog/page?pageNum=1&pageSize=10&type=0&uid=E0BB5354E9F54BC6A032E8B709CC7B2E&startTime=2026-06-01&endTime=2026-06-15%2023:59:59&agentName=Inspection%20Assistant&modelName=gpt" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json"
```

**Sample response**

```json
{
  "code": 0,
  "message": "OK",
  "data": {
    "pageNum": 1,
    "pageSize": 10,
    "total": 1,
    "list": [
      {
        "id": 1001,
        "type": 0,
        "deviceId": "1901092524001715",
        "agentId": "agent_demo_001",
        "agentName": "Inspection Assistant",
        "modelId": "common",
        "modelName": "Default Model",
        "modelApiName": "gpt-4o-mini",
        "systemPrompt": "You are an inspection assistant",
        "questionContent": "Please summarize today's inspection results",
        "questionImg": "",
        "answerContent": "Eight checkpoints were completed today with no anomalies.",
        "costTime": 1260,
        "status": "success",
        "errorMsg": "",
        "isMemory": true,
        "time": "2025-11-07T15:20:00.000+08:00",
        "uid": "E0BB5354E9F54BC6A032E8B709CC7B2E",
        "userName": "Alice",
        "companyId": "rokid-demo-company",
        "gmtCreated": "2025-11-07T15:20:00.000+08:00",
        "gmtModified": "2025-11-07T15:20:00.000+08:00",
        "deleted": 0
      }
    ]
  },
  "success": true
}
```
