AIPlayer method using API
v2 returns the human API envelope as-is (snake_case). There is no succeed, defaultAI, or
camelCase remap.
1. AIPlayer.generateToken(json)
Exchange a short-lived ClientToken for a session JWT. On success the SDK stores the JWT internally;
then you can call getAIList() and init().
-
Parameter
Param Type Description jsonObjectparameters of the generateToken function json.appIdStringAppId json.tokenStringJWT Client Token -
Return Parameter
Param Type Description returnObjecthuman API envelope return.statusString"success"on OKreturn.codeNumber2000on OKreturn.messageStringe.g. "Success"return.data.tokenStringsession JWT (also stored inside the SDK) return.data.token_expireNumberUnix timestamp (seconds) return.timestampStringISO-8601
There is no defaultAI. Pick an avatar from getAIList().
- Example
const result = await AI_PLAYER.generateToken({ appId: "...", token: "..." });
if (result.status !== "success") {
throw new Error(result.message ?? "generateToken failed");
}
// result.data.token / result.data.token_expire exist; the SDK already stored them
Verified shape:
{
"status": "success",
"code": 2000,
"message": "Success",
"data": {
"token": "<session JWT>",
"token_expire": 1788854164
},
"timestamp": "2026-09-08T05:56:04.131Z"
}
2. AIPlayer.getAIList()
List avatars the current session is allowed to use. Call after a successful generateToken().
-
Return Parameter
Param Type Description returnObjecthuman API envelope return.statusString"success"on OKreturn.codeNumber2000on OKreturn.data.aiArrayavatar objects (see fields below)
Each data.ai[] item:
| Field | Required | Description |
|---|---|---|
ai_name | yes | Pass this to init({ aiName }) |
ai_type | yes | "2D" |
ai_display_name | optional | UI label only |
model_id | optional | Catalog id. Do not pass this to init() unless it equals ai_name |
language | optional | e.g. "ko". Omitted or unused when empty |
thumb_url | optional | Thumbnail URL. Omitted when empty |
- Example
const result = await AI_PLAYER.getAIList();
if (result.status !== "success") {
throw new Error(result.message ?? "getAIList failed");
}
const aiName = result.data.ai[0].ai_name;
await AI_PLAYER.init({ aiName });
Verified shape:
{
"status": "success",
"code": 2000,
"message": "Success",
"data": {
"ai": [
{
"model_id": "sample-sage-v2",
"ai_name": "sample-sage-v2",
"ai_display_name": "Sample-sage-v2",
"language": "ko",
"thumb_url": "https://cdn.aistudios.com/thumbnail/default.png",
"ai_type": "2D"
}
]
},
"timestamp": "2026-09-08T05:56:04.162Z"
}
3. AIPlayer.getSampleTextList()
Gets the sample text list for the current AI language.
-
Return Parameter:
Array<String> -
Examples
const texts = await AI_PLAYER.getSampleTextList();