Skip to main content
Version: Latest

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

    ParamTypeDescription
    jsonObjectparameters of the generateToken function
    json.appIdStringAppId
    json.tokenStringJWT Client Token
  • Return Parameter

    ParamTypeDescription
    returnObjecthuman API envelope
    return.statusString"success" on OK
    return.codeNumber2000 on OK
    return.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

    ParamTypeDescription
    returnObjecthuman API envelope
    return.statusString"success" on OK
    return.codeNumber2000 on OK
    return.data.aiArrayavatar objects (see fields below)

Each data.ai[] item:

FieldRequiredDescription
ai_nameyesPass this to init({ aiName })
ai_typeyes"2D"
ai_display_nameoptionalUI label only
model_idoptionalCatalog id. Do not pass this to init() unless it equals ai_name
languageoptionale.g. "ko". Omitted or unused when empty
thumb_urloptionalThumbnail 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();