Kotlin SDK
ElevenAgents SDK: deploy customized, interactive voice agents in minutes for Android apps.
ElevenAgents SDK: deploy customized, interactive voice agents in minutes for Android apps.
Refer to the ElevenAgents overview for an explanation of how ElevenAgents works.
Add the ElevenLabs SDK to your Android project by including the following dependency in your app-level build.gradle file:
An example Android app using this SDK can be found here
Add the necessary permissions to your AndroidManifest.xml:
For Android 6.0 (API level 23) and higher, you must request microphone permission at runtime:
Initialize the ElevenLabs SDK in your Application class or main activity:
Start a conversation session with either:
agentIdconversationToken provisioned from your backend (never expose your API key to the client).Note that ElevenAgents requires microphone access. Consider explaining and requesting permissions in your app’s UI before the conversation starts, especially on Android 6.0+ where runtime permissions are required.
If a tool is configured with expects_response=false on the server, return null from execute
to skip sending a tool result back to the agent.
agentId in ConversationConfig. The SDK requests a conversation token from ElevenLabs without needing an API key on device.conversationToken in ConversationConfig. Your server requests a conversation token from ElevenLabs using your ElevenLabs API key.Register client tools to allow the agent to call local capabilities on the device.
When the agent issues a client_tool_call, the SDK executes the matching tool and responds with a client_tool_result. If the tool is not registered, onUnhandledClientToolCall is invoked and a failure result is returned to the agent (if a response is expected).
"ai" or "user") and raw JSON message."speaking") or listening ("listening")."connected", "connecting", or "disconnected").Not all client events are enabled by default for an agent. If you have enabled a callback but aren’t seeing events come through, ensure that your ElevenLabs agent has the corresponding event enabled. You can do this in the “Advanced” tab of the agent settings in the ElevenLabs dashboard.
The startSession method initiates the WebRTC connection and starts using the microphone to communicate with the ElevenLabs Agents agent.
For public agents (i.e. agents that don’t have authentication enabled), only the agentId is required. The Agent ID can be acquired through the ElevenLabs UI.
For private agents, you must pass in a conversationToken obtained from the ElevenLabs API. Generating this token requires an ElevenLabs API key.
conversationToken is valid for 10 minutes.Then, pass the token to the startSession method. Note that only the conversationToken is required for private agents.
You can optionally pass a user ID to identify the user in the conversation. This can be your own customer identifier. This will be included in the conversation initiation data sent to the server.
A method to manually end the conversation. The method will disconnect and end the conversation.
Send a text message to the agent during an active conversation. This will trigger a response from the agent.
Sends contextual information to the agent that won’t trigger a response.
Provide feedback on the conversation quality. This helps improve the agent’s performance. Use onCanSendFeedbackChange to enable your thumbs up/down UI when feedback is allowed.
Notifies the agent about user activity to prevent interruptions. Useful for when the user is actively using the app and the agent should pause speaking, i.e. when the user is typing in a chat.
The agent will pause speaking for ~2 seconds after receiving this signal.
Get the conversation ID.
Observe session.isMuted to update the UI label between “Mute” and “Unmute”.
Get the current status of the conversation.
If you shrink/obfuscate, ensure Gson models and LiveKit are kept. Example rules (adjust as needed):
session.endSession() and that you start a new session instance before reconnectingFor an example implementation, see the example app in the ElevenLabs Android SDK repository. The app demonstrates:
sendUserActivity()