Build Your First Multilingual AI Agent with SUTRA and Agno
SUTRA, a family of large multilingual language models (LMLMs), excels in handling over 50 languages, making it ideal for applications requiring cultural and linguistic diversity. Agno, a lightweight and model-agnostic library, complements SUTRA by enabling the creation of intelligent agents with memory, reasoning, and tool integration.
This guide will walk you through setting up a multilingual AI agent, running examples, and leveraging tools like DuckDuckGo and Yahoo Finance for real-time data.
Prerequisites
Before diving in, ensure you have:
- A SUTRA API key from TWO AI's SUTRA API page
- Basic familiarity with Python and Jupyter notebooks
- Access to Google Colab
Setting Up the Environment
Step 1: Install Required Packages
!pip install openai agno duckduckgo-search yfinance
These packages include:
- openai: For interacting with SUTRA's API.
- agno: The Agno library for building AI agents.
- duckduckgo-search: For real-time web searches.
- yfinance: For accessing stock market data.
Step 2: Configure API Keys
import os from google.colab import userdata # Set the API keys from Colab secrets os.environ["OPENAI_API_KEY"] = userdata.get("SUTRA_API_KEY") os.environ["TAVILY_API_KEY"] = userdata.get("TAVILY_API_KEY")
🔐 Replace SUTRA_API_KEY with your actual key from TWO AI.
Using SUTRA with OpenAI Client
from openai import OpenAI client = OpenAI( base_url='https://api.two.ai/v2', api_key=os.environ["SUTRA_API_KEY"] ) response = client.chat.completions.create( model="sutra-v2", messages=[ {"role": "system", "content": "You are a helpful assistant that specializes in Indian languages and culture."}, {"role": "user", "content": "Tell me about the importance of the Ganga river in Indian culture."} ] ) print(response.choices[0].message.content)
Building Multilingual AI Agents with Agno
Example 1: Cultural Q&A Agent
from agno.agent import Agent from agno.models.openai.like import OpenAILike sutra_agent = Agent( model=OpenAILike( id="sutra-v2", api_key=os.getenv("SUTRA_API_KEY"), base_url="https://api.two.ai/v2" ), description="You are a helpful assistant specializing in Indian culture and history.", markdown=True ) sutra_agent.print_response("Tell me about the history of yoga in India.", stream=True)
Example 3: Storytelling Agent
story_agent = Agent( model=OpenAILike( id="sutra-v2", api_key=os.getenv("SUTRA_API_KEY"), base_url="https://api.two.ai/v2" ), description="You are a creative storyteller specializing in Indian folklore.", markdown=True ) story_agent.print_response("Write a short story about a magical tree in an Indian village.", stream=True)
Example 2: Code Explanation Agent
sample_code = ''' def diwali_date(year): return f'Diwali in {year} is likely in October or November.' print(diwali_date(2025)) ''' code_agent = Agent( model=OpenAILike( id="sutra-v2", api_key=os.getenv("SUTRA_API_KEY"), base_url="https://api.two.ai/v2" ), description="You are an expert in explaining Python code, especially related to Indian culture.", markdown=True ) code_agent.print_response(f"Explain this Python code:\n{sample_code}", stream=True)
Example 3: Stock Market Agent
from agno.tools.yfinance import YFinanceTools sutra_agent = Agent( model=OpenAILike( id="sutra-v2", api_key=os.getenv("SUTRA_API_KEY"), base_url="https://api.two.ai/v2" ), description="You are an expert in analyzing stock market data using YFinanceTools.", markdown=True, tools=[YFinanceTools()] ) sutra_agent.print_response("How is TSLA stock doing right now in Hindi?", stream=True)
Example 4: Multilingual Agent with Reasoning
from agno.tools.duckduckgo import DuckDuckGoTools sutra_agent_with_tools = Agent( model=OpenAILike( id="sutra-v2", api_key=os.getenv("SUTRA_API_KEY"), base_url="https://api.two.ai/v2" ), description="You are a helpful assistant specializing in Indian languages, culture, and current events. Provide accurate and detailed responses in Hindi when requested, using DuckDuckGoTools for up-to-date information.", tools=[DuckDuckGoTools()], show_tool_calls=True, markdown=True ) query = ''' भारत के अंतरिक्ष कार्यक्रम में हाल के विकास क्या हैं? DuckDuckGoTools का उपयोग करके नवीनतम जानकारी प्राप्त करें और निम्नलिखित शामिल करें: 1. हाल की मिशन सफलताएँ (उदाहरण: SpaDeX, Gaganyaan)। 2. भविष्य की योजनाएँ (उदाहरण: चंद्रयान-4, भारतीय अंतरिक्ष स्टेशन)। 3. निजी क्षेत्र की भागीदारी। हिंदी में विस्तृत और संरचित उत्तर प्रदान करें, प्रत्येक अनुभाग को स्पष्ट रूप से लेबल करें। ''' sutra_agent_with_tools.print_response(query, stream=True)
Next Steps
- 🔍 Experiment with Prompts: Customize prompts and agent descriptions.
- 🧠 Combine Tasks: Build agents that merge tasks like translation + storytelling.
- 📘 Explore the API: Visit the Sutra API Docs for more options.
- 🌍 Share Your Work: Publish your creations and tag the community!
🌟 Share Your Work
Contribute your chatbot to the open-source community:
- ✨ Submit to sutra-cookbook GitHub repo
- Share your notebook with your team or Audience
💡 Tips & Tricks
- ✅ Multilingual Power: Use sutra-v2 to support 50+ languages
- 📚 Optimal Chunks: Stick with chunk_size = 1000 and chunk_overlap = 100
🌍
Community First: Star the repo and share feedback
📘️ Conclusion
Combining RAG with SUTRA empowers you to build intelligent, multilingual, document-aware chatbots—perfect for education, community discussions, and global learning.
🔗 Resources & Community
- 🌐 Website: two.ai
- 💻 GitHub: sutra-cookbook
- 💬 Discord: Join the community
- 🤞 Twitter: @sutra_dev
- 💼 LinkedIn: TWO Platforms