模型介绍
Groq 用自研 LPU(Language Processing Unit)芯片做 AI 推理,速度是 GPU 的 10-100 倍。适合对延迟要求极高的实时应用场景。支持 Llama 3、Mixtral、Gemma 等开源模型。
API 接入信息
| 项目 | 详情 |
|---|
| API Endpoint | https://api.groq.com/openai/v1/chat/completions |
| 鉴权方式 | Bearer Token(OpenAI 兼容) |
| 默认模型 | llama-3.3-70b-versatile |
| MCP / Function Calling | ✅ 完整支持 |
价格
| 类型 | 价格 |
|---|
| 输入(Input) | $0.59 / 1M tokens |
| 输出(Output) | $0.79 / 1M tokens |
| 速度比 GPU 快 10-100x |
关键参数
| 参数名 | 类型 | 默认值 | 说明 |
|---|
| model | string | llama-3.3-70b-versatile | Llama 3 / Mixtral / Gemma 等开源模型 |
| temperature | float | 0.7 | 0-2 |
| stream | boolean | true | 流式输出推荐开启 |
curl 调用示例
curl https://api.groq.com/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $GROQ_API_KEY" \
-d '{
"model": "llama-3.3-70b-versatile",
"messages": [{"role": "user", "content": "速度测试"}],
"stream": true
}'
Python 调用示例
from openai import OpenAI
client = OpenAI(
api_key="gsk_xxx",
base_url="https://api.groq.com/openai/v1"
)
stream = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "速度测试"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
优势场景
- 速度最快
- OpenAI 兼容
- 支持多种开源模型
- 免费额度充足
最适合的场景
实时应用 / 低延迟场景 / 原型快速验证