acceptable-dream-85180
09/08/2025, 5:29 PMtall-airline-16756
09/08/2025, 5:29 PMtall-airline-16756
09/08/2025, 5:29 PMListAgents method is just what you need for this. It’s available through LiveKit server SDKs, like the Go SDK, where you’ll find the ListAgents function inside the AgentClient.
Just a heads up, the ListAgents method needs you to authenticate with a LiveKit API key and secret that have the right permissions. You’ll pass in a ListAgentsRequest object when calling it. If you send an empty request, it’ll happily return all the agents in your project.
The response you get back includes a list of AgentInfo objects, each one packed with details like the agent’s ID, version, when it was deployed, the region, current status, and resource usage.
If you want a hand with setting this up or have any questions, just give me a shout—I’m here to help!
Sources: cmd/lk/agent.go | protobufs/livekit_cloud_agent.proto | agent_client.go | Agent deployment CLI reference | LiveKit Docsacceptable-dream-85180
09/08/2025, 5:31 PMlkapi = livekit_api.LiveKitAPI(
url=config.livekit_url, api_key=config.livekit_api_key, api_secret=config.livekit_api_secret
)tall-airline-16756
09/08/2025, 5:32 PMListAgents method and list all your deployed agents:
import requests
import json
import base64
import hmac
import hashlib
# Configuration
base_url = "https://your-project.livekit.cloud"
api_key = "your_api_key"
api_secret = "your_api_secret"
# Function to create JWT token
def create_jwt_token(api_key, api_secret):
header = {"alg": "HS256", "typ": "JWT"}
payload = {"iss": api_key}
encoded_header = base64.urlsafe_b64encode(json.dumps(header).encode()).decode().strip("=")
encoded_payload = base64.urlsafe_b64encode(json.dumps(payload).encode()).decode().strip("=")
signature_input = f"{encoded_header}.{encoded_payload}"
signature = hmac.new(api_secret.encode(), signature_input.encode(), hashlib.sha256).digest()
signature_b64 = base64.urlsafe_b64encode(signature).decode().strip("=")
return f"{encoded_header}.{encoded_payload}.{signature_b64}"
# Construct request
url = f"{base_url}/twirp/livekit.CloudAgent/ListAgents"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {create_jwt_token(api_key, api_secret)}"
}
# Request payload
data = {} # Empty payload to list all agents
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
agents = response.json().get("agents", [])
for agent in agents:
print(f"ID: {agent['agent_id']}, Name: {agent['agent_name']}, Version: {agent['version']}")
else:
print(f"Oops! Something went wrong: {response.status_code}, {response.text}")
Just swap out your-project.livekit.cloud, your_api_key, and your_api_secret with your own LiveKit project details. This example also shows how to generate the JWT token you’ll need for authentication with the LiveKit API.
If you hit any snags or have questions, feel free to ask—I’m here to help!
Sources: README.md | livekit/livekit_cloud_agent.pb.go | cmd/lk/agent.go | Agent deployment CLI reference | LiveKit Docsacceptable-dream-85180
09/08/2025, 5:50 PMtall-airline-16756
09/08/2025, 5:51 PMbase_url for your LiveKit API requests should be the URL of your LiveKit server or your cloud project. For instance, if you’re using LiveKit Cloud, it usually looks something like this:
https://your-project.livekit.cloud
Just swap out your-project with the actual name of your LiveKit project. And if you’re running LiveKit on your own server, go ahead and use your server’s URL instead.
If you’re unsure about your project URL or want a hand figuring it out, just give me a shout—I’m here to help!acceptable-dream-85180
09/08/2025, 5:56 PMtall-airline-16756
09/08/2025, 5:56 PMresponse.json() is giving you trouble, it might be because of a couple of reasons:
• The response body isn’t valid JSON. This can happen if the server sent back something unexpected or an error message that’s not in JSON format.
• The server might have returned an error (like permission denied) with a status code other than 200, and the code tried to parse it as JSON without checking the status first.
To get to the bottom of this, try checking out the raw response content and status code before calling `response.json()`:
print(response.status_code)
print(response.text)
If the status code isn’t 200, the response might actually have an error message in JSON. Feel free to share what you find, and I’ll be happy to help you figure it out!
Sources: cmd/lk/agent.go | livekit-api/livekit/api/twirp_client.pyacceptable-dream-85180
09/08/2025, 5:58 PMtall-airline-16756
09/08/2025, 5:58 PM/twirp/livekit.CloudAgent/ListAgents)?
• Is the Content-Type header set to application/json in your request?
• Are you sending an empty JSON object ({}) as the request payload?
Just let me know what you find, and I’ll be happy to help you troubleshoot from there!acceptable-dream-85180
09/08/2025, 5:59 PM# Function to create JWT token
def create_jwt_token(api_key:str, api_secret:str)->str:
header = {"alg": "HS256", "typ": "JWT"}
payload = {"iss": api_key}
encoded_header = base64.urlsafe_b64encode(json.dumps(header).encode()).decode().strip("=")
encoded_payload = base64.urlsafe_b64encode(json.dumps(payload).encode()).decode().strip("=")
signature_input = f"{encoded_header}.{encoded_payload}"
signature = hmac.new(api_secret.encode(), signature_input.encode(), hashlib.sha256).digest()
signature_b64 = base64.urlsafe_b64encode(signature).decode().strip("=")
return f"{encoded_header}.{encoded_payload}.{signature_b64}"
def list_cloud_deployed_agent()->None:
# Construct request
url = f"https://ribbon-v8vqjd47.livekit.cloud/twirp/livekit.CloudAgent/ListAgents"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {create_jwt_token(api_key=config.livekit_api_key, api_secret=config.livekit_api_secret)}"
}
response = requests.post(url, headers=headers, json={})
print(f"Response status: {response.status_code}")
print(f"Response headers: {response.headers}")
print(f"Response text: '{response.text}'")
print(f"Response content length: {len(response.content)}")tall-airline-16756
09/08/2025, 6:00 PMAuthorization header is properly formatted with the JWT token from your create_jwt_token function.
• Double-check that the Content-Type header is set to application/json in your request.
• Take a peek at the response headers and content length to see if the server is giving any extra info.
Looking at your code, the Response text and Response content length should give some helpful hints. If you’re still just getting "OK" without any other details, it might mean there’s something up with the endpoint or the request payload.
Feel free to share what you find, and I’m here to help you figure it out!acceptable-dream-85180
09/08/2025, 6:01 PMResponse headers: {'Content-Length': '2', 'Content-Type': 'text/plain; charset=utf-8', 'Date': 'Mon, 08 Sep 2025 17:58:20 GMT', 'Vary': 'Origin'}
Response text: 'OK'
Response content length: 2tall-airline-16756
09/08/2025, 6:01 PMhttps://ribbon-v8vqjd47.livekit.cloud/twirp/livekit.CloudAgent/ListAgents.
• Next, take a look at the Authorization header to confirm it has a valid JWT token created with the correct API key and secret.
• Also, the request payload should be an empty JSON object ({}) since that’s what the ListAgents method expects.
• Lastly, make sure agent hosting is enabled for your LiveKit project — if it’s not, the server might not handle the request properly.
If you’ve checked all these and things still aren’t working, no worries! Just let me know, and we can dig a little deeper together.