接入 DeepSeek
DeepSeek 以兼具性能和成本优势的模型服务受到很多 AI 应用团队关注。API7 AI 网关提供 DeepSeek 专用驱动,建议直接使用 deepseek 类型,而不是通用的 openai-compatible 类型。
前提条件
获取 DeepSeek 访问密钥
在 DeepSeek 平台创建访问密钥,并写入环境变量:
export DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
配置 DeepSeek 代理
- Admin API
- ADC
curl "http://127.0.0.1:7080/apisix/admin/routes?gateway_group_id=default" -X PUT \
-H "X-API-KEY: $ADMIN_API_KEY" \
-d '{
"id": "deepseek-route",
"service_id": "'"$SERVICE_ID"'",
"paths": ["/deepseek"],
"plugins": {
"ai-proxy": {
"provider": "deepseek",
"auth": {
"header": {
"Authorization": "Bearer '"$DEEPSEEK_API_KEY"'"
}
},
"options": {
"model": "deepseek-chat"
}
}
}
}'
adc.yaml
services:
- name: DeepSeek Service
routes:
- name: deepseek-route
uris:
- /deepseek
plugins:
ai-proxy:
provider: deepseek
auth:
header:
Authorization: Bearer ${DEEPSEEK_API_KEY}
options:
model: deepseek-chat
使用建议
- 将 DeepSeek 与其他模型放入
ai-proxy-multi,可按成本、质量或可用性做流量分配。 - 对高频业务开启令牌限流,避免异常请求导致预算失控。
- 在日志中保留模型、延迟、错误和令牌用量,用于效果评估和成本分析。