Skip to content

熱門 LLM · 全本一頁

← 回 LLM / API 申請總覽 · 此頁是 3 個分頁合一頁版,給想 Ctrl-F 一次搜全本A4 一次印 的人。日常瀏覽建議用分頁版(左 sidebar)。


熱門 LLM · 商業 API(Claude / GPT / Gemini)

← 回 LLM / API 申請總覽

美國三家主流商業 LLM,付費為主、能力最強,AgentZ 多數章節用這幾家做範例。

1. Anthropic Claude(AgentZ 主推

介紹

Anthropic 的 Claude 系列,是 AgentZ 預設用的模型。三檔位:

  • Haiku 4.5:快、便宜、適合大量 ReAct loop / 工具呼叫
  • Sonnet 4.6:平衡,日常 agent 用這顆
  • Opus 4.7:最強推理,1M context,適合 coding / 深度規劃

特色:

  • 1M token context window(Opus 4.7)
  • 內建 tool use(function calling)
  • Claude Code CLI 直接綁這顆
  • API 行為相對「穩」,agent loop 不易突然亂跑

申請 API key

  1. https://console.anthropic.com/ → Sign up(用 Google / GitHub / Email 都可以)
  2. 驗證 phone 號(必填)
  3. Billing → Add payment method(信用卡)
  4. 預存 credit(最低 $5)— 重要:先設 monthly limit $10-20 避免炸
  5. API Keys → Create Key → 複製 sk-ant-api03-...

AgentZ Ch 8 / Ch 15 教你怎麼設 cost cap 在程式層把 over-spend 擋掉。

第一支呼叫(curl)

bash
export ANTHROPIC_API_KEY="sk-ant-api03-..."

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-haiku-4-5",
    "max_tokens": 200,
    "messages": [{"role": "user", "content": "用繁中介紹 AI Agent。"}]
  }'

第一支呼叫(Python)

python
# pip install anthropic
import anthropic

client = anthropic.Anthropic()  # 自動讀 ANTHROPIC_API_KEY env
resp = client.messages.create(
    model="claude-haiku-4-5",
    max_tokens=200,
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}]
)
print(resp.content[0].text)

費用速算

  • Haiku 4.5:input $1 / 1M、output $5 / 1M
  • Sonnet 4.6:input $3 / 1M、output $15 / 1M
  • Opus 4.7:input $15 / 1M、output $75 / 1M

一次 agent run 大約 5-50K tokens,Haiku 一次跑 < $0.05,Sonnet < $0.20。


2. OpenAI GPT

介紹

業界最廣的模型,Function calling / Assistants API / Realtime API 都最早出。AgentZ Ch 11 會把它跟 Claude 做對照。

申請

  1. https://platform.openai.com/ → Sign up
  2. Billing → Add card → 預存 credit
  3. 重要:新帳號要等 24-48hr 才能用某些 model;先設 usage limit
  4. API keys → Create new secret key → sk-proj-...

範例(curl)

bash
export OPENAI_API_KEY="sk-proj-..."

curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "用繁中介紹 AI Agent。"}]
  }'

Python

python
# pip install openai
from openai import OpenAI

client = OpenAI()
resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}],
)
print(resp.choices[0].message.content)

費用

  • gpt-4o-mini:input $0.15、output $0.60 / 1M(便宜)
  • gpt-4o:input $2.5、output $10 / 1M
  • o1 / o3(推理):較貴,input $15-60 / 1M

