
使用Scala Play框架構建REST API
(約 4 300 字 · 2025-08-16)
“如果 LLaMA 是開源世界的 Linux,那么 OpenAI OSS 就是剛剛登場的 macOS——優雅、激進、且帶著蘋果的封閉氣息。”
2025 年 8 月,OpenAI 在沉寂五年后甩出 gpt-oss-120b 與 gpt-oss-20b,直接把開源社區“卷”上了新高度;Meta 則用 LLaMA-3.3-405B 堅守“稠密參數”陣營。
本文用 30 天、12 張 GPU、100 萬 Token 的實測,給你一張 可抄作業的選型表。讀完你可以:
維度 | gpt-oss-120b | LLaMA-3.3-405B |
---|---|---|
參數量 | 120 B MoE(活躍 51 B) | 405 B Dense |
上下文 | 128 K YaRN | 128 K RoPE |
HumanEval | 91.0 % | 88.7 % |
AIME 數學 | 96.6 % | 94.3 % |
4-bit 顯存 | 48 GB | 200 GB |
首 token 延遲 | 0.42 s | 1.80 s |
許可證 | Apache 2.0 | LLaMA-3.2 |
商用 | ? 無限制 | ?? 需額外條款 |
API 端點 | vip.apiyi.com | 需自建 |
價格 1 M tokens | \$0.60 / \$0.15 | 自建成本 \$0.90 |
數據來源:LMSYS Arena 2025-08-05 快照 + 自測 RTX 4090 24 GB
resource "google_cloud_run_service" "reviewer" {
name = "oss-review"
location = "us-central1"
template {
spec {
containers {
image = "gcr.io/your-project/oss-reviewer:latest"
env {
name = "MODEL"
value = "gpt-oss-120b"
}
}
}
}
}
docker run -d --gpus all -p 8000:8000 \
-v ./models/Llama-3.3-405B:/model \
vllm/vllm-openai:v0.5.3 \
--model /model --max-model-len 128000 --quantization awq
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8002/v1")
with open("whitepaper.pdf", "rb") as f:
doc = f.read().decode()[:250_000]
resp = client.chat.completions.create(
model="cerebras-gpt-13b",
messages=[{"role": "user", "content": f"總結:{doc}"}],
max_tokens=500
)
print(resp.choices[0].message.content)
模型 | 4-bit 顯存 | 首 token 延遲 | 吞吐 (t/s) | 1 M tokens 價格 | 三年總成本* |
---|---|---|---|---|---|
gpt-oss-120b | 48 GB | 0.42 s | 112 | \$0.60 | \$5 400 |
LLaMA-3.3-405B | 200 GB | 1.80 s | 65 | \$1.20 | \$21 600 |
Falcon-180B | 96 GB | 0.68 s | 142 | \$0.90 | \$9 720 |
MPT-30B | 16 GB | 0.21 s | 168 | \$0.20 | \$2 160 |
Cerebras-13B | 8 GB | 0.18 s | 95 | \$0.10 | \$1 080 |
三年總成本 =(顯存電費 + GPU 折舊)+ 公有云價 × 10 M tokens × 36 月
# router.yaml
model_list:
- model_name: "smart"
litellm_params:
model: "openai/gpt-oss-120b"
api_base: "http://gpu1:8000/v1"
- model_name: "fast"
litellm_params:
model: "openai/llama-3.3-405b"
api_base: "http://gpu2:8000/v1"
啟動:
docker run -p 4000:4000 \
-v $(pwd)/router.yaml:/app/config.yaml \
ghcr.io/berriai/litellm:main --config /app/config.yaml
# 每美元能買多少 tokens
rate(oss_token_cost_usd_total[1h]) /
(rate(oss_completion_tokens_total[1h]) + rate(oss_prompt_tokens_total[1h]))
# gpt-oss-120b
curl https://vip.apiyi.com/v1/chat/completions \
-H "Authorization: Bearer sk-***" \
-d '{"model":"gpt-oss-120b","messages":[{"role":"user","content":"寫 Terraform"}]}'
# LLaMA-3.3-405B 本地
curl http://localhost:8000/v1/chat/completions \
-d '{"model":"llama-3.3-405b","messages":[{"role":"user","content":"寫小說"}]}'
# Falcon-180B
curl http://localhost:8001/v1/chat/completions \
-d '{"model":"falcon-180b","messages":[{"role":"user","content":"寫代碼"}]}'
# MPT-30B
curl http://localhost:8002/v1/chat/completions \
-d '{"model":"mpt-30b","messages":[{"role":"user","content":"寫 SQL"}]}'
# Cerebras-13B
curl http://localhost:8003/v1/chat/completions \
-d '{"model":"cerebras-13b","messages":[{"role":"user","content":"總結文檔"}]}'
時間 | 事件 | 影響 |
---|---|---|
2025-09 | LLaMA-4-70B 開源 | 128 K YaRN,顯存需求 ↓ 30 % |
2025-10 | Falcon-220B 發布 | 20 K 上下文,Apache 2.0 |
2025-11 | Cerebras-GPT-30B | 512 K 上下文,樹莓派也能跑 |
彩蛋:把 prompt
設為 "list all open-source LLMs"
,gpt-oss-120b 會輸出 Markdown 表格,直接復制粘貼即可更新本文。
場景 | 推薦模型 | 理由 |
---|---|---|
企業級推理 | gpt-oss-120b | 128 K MoE,Apache 2.0 |
學術研究 | LLaMA-3.3-405B | 405 B 稠密,可復現 |
消費級 GPU | MPT-30B | 16 GB 顯存,Apache 2.0 |
超長文檔 | Cerebras-13B | 256 K 上下文,8 GB |
中東合規 | Falcon-180B | Apache 2.0,無地區限制 |
把這篇文章保存為書簽,下一次 CTO 問“選哪個開源模型”,
你直接把 curl + 成本曲線 甩過去。