Multi-Agent Systems with SUTRA

This notebook demonstrates how to use SUTRA with CrewAI, a framework for orchestrating role-playing, autonomous AI agents. SUTRA-V2, developed by TWO AI, powers multilingual chat and instruction tasks, integrating seamlessly with CrewAI’s collaborative agent workflows.

🔧 Prerequisites

  • Obtain your SUTRA API key from https://developer.two.ai.
  • Store the API key securely (e.g., in Google Colab secrets or environment variables).
  • Install CrewAI and OpenAI SDK.

📦 Step 1: Install Dependencies

# SUTRA models are OpenAI API compatible
!pip install -qU crewai openai

🔐 Step 2: Initialize SUTRA-V2 with CrewAI

from crewai import Agent, Task, Crew
from crewai import LLM
import os

client = LLM(
    model="openai/sutra-v2",
    api_key=os.getenv("SUTRA_API_KEY"),
    api_base="https://api.two.ai/v2",
)

# Define a CrewAI agent with SUTRA-V2
agent = Agent(
    role="Multilingual Assistant",
    goal="Provide concise answers in multiple languages",
    backstory="You are an expert AI assistant trained to communicate fluently in over 50 languages.",
    llm=client,
    model="sutra-v2",
    verbose=True
)

# Define a task
task = Task(
    description="Explain AI in three sentences in German.",
    agent=agent,
    expected_output="A concise explanation of AI in German."
)

# Create a crew
crew = Crew(
    agents=[agent],
    tasks=[task],
    verbose=True
)

💬 Step 3: Run the agent

# Run the agent
response = agent.kickoff("How Many Languages SUTRA Speak in Hindi.")
print(response)

🌟 Why CrewAI?

  • Collaboration: Enables multi-agent workflows with role-based tasks.
  • Flexibility: Integrates with OpenAI-compatible APIs like SUTRA-V2.
  • Performance: Optimized for speed and enterprise-grade automation.

🛠 Troubleshooting

  • Invalid API Key: Verify your key at https://developer.two.ai.
  • Model Not Found: Use sutra-v2. SUTRA-V1 was deprecated on March 22, 2025.
  • CrewAI Errors: Ensure Python < 3.13 for compatibility with CrewAI tools.

📎 Resources