import asyncio
from pipecatcloud.exception import AgentStartError
from pipecatcloud.session import Session, SessionParams
async def main():
try:
# Create session object
session = Session(
agent_name="my-first-agent",
api_key=API_KEY, # Replace with your actual API key
params=SessionParams(
use_daily=True, # Optional: Creates a Daily room
daily_room_properties={"start_video_off": False},
data={"key": "value"},
),
)
# Start the session
response = await session.start()
# Get Daily room URL
daily_url = f"{response['dailyRoom']}?t={response['dailyToken']}"
print(f"Join Daily room: {daily_url}")
except AgentStartError as e:
print(f"Error starting agent: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
# Run the async function
if __name__ == "__main__":
asyncio.run(main())