Models
MushroomAgent 通过 config.yaml 中的 llm 配置段连接 LLM 提供商。它支持 OpenAI 及任意 OpenAI 兼容的 API。
基本配置
llm:
api_type: "openai"
api_key: "sk-..."
base_url: "https://api.openai.com/v1"
model: "gpt-5.2"
API 密钥也可以通过环境变量 LLM_API_KEY 设置 — 当配置文件中 api_key 为空时会自动读取。
关键参数
| 字段 | 默认值 | 说明 |
|---|---|---|
api_type | — | 设为 openai |
api_key | — | API 密钥 |
base_url | — | API 端点地址 |
model | — | 模型名称 |
temperature | 0.0 | 采样温度 (0-2) |
max_completion_tokens | 4096 | 最大输出 token 数 |
stream | false | 启用流式响应 |
timeout | 600 | 请求超时时间(秒) |
OpenAI 兼容的提供商
任何暴露 OpenAI 兼容 API 的服务都可以使用 — 只需修改 base_url:
| 服务 | base_url |
|---|---|
| OpenAI | https://api.openai.com/v1 |
| Azure OpenAI | 你的 Azure 端点地址 |
| Ollama(本地) | http://localhost:11434/v1 |
| 任意 OpenAI 兼容的服务 | 根据服务商而定 |
如需使用 Anthropic Claude、Google Gemini 等非 OpenAI 模型,请通过提供 OpenAI 兼容适配的代理服务接入(如 One API、LiteLLM)。
实时语音模型
语音模式下,通过单独的 realtime_llm 段配置流式模型:
realtime_llm:
model: "gpt-realtime"
api_key: "YOUR_REALTIME_API_KEY" # 未设置则回退到 llm.api_key
Embedding 模型
记忆和检索功能需配置 embedding 段:
embedding:
api_type: "openai"
api_key: ""
base_url: "https://api.openai.com/v1"
model: "text-embedding-3-small"
dimensions: 1536
支持的 embedding 类型:openai(及 OpenAI 兼容)、dashscope。
参考
全部字段见 配置参考。