AgentSdk API Reference
AgentSdk API Reference
Creation and Retrieval
java
// Create instance (singleton: same appId returns the same instance)
AgentSdk agentSdk = AgentSdk.create(url, appId, appKey, appSecret);
// Get an already-created instance
AgentSdk agentSdk = AgentSdk.get(appId);
// Get list of all registered appIds
List<String> appIds = AgentSdk.listAppIds();
| Method | Return Type | Description |
|---|---|---|
create(url, appId, appKey, appSecret) | AgentSdk | Create or get instance |
get(appId) | AgentSdk / null | Get an already-created instance |
listAppIds() | List<String> | All registered appIds |
Lifecycle
java
agentSdk.initialize(); // Establish WebSocket connection
agentSdk.release(); // Close connection, release all resources
| Method | Description |
|---|---|
initialize() | Establish WebSocket connection (triggers auth, reconnect) |
release() | Close connection, clean up callbacks, clean up caches, stop reconnect |
Auth Callback
java
agentSdk.registerAuth(AgentAuthCallback callback);
java
public interface AgentAuthCallback {
void onAuthState(String appId, int code, String msg);
}
Passive Callback Registration
Important: Must be registered before calling
initialize(). Each SDK instance can register only one passive-callback type.
| Method | Callback Type | Scenario |
|---|---|---|
registerAudio2Llm(cb) | Audio2LlmCallback | Audio -> ASR+LLM |
registerAudio2Tts(cb) | Audio2TtsCallback | Audio -> ASR+LLM+TTS |
registerAsr2Llm(cb) | Asr2LlmCallback | Text -> LLM |
registerAsr2Tts(cb) | Asr2TtsCallback | Text -> LLM+TTS |
registerAsrVideo2Vlm(cb) | AsrVideo2VlmCallback | Text+Video -> VLM |
registerAsrVideo2Tts(cb) | AsrVideo2TtsCallback | Text+Video -> VLM+TTS |
registerAudioVideo2Vlm(cb) | AudioVideo2VlmCallback | Audio+Video -> VLM |
registerAudioVideo2Tts(cb) | AudioVideo2TtsCallback | Audio+Video -> VLM+TTS |
v1.4.0 changes:
registerStateListen(...)is removed; state pushes now arrive throughPassiveCallback.onState(...).- Greeting signals are handled by overriding
PassiveCallback.onGreetSignal(...); no separate registration.- Removed from the SDK: passive callbacks
Audio2Asr/Audio2Audio/AudioVideo2Audio/Text2Tts(classes deleted) and the active APIsquerySkill/queryState/registerPullStream/registerPushListen(registration methods deleted; underlying classes still on disk).See the Passive callbacks guide.
Active Interaction
Task Flow
java
// Register task flow
agentSdk.registerTaskFlow(TaskFlowRequest taskFlowRequest);
// Unregister
agentSdk.unregisterTaskFlow(String flowId);
For the full task-flow lifecycle see Active Operations Guide - Task Flow.
Helper Methods
| Method | Return Type | Description |
|---|---|---|
getAgentCallbackType(agentId) | AgentCallbackType | Get the callback type bound to an agent |
getAgentMeta(agentId) | AgentMeta | Get agent metadata |
getRobotCallback(callbackType) | PassiveCallback | Get the registered callback instance |
getAppId() | String | Get the appId of this instance |
getUrl() | String | Get the connection URL |