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();
MethodReturn TypeDescription
create(url, appId, appKey, appSecret)AgentSdkCreate or get instance
get(appId)AgentSdk / nullGet an already-created instance
listAppIds()List<String>All registered appIds

Lifecycle

java
agentSdk.initialize();  // Establish WebSocket connection
agentSdk.release();     // Close connection, release all resources
MethodDescription
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.

MethodCallback TypeScenario
registerAudio2Llm(cb)Audio2LlmCallbackAudio -> ASR+LLM
registerAudio2Tts(cb)Audio2TtsCallbackAudio -> ASR+LLM+TTS
registerAsr2Llm(cb)Asr2LlmCallbackText -> LLM
registerAsr2Tts(cb)Asr2TtsCallbackText -> LLM+TTS
registerAsrVideo2Vlm(cb)AsrVideo2VlmCallbackText+Video -> VLM
registerAsrVideo2Tts(cb)AsrVideo2TtsCallbackText+Video -> VLM+TTS
registerAudioVideo2Vlm(cb)AudioVideo2VlmCallbackAudio+Video -> VLM
registerAudioVideo2Tts(cb)AudioVideo2TtsCallbackAudio+Video -> VLM+TTS

v1.4.0 changes:

  • registerStateListen(...) is removed; state pushes now arrive through PassiveCallback.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 APIs querySkill / 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

MethodReturn TypeDescription
getAgentCallbackType(agentId)AgentCallbackTypeGet the callback type bound to an agent
getAgentMeta(agentId)AgentMetaGet agent metadata
getRobotCallback(callbackType)PassiveCallbackGet the registered callback instance
getAppId()StringGet the appId of this instance
getUrl()StringGet the connection URL