Updated at Sep 24, 2025
7 min
pippython --versionpip --versionnode -vnpm -v# Option A: From PyPI (if available)pip install metagpt# Option B: From source (recommended to track examples)git clone <org>/MetaGPT.gitcd MetaGPTpip install -r requirements.txtOPENAI_API_KEY, ANTHROPIC_API_KEY).ollama serve and select a model; point MetaGPT to your local endpoint..env (adjust for your provider):OPENAI_API_KEY=sk-...MODEL_NAME=gpt-4o-mini# Or localLLM_ENDPOINT=MODEL_NAME=deepseek-coderfrom metagpt import MetaTeam, Agent, Rolefrom metagpt.llms import LLM# 1) Define the LLM backendllm = LLM(model_name="gpt-4o-mini") # or point to local model# 2) Define role-specific agentspm = Agent(name="PM", role=Role.PRODUCT_MANAGER, llm=llm)arch = Agent(name="Architect", role=Role.ARCHITECT, llm=llm)eng = Agent(name="Engineer", role=Role.ENGINEER, llm=llm)qa = Agent(name="QA", role=Role.QA, llm=llm)# 3) Create a team with shared memory/contextteam = MetaTeam(agents=.---## Writing Prompts That Multi‑Agents UnderstandMetaGPT shines when you give it structured, role‑aware instructions. Think like a manager writing a brief for four specialists.- Objective: One sentence stating the end goal.- Users and Scope: Who benefits and what’s in/out.- Constraints: Clear boundaries (stack, latency, privacy, budget).- Success Metrics: What “good” looks like.- Deliverables: Explicit artifacts (PRD, diagram, repo layout, tests).Example brief:```yamlobjective: Build a Python CLI that reads a PDF and produces a 1-page summary in Markdown.users: .---## Best Practices for Reliable Results- Start small, then scale: Validate the pipeline on a minimal spec before big projects.- One role, one mandate: Avoid overlapping responsibilities to reduce confusion.- Use checklists: Give each agent a rubric (acceptance criteria) for their output.- Gate reviews: Add a Reviewer/Lead role that approves or sends work back.- Keep prompts structured: YAML/JSON schemas make outputs more deterministic.- Persist artifacts: Save PRD/design/code to disk for traceability and re‑runs.- Pair local + cloud: Use local models for drafts; escalate tricky steps to a stronger cloud model.- Budget constraints: Set token caps and cost checks for each stage.---## Example Project: Auto‑PRD for Feature RequestsGoal: Convert a raw feature request into a polished PRD with user stories and acceptance criteria.Flow:1. Input parsing: Normalize the request and extract context (user persona, pain points).2. PM agent: Drafts a PRD with goals, non‑goals, KPIs.3. Architect agent: Proposes solution options with pros/cons.4. Reviewer agent: Ensures clarity, risks, and dependencies are documented.Why it works: The structured hand‑off mirrors real product teams and forces clarity. IBM’s guide walks through a similar multi‑agent PRD flow with local models you can replicate.---## Troubleshooting Common Issues- Agents looping or stalling- Reduce scope and add explicit deliverables.- Add timeouts and step limits; enable review gates.- Messy or unstructured outputs- Enforce schemas with JSON/YAML; prompt with format examples.- Add a “Formatter” agent whose sole job is to normalize outputs.- Low‑quality code- Use a code‑strong model (e.g., DeepSeek‑Coder locally, or a top cloud model) for the Engineer.- Add a Tester/Linter agent; run unit tests automatically.- High costs- Use local models for drafting; only escalate to premium LLMs for final polish.- Limit context windows; chunk artifacts and retrieve as needed.- Model mismatch- Tune per‑role models (reasoning vs. coding vs. editing) and temperature settings.Independent overviews highlight MetaGPT’s strength in code generation and how to avoid pitfalls with better prompts and tooling.---## Going Deeper: Advanced Patterns- Retrieval‑Augmented Generation (RAG)- Feed your team a project “knowledge base” of past PRDs, designs, and code.- Let the PM/Architect retrieve relevant context before writing.- Toolformer style actions- Allow Engineer to run shell commands, create files, and execute tests.- Multi‑tenant projects- Run multiple teams in parallel for A/B solution exploration.- Human‑in‑the‑loop controls- Insert approval steps (e.g., PRD → human review → continue).- Evaluation harness- Auto‑grade outputs (e.g., linting, test coverage, readability scores) and feed results back to a Coach agent.---## Real‑World Use Cases You Can Build This Week- Startup Ideation → PRD → Prototype website- Internal data tool with CLI and docs- API design with client libraries in multiple languages- QA pipeline that generates tests from Jira tickets- Technical blog generator with code samples and diagramsCommunity write‑ups show MetaGPT’s knack for turning minimal input into structured, high‑quality artifacts rapidly, especially for engineering and product work.---## By the way: Speed up ideation and iteration with [Sider.AI](https://sider.ai)Worth noting: if you’re drafting prompts, reviewing artifacts, or iterating specs, a versatile assistant like [Sider.AI](https://sider.ai) can help you prototype briefs, compare alternatives, and refine outputs before handing them to MetaGPT. It’s especially handy for brainstorming user stories, acceptance criteria, and test cases that your agents can consume. Explore [Sider.AI](https://sider.ai) at https://sider.ai./---## Action Plan: Your Next 60 Minutes- 10 min: Install MetaGPT and set up your LLM (local or cloud).- 15 min: Create a 4‑role team (PM, Architect, Engineer, QA) and run a tiny project.- 15 min: Add schemas for PRD/design and a Reviewer gate.- 20 min: Swap models per role; add a test runner tool for Engineer/QA.Ship a first artifact today. Iterate tomorrow.---## Key Takeaways- MetaGPT lets you script a team of specialized agents that work together on complex tasks.- Success hinges on structured prompts, clear deliverables, and review gates.- Combine local and cloud models to balance cost, privacy, and quality.- Start with small pipelines (PRD → design → code → tests), then scale to richer tools and governance.For additional context and hands‑on examples, see these guides and tutorials.### FAQQ1:What is MetaGPT and how does it work?MetaGPT is a multi-agent framework where role‑based agents (PM, Architect, Engineer, QA) collaborate to produce structured outputs like PRDs, designs, and code. It coordinates tasks, shares context, and lets you plug in local or cloud LLMs for each role.Q2:How do I install and set up MetaGPT?Install via pip or from source, configure your LLM (OpenAI, Anthropic, or local via Ollama), and set environment variables for model access. Then define agents, create a team, and run a task to generate artifacts like PRDs and code.Q3:Can I use MetaGPT with local LLMs like DeepSeek or Llama?Yes. Using Ollama, you can run models like DeepSeek‑Coder or Llama locally and point MetaGPT to the local endpoint. This reduces cost and improves privacy for sensitive projects.Q4:What are best practices for prompts in MetaGPT?Use structured briefs with objectives, users, constraints, success metrics, and deliverables. Assign each agent a clear mandate and provide schema‑based output formats (e.g., JSON/YAML) to reduce ambiguity.Q5:How do I prevent agents from looping or producing low-quality code?Add step limits and review gates, enforce output schemas, and use specialized models per role (e.g., reasoning‑strong for Architect, code‑strong for Engineer). Include a Tester/Linter agent and run unit tests automatically.
How to Master ChatPDF: Faster Insights from Dense Documents

The best X Auto-Translation alternative for fast, accurate docs

Samsung AI Translation Unavailable in Iran? Practical Workarounds

Persian translate tools: a practical guide to faster, accurate work

The Best Grok alternative for deep, cited research

Top 15 Features of AI Image Generator You’ll Actually Use