3. Google Gemini(有免費層

介紹

  • 2M token context window(業界最長)
  • 影像、影片、PDF 多模態強
  • 免費層慷慨:Flash 系列每分鐘 15 次、每天 1500 次免費

申請

  1. https://aistudio.google.com/ → 用 Google 帳號登入(不用信用卡)
  2. Get API key → Create API key → AIza...
  3. 想用付費層:到 Google Cloud Console 開 Billing

Python

python
# pip install google-generativeai
import google.generativeai as genai
import os

genai.configure(api_key=os.environ["GEMINI_API_KEY"])
model = genai.GenerativeModel("gemini-2.0-flash-exp")
resp = model.generate_content("用繁中介紹 AI Agent。")
print(resp.text)

費用

  • Flash:免費層 / 付費 input $0.075、output $0.30 / 1M
  • Pro:input $1.25、output $5 / 1M
  • 2M context 模式價錢翻倍


其他類別開源/聚合 · 本地/主權 · 全本一頁


熱門 LLM · 開源 / 聚合 / 速度 / 便宜

← 回 LLM / API 申請總覽

不想全壓在美國三大廠?這 5 家適合:免費試(Groq)、推理便宜(DeepSeek)、歐盟合規(Mistral)、一個 key 打 100+ 家(OpenRouter)、X 社交整合(Grok)。

4. Groq(最快 + 免費

介紹

  • 不是 Grok(xAI)— Groq 是硬體公司,自研 LPU 推論晶片
  • 推論速度 ~500 tok/s(一般 GPU 50-100 tok/s)
  • 跑 Llama 3.x / Mixtral / Gemma 等開源模型
  • 免費層每天幾千 request,做 demo / 學習超夠

申請

  1. https://console.groq.com/ → Sign up(Email / Google)
  2. API Keys → Create API key → gsk_...
  3. 不需要信用卡(免費層)

Python(OpenAI 相容介面)

python
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GROQ_API_KEY"],
    base_url="https://api.groq.com/openai/v1",
)
resp = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}],
)
print(resp.choices[0].message.content)

費用

  • 免費層慷慨
  • 付費:Llama 3.3 70B input $0.59、output $0.79 / 1M

5. DeepSeek(推理強 + 便宜

介紹

  • DeepSeek R1:推理能力接近 o1,價格 1/30
  • DeepSeek V3:通用模型,跟 Claude Sonnet 同檔位
  • 中國公司,但 API 在境外可直接打

申請

  1. https://platform.deepseek.com/ → Sign up
  2. 充值(最低 $1)— 信用卡 / Stripe
  3. API key → sk-...

Python(OpenAI 相容)

python
client = OpenAI(
    api_key=os.environ["DEEPSEEK_API_KEY"],
    base_url="https://api.deepseek.com/v1",
)
resp = client.chat.completions.create(
    model="deepseek-chat",  # or "deepseek-reasoner"
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}],
)

費用

  • deepseek-chat (V3):input $0.14(cache hit)/ $0.27 / 1M
  • deepseek-reasoner (R1):input $0.55 / output $2.19 / 1M

6. Mistral AI(歐盟、GDPR 友善)

介紹

  • 法國公司,資料留歐盟
  • 開源 model(Mistral 7B, Mixtral 8x7B)也能自架
  • 適合需要 EU 合規的場景

申請

  1. https://console.mistral.ai/ → Sign up
  2. Workspace → Billing → Add card
  3. API Keys → 建立

Python

python
# pip install mistralai
from mistralai import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
resp = client.chat.complete(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}],
)
print(resp.choices[0].message.content)

費用

  • Mistral Large:input $2、output $6 / 1M
  • Mistral Small:input $0.2、output $0.6 / 1M

7. OpenRouter(聚合器,一個 key 打全部

介紹

  • 一個 API key 可以打 Anthropic / OpenAI / Google / Mistral / Llama 等 100+ 模型
  • 每家 list price + 5.5% 手續費
  • 適合「想比較多家、不想開 N 個帳號」的學習階段

申請

  1. https://openrouter.ai/ → Sign up (Google / GitHub)
  2. Credits → 充值(最低 $5,支援信用卡 / 加密貨幣)
  3. Keys → Create key → sk-or-v1-...

Python(OpenAI 相容)

python
client = OpenAI(
    api_key=os.environ["OPENROUTER_API_KEY"],
    base_url="https://openrouter.ai/api/v1",
)
resp = client.chat.completions.create(
    model="anthropic/claude-haiku-4.5",  # 也可以 "openai/gpt-4o-mini" 等
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}],
)

費用

  • 各家 list price + 5.5%
  • 也提供「免費」型號(速率受限)

8. xAI Grok

