惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
雷峰网
雷峰网
S
SegmentFault 最新的问题
博客园 - 【当耐特】
博客园_首页
量子位
爱范儿
爱范儿
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
V
V2EX
美团技术团队
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Cloudflare Blog
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
AI Agent Design: Dify vs LangChain vs Raw API — How to Ch...
kanta13jp1 · 2026-04-28 · via DEV Community

kanta13jp1

AI Agent Design: Dify vs LangChain vs Raw API — How to Choose

When you decide to build an AI agent, the first question is "what do I use?" I've run all three in production. Here's the honest breakdown.

The Short Answer

Dify:       No-code/low-code / prototypes / non-engineer teams
LangChain:  Python / complex chains / OSS ecosystem needed
Raw API:    Production / full control / Flutter + Supabase integration

Enter fullscreen mode Exit fullscreen mode

My project landed on raw API (Anthropic SDK + Deno Edge Function).

When Dify Wins

# Dify workflow design view
[Input] → [LLM Node] → [Condition Branch] → [Tool Node] → [Output]

Enter fullscreen mode Exit fullscreen mode

Dify lets you build flows in a GUI. Its biggest strength: working prototype in 3 days.

✅ Use Dify when:
- Non-engineers need to edit workflows
- You want to test a RAG pipeline fast
- You don't want to manage hosting/infra

❌ Not Dify when:
- You need tight integration with existing code
- Custom logic is complex
- Dify's execution cost is climbing

Enter fullscreen mode Exit fullscreen mode

When LangChain Wins

from langchain.agents import initialize_agent, Tool
from langchain.chat_models import ChatAnthropic

tools = [
    Tool(name="search", func=search_fn, description="Web search"),
    Tool(name="calculator", func=calc_fn, description="Math"),
]

agent = initialize_agent(tools, ChatAnthropic(model="claude-haiku-4-5"), ...)
result = agent.run("What's the weather in Tokyo today?")

Enter fullscreen mode Exit fullscreen mode

LangChain's Python ecosystem is powerful. Rich integrations for Vector Store / Retriever / Memory.

✅ Use LangChain when:
- Building a serious RAG pipeline
- Need to swap between multiple LLMs
- Python-based data pipelines already exist

❌ Not LangChain when:
- Flutter/Dart/Deno is your main stack — bindings are thin
- Simple API calls — overhead is disproportionate

Enter fullscreen mode Exit fullscreen mode

When Raw API Wins (My Choice)

// Deno Edge Function implementation
const response = await fetch('https://api.anthropic.com/v1/messages', {
  method: 'POST',
  headers: {
    'x-api-key': Deno.env.get('ANTHROPIC_API_KEY')!,
    'anthropic-version': '2023-06-01',
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    model: 'claude-haiku-4-5-20251001',
    max_tokens: 1024,
    messages: [{ role: 'user', content: userMessage }],
  }),
});

const data = await response.json();
return data.content[0].text;

Enter fullscreen mode Exit fullscreen mode

Why I chose raw API:

  1. Supabase Edge Function (Deno) is home — no need for Python LangChain bindings
  2. Cost control — switch haiku/sonnet/opus inside business logic
  3. Minimal dependencies — not dragged by library breaking changes
  4. RLS integration — wire directly to Supabase auth.uid()

The Decision Flow

Want to build an AI agent?
  ↓
Non-engineers editing workflows?
  Yes → Dify
  No ↓
Python is your main stack?
  Yes → LangChain
  No ↓
Tight integration with existing stack needed?
  Yes → Raw API
  No → Dify (as prototype)

Enter fullscreen mode Exit fullscreen mode

Tool Use (Function Calling) Pattern

Using Tool Use with raw API:

const tools = [
  {
    name: "get_race_data",
    description: "Fetch horse racing data",
    input_schema: {
      type: "object",
      properties: {
        race_id: { type: "string", description: "Race ID" },
        date: { type: "string", description: "Date in YYYY-MM-DD" },
      },
      required: ["race_id"],
    },
  },
];

const response = await fetch('https://api.anthropic.com/v1/messages', {
  method: 'POST',
  headers: { 'x-api-key': API_KEY, 'anthropic-version': '2023-06-01', 'content-type': 'application/json' },
  body: JSON.stringify({
    model: 'claude-sonnet-4-6',
    max_tokens: 2048,
    tools,
    messages: [{ role: 'user', content: 'Predict tomorrow\'s Nakayama races' }],
  }),
});

Enter fullscreen mode Exit fullscreen mode

When Claude decides it should call get_race_data, it returns a tool_use block. Your code handles the dispatch.

Cost Design: Model Switching Strategy

function selectModel(taskType: string): string {
  switch (taskType) {
    case 'simple_qa':      return 'claude-haiku-4-5-20251001';  // $0.00025/1K
    case 'analysis':       return 'claude-sonnet-4-6';           // $0.003/1K
    case 'complex_design': return 'claude-opus-4-7';             // $0.015/1K
    default: return 'claude-haiku-4-5-20251001';
  }
}

Enter fullscreen mode Exit fullscreen mode

My horse racing prediction system uses:

  • Standard analysis: haiku ($0.00045/prediction)
  • Top race deep analysis: sonnet
  • Architecture decisions: opus (session-level only)

Summary

Factor Dify LangChain Raw API
Development speed
Customizability
Existing stack integration
Operational cost
Non-engineer support

For Flutter + Supabase environments, raw API is the right call. Simplicity and control in one package.

The toolchain you choose shapes what you can build. Match it to your stack, not the hype.