import os# Set environment variablesos.environ["TOGETHER_API_KEY"] = "your-together-api-key-here" # Replace with your actual Together API keyos.environ["KLAVIS_API_KEY"] = "your-klavis-api-key-here" # Replace with your actual Klavis API key
Use the agent to analyze and summarize a YouTube video
Copy
Ask AI
# Example YouTube video URL - replace with any video you'd like to analyzeYOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v=TG6QOa2JJJQ"# 1. Create YouTube MCP server instanceyoutube_mcp_instance = klavis_client.mcp_server.create_server_instance( server_name=McpServerName.YOUTUBE, user_id="1234", platform_name="Klavis",)# 2. Create an agent with YouTube MCP serveragent = Agent( together_client=together_client, klavis_client=klavis_client, mcp_server_url=youtube_mcp_instance.server_url, model="meta-llama/Llama-3.3-70B-Instruct-Turbo")# 3. Process the requestresponse = agent.process_request( f"Please analyze this YouTube video and provide a comprehensive summary with timestamps: {YOUTUBE_VIDEO_URL}")print(response)
Gmail integration requires OAuth authentication, so you’ll need to authorize the application in your browser.
Copy
Ask AI
import webbrowser# Create Gmail MCP server instancegmail_mcp_instance = klavis_client.mcp_server.create_server_instance( server_name=McpServerName.GMAIL, user_id="1234", platform_name="Klavis",)# Redirect to Gmail OAuth page for authorizationwebbrowser.open(gmail_mcp_instance.oauth_url)print(f"🔐 Opening OAuth authorization for Gmail")print(f"If you are not redirected automatically, please open this URL: {gmail_mcp_instance.oauth_url}")# Email configurationEMAIL_RECIPIENT = "recipient@example.com" # Replace with the recipient's emailEMAIL_SUBJECT = "Greetings from Together AI + Klavis Integration"EMAIL_BODY = "This is a test email sent using the Together AI and Klavis AI integration. The email was sent automatically by your AI agent!"# After OAuth authorization is complete, create the Gmail agentgmail_agent = Agent( together_client=together_client, klavis_client=klavis_client, mcp_server_url=gmail_mcp_instance.server_url, model="Qwen/Qwen2.5-72B-Instruct-Turbo")# Send the emailresponse = gmail_agent.process_request( f"Please send an email to {EMAIL_RECIPIENT} with the subject '{EMAIL_SUBJECT}' and the following body: '{EMAIL_BODY}'")print(response)