介紹

  • Elon Musk 的 xAI
  • 整合 X (Twitter) realtime 資料
  • 訂閱 X Premium+ 內含網頁版

申請

  1. https://console.x.ai/ → Sign up
  2. Billing → Add card
  3. API Keys → xai-...

Python(OpenAI 相容)

python
client = OpenAI(
    api_key=os.environ["XAI_API_KEY"],
    base_url="https://api.x.ai/v1",
)
resp = client.chat.completions.create(
    model="grok-2-latest",
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}],
)


其他類別商業 API · 本地/主權 · 全本一頁


熱門 LLM · 本地推論 / 台灣主權 / 中文圈

← 回 LLM / API 申請總覽

不想申請 cloud API key、不想付費、想自己掌握資料?這頁列 3 種選擇:本地推論、台灣主權、中文圈三家。

9. 本地跑(Ollama / LM Studio)— 不用 API key

介紹

完全離線、零成本、隱私 100% — 缺點是要你自己有 GPU(或 Apple Silicon M-series)。

Ollama(CLI 推薦)

bash
# Mac
brew install ollama
ollama serve  # 背景跑

# 拉模型(4GB 起跳)
ollama pull llama3.2:3b
ollama pull qwen2.5:14b
ollama pull deepseek-r1:7b

# 跑
ollama run llama3.2:3b "用繁中介紹 AI Agent。"

Python(OpenAI 相容)

python
client = OpenAI(
    api_key="ollama",  # 隨便填
    base_url="http://localhost:11434/v1",
)
resp = client.chat.completions.create(
    model="llama3.2:3b",
    messages=[{"role": "user", "content": "用繁中介紹 AI Agent。"}],
)

硬體建議

設備能跑
MacBook Air M2 8GB3B 模型勉強
MacBook Pro M3 16GB7B 流暢、13B 慢
Mac Studio M3 Ultra 128GB70B 流暢、235B 可跑
4090 24GB13B 流暢、Q4 量化 30B
雙 4090 / A10070B+

10. TAIDE(台灣主權繁中模型

介紹

  • 國科會(NSTC)+ 工研院(ITRI)主導
  • 基於 Llama 3 訓練,加大量繁中語料
  • 目標:台灣公部門、企業有「不依賴境外 API」的選擇
  • 沒有官方雲端 API,只能自架(HuggingFace 下載 weights)

申請使用

  1. https://taide.tw/ → 註冊 → 填用途
  2. 通過審核後可下載 weights(HuggingFace 連結)
  3. 自架(建議用 vllm / Ollama / llama.cpp)

自架(Ollama 範例)

bash
# 從 HuggingFace 下載 GGUF 格式
huggingface-cli download taide/Llama-3.1-TAIDE-LX-8B-Chat \
    --local-dir ./taide-8b

# 寫 Modelfile
cat > Modelfile <<EOF
FROM ./taide-8b/Llama-3.1-TAIDE-LX-8B-Chat.Q4_K_M.gguf
PARAMETER temperature 0.7
EOF

# 載入
ollama create taide-8b -f Modelfile
ollama run taide-8b "用繁中介紹 AI Agent。"

AgentZ 整合

  • Ch 13(Memory / RAG):用 TAIDE 當生成模型 + OpenAI embedding 做 RAG
  • Ch 17(Builder 進階):用 TAIDE 做 Agentic-RL 本地訓練

11. Qwen / 智譜 GLM / 零一萬物 Yi

中文圈三家強模型,都可以從 HuggingFace 抓 weights 自架,或用各家雲端 API(不一定有境外可用版本)。

  • Qwen2.5(阿里):14B / 32B / 72B 開源,繁中表現好
  • GLM-4(智譜):6B / 9B 開源
  • Yi-1.5(零一萬物,李開復):6B / 34B 開源

自架方式同 TAIDE:用 Ollama 或 vllm。



其他類別商業 API · 開源/聚合 · 全本一頁


← 回 LLM / API 申請總覽 · 首頁 · GitHub

MIT License — 章節內容跟 starter code 都可以 copy 進你自己的商業專案