GitHub Copilot CLI 是 GitHub 为终端提供的 AI 编程代理。它可以理解您的代码库、进行编辑、运行命令,并帮助您更快速地构建软件。
您可以通过 Ollama 在 Copilot CLI 中使用开源模型,从而可以使用诸如 qwen3.5、glm-5.1:cloud、kimi-k2.5:cloud 等模型。
安装
安装 Copilot CLI:
shell
brew install copilot-clishell
npm install -g @github/copilotshell
curl -fsSL https://gh.io/copilot-install | bashpowershell
winget install GitHub.Copilot与 Ollama 配合使用
快速设置
shell
ollama launch copilot直接使用模型运行
shell
ollama launch copilot --model kimi-k2.5:cloud推荐模型
kimi-k2.5:cloudglm-5:cloudminimax-m2.7:cloudqwen3.5:cloudglm-4.7-flashqwen3.5
您也可以在 ollama.com/search?c=cloud 获取云端模型。
非交互式(无界面)模式
在 Docker、CI/CD 或脚本中使用时,可以在无需交互的情况下运行 Copilot CLI:
shell
ollama launch copilot --model kimi-k2.5:cloud --yes -- -p "how does this repository work?"--yes 标志会自动拉取模型、跳过选择器,并要求指定 --model。在 -- 之后的参数将直接传递给 Copilot CLI。
手动设置
Copilot CLI 通过环境变量使用与 OpenAI 兼容的 API 连接到 Ollama。
- 设置环境变量:
shell
export COPILOT_PROVIDER_BASE_URL=http://localhost:11434/v1
export COPILOT_PROVIDER_API_KEY=
export COPILOT_PROVIDER_WIRE_API=responses
export COPILOT_MODEL=qwen3.5- 运行 Copilot CLI:
shell
copilot或者在命令行中直接带上环境变量运行:
shell
COPILOT_PROVIDER_BASE_URL=http://localhost:11434/v1 COPILOT_PROVIDER_API_KEY= COPILOT_PROVIDER_WIRE_API=responses COPILOT_MODEL=glm-5:cloud copilot注意: Copilot 需要较大的上下文窗口。我们建议至少使用 64k token。请参阅 上下文长度文档 以了解如何在 Ollama 中调整上下文长度。