Zum Hauptinhalt springen
CrewAI ermöglicht den Aufbau autonomer Multi-Agenten-Systeme, in denen spezialisierte KI-Agenten bei komplexen Aufgaben zusammenarbeiten. Venice AI funktioniert dank OpenAI-Kompatibilität als Drop-in-LLM-Provider.

Einrichtung

pip install crewai crewai-tools

Basis-Konfiguration

Konfiguriere Venice als LLM-Provider in CrewAI über die OpenAI-kompatible Schnittstelle:
import os

os.environ["OPENAI_API_KEY"] = "your-venice-api-key"
os.environ["OPENAI_API_BASE"] = "https://api.venice.ai/api/v1"
os.environ["OPENAI_MODEL_NAME"] = "venice-uncensored"
Oder pro Agent mit dem LLM-Objekt konfigurieren:
from crewai import LLM

venice_llm = LLM(
    model="openai/venice-uncensored",
    api_key="your-venice-api-key",
    base_url="https://api.venice.ai/api/v1",
    temperature=0.7,
)

# Für komplexe Reasoning-Aufgaben
venice_flagship = LLM(
    model="openai/zai-org-glm-5-1",
    api_key="your-venice-api-key",
    base_url="https://api.venice.ai/api/v1",
    temperature=0.3,
)

Deine erste Crew

Erstelle eine einfache Research-Crew mit zwei Agenten:
from crewai import Agent, Task, Crew

# Agent 1: Researcher
researcher = Agent(
    role="Senior Research Analyst",
    goal="Find comprehensive, accurate information on the given topic",
    backstory="You are an expert researcher with a keen eye for detail. "
              "You excel at finding and synthesizing information from multiple sources.",
    llm=venice_flagship,
    verbose=True,
)

# Agent 2: Writer
writer = Agent(
    role="Content Strategist",
    goal="Create engaging, well-structured content from research findings",
    backstory="You are a skilled writer who transforms complex research "
              "into clear, compelling content that readers love.",
    llm=venice_llm,
    verbose=True,
)

# Task 1: Research
research_task = Task(
    description="Research the topic: {topic}. "
                "Find key facts, recent developments, and expert opinions. "
                "Provide a structured summary with sources.",
    expected_output="A detailed research summary with key findings, "
                    "organized by subtopic, with at least 5 key points.",
    agent=researcher,
)

# Task 2: Artikel schreiben
write_task = Task(
    description="Using the research provided, write a compelling blog post "
                "about {topic}. Include an introduction, main sections, and conclusion.",
    expected_output="A well-written blog post of 500-800 words with clear sections.",
    agent=writer,
    context=[research_task],  # Nutzt die Ausgabe von research_task
)

# Crew erstellen und ausführen
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    verbose=True,
)

result = crew.kickoff(inputs={"topic": "The future of privacy-preserving AI"})
print(result)

Multi-Agenten-Crew für Produktanalyse

Ein komplexeres Beispiel mit spezialisierten Agenten:
from crewai import Agent, Task, Crew, Process

# Unterschiedliche Modelle für unterschiedliche Agent-Fähigkeiten
fast_llm = LLM(model="openai/qwen3-5-9b", api_key="your-key", base_url="https://api.venice.ai/api/v1")
smart_llm = LLM(model="openai/zai-org-glm-5-1", api_key="your-key", base_url="https://api.venice.ai/api/v1")
uncensored_llm = LLM(model="openai/venice-uncensored-1-2", api_key="your-key", base_url="https://api.venice.ai/api/v1")

# Market Analyst – braucht Intelligenz
market_analyst = Agent(
    role="Market Research Analyst",
    goal="Analyze market trends and competitive landscape",
    backstory="You are a veteran market analyst with 15 years of experience "
              "in tech markets. You provide unbiased, data-driven insights.",
    llm=smart_llm,
    verbose=True,
)

# Red Team – profitiert von unzensiertem Denken
red_team = Agent(
    role="Red Team Critic",
    goal="Find weaknesses, risks, and potential failures in business strategies",
    backstory="You are a brutally honest critic who stress-tests ideas. "
              "You find every possible flaw and risk, no matter how uncomfortable.",
    llm=uncensored_llm,  # Unzensiert für ehrliche Kritik
    verbose=True,
)

# Stratege – braucht Reasoning
strategist = Agent(
    role="Business Strategist",
    goal="Synthesize analysis into actionable strategy recommendations",
    backstory="You are a McKinsey-trained strategist who creates clear, "
              "actionable plans from complex analyses.",
    llm=smart_llm,
    verbose=True,
)

# Tasks
market_task = Task(
    description="Analyze the market opportunity for: {product_idea}. "
                "Cover market size, competitors, trends, and target audience.",
    expected_output="Structured market analysis with TAM/SAM/SOM estimates, "
                    "top 5 competitors, and 3 key market trends.",
    agent=market_analyst,
)

critique_task = Task(
    description="Critically evaluate this product idea and market analysis. "
                "Find every weakness, risk, and potential failure mode. Be brutally honest.",
    expected_output="A list of at least 5 critical risks, 3 potential failure modes, "
                    "and honest assessment of whether this idea will succeed.",
    agent=red_team,
    context=[market_task],
)

strategy_task = Task(
    description="Based on the market analysis and red team critique, "
                "create a go-to-market strategy that addresses the identified risks.",
    expected_output="A clear go-to-market strategy with: positioning statement, "
                    "3 key differentiators, launch timeline, and risk mitigations.",
    agent=strategist,
    context=[market_task, critique_task],
)

crew = Crew(
    agents=[market_analyst, red_team, strategist],
    tasks=[market_task, critique_task, strategy_task],
    process=Process.sequential,
    verbose=True,
)

result = crew.kickoff(inputs={
    "product_idea": "A privacy-first AI coding assistant that runs on Venice API"
})
print(result)

Tools verwenden

Erweitere Agenten mit Web-Search und weiteren Tools:
SerperDevTool benötigt eine Umgebungsvariable SERPER_API_KEY von serper.dev. Als Alternative kannst du Venices integrierte Websuche nutzen, indem du venice_parameters: {"enable_web_search": "auto"} über model_kwargs übergibst — kein zusätzlicher API-Schlüssel erforderlich. Ein Beispiel findest du in der Web Search Integration des LangChain-Guides.
from crewai_tools import SerperDevTool, WebsiteSearchTool
from crewai import Agent, Task, Crew

# Web-Search-Tool (erfordert die Umgebungsvariable SERPER_API_KEY)
search_tool = SerperDevTool()

researcher = Agent(
    role="Web Researcher",
    goal="Find the latest information on any topic",
    backstory="You are an expert web researcher.",
    llm=venice_flagship,
    tools=[search_tool],
    verbose=True,
)

task = Task(
    description="Research the latest developments in {topic} from the past week.",
    expected_output="A summary of 5 recent developments with dates and sources.",
    agent=researcher,
)

crew = Crew(agents=[researcher], tasks=[task], verbose=True)
result = crew.kickoff(inputs={"topic": "decentralized AI"})

Modellauswahl-Guide für CrewAI

Wähle für jede Agent-Rolle das passende Venice-Modell:
Agent-RolleEmpfohlenes ModellWarum
Komplexes Reasoning / Strategiezai-org-glm-5-1Bestes privates Reasoning-Modell
Unzensierte Analyse / Red Teamvenice-uncensored-1-2Keine Inhaltsfilterung
Hohes Volumen / schnelle Aufgabenqwen3-5-9bGünstigstes Modell mit $0,10/1M Input-Tokens und $0,15/1M Output-Tokens
Code-Generierungs-Agentenqwen3-coder-480b-a35b-instructFür Code optimiert
Vision/Multimodalqwen3-vl-235b-a22bFortschrittliches Vision-Verständnis
Budgetbewusste Teamsqwen3-5-9b (schnell) + venice-uncensored-1-2 (Haupt)Kostengünstige Kombination

Tipps zur Kostenoptimierung

  1. Günstigere Modelle für einfachere Agenten nutzen: Nicht jeder Agent braucht ein Flaggschiff-Modell. Verwende qwen3-4b zum Formatieren, Zusammenfassen oder einfachen Extrahieren.
  2. venice-uncensored für kreative/kritische Rollen nutzen: Schnell, günstig und verweigert auch unbequeme Analysen nicht.
  3. Flaggschiff-Modelle für Reasoning reservieren: Nutze zai-org-glm-5-1 nur für Agenten, die komplexes Reasoning oder zuverlässiges Function Calling brauchen.
  4. Maximale Iterationen begrenzen: Setze max_iter an Agenten, um unkontrollierten Token-Verbrauch zu vermeiden:
    agent = Agent(role="...", goal="...", backstory="...", llm=venice_llm, max_iter=5)
    

Privacy-Vorteil

Venices Privacy-Garantien machen es ideal für CrewAI-Anwendungsfälle wie:
  • Vertrauliche Geschäftsstrategien — Zero Data Retention bedeutet, dass deine Wettbewerbsanalysen privat bleiben
  • Verarbeitung sensibler Daten — Private Modelle loggen oder speichern deine Daten nicht
  • Red-Team-Übungen — Unzensierte Modelle liefern ehrliches Feedback ohne Inhaltsfilterung

CrewAI Docs

Offizielle CrewAI-Dokumentation

Venice-Modelle

Alle Venice-Modelle durchsuchen