GPT-6.1 Sol 可以免费用(注册送额度),在 Codex 里就能让它帮你写 Python 脚本。但国内写 Python 第一步经常卡在装库:pip install 慢到几 KB/s,或者直接报 ReadTimeoutError、Could not find a version that satisfies the requirement。换国内镜像就好了。
1. 临时用一次镜像
bash
pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple
2. 永久换成清华镜像
bash
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config list
输出里有 tuna.tsinghua.edu.cn 就说明换好了,之后 pip install 都走镜像。
清华的不稳定可以换阿里云:https://mirrors.aliyun.com/pypi/simple/
3. 还是报错?
pip 不是内部或外部命令(Windows):用python -m pip install 包名。- Mac/Linux 提示
externally-managed-environment:先建虚拟环境再装:
bash
python3 -m venv venv
source venv/bin/activate
pip install requests
- 换完镜像还是
Could not find a version:多半是 Python 版本太老或包名写错,python --version看一下版本,去 pypi.org 核对包名。
4. 注册拿 Key
GPT-6.1 Sol 目前在 AgentRouter 上,GitHub 账号满一年就能注册,用注册送的额度就能跑。用我的邀请链接注册:https://agentrouter.org/register?aff=76NE
注册后在控制台新建一个令牌,复制备用。
5. 配置 Codex
编辑 ~/.codex/config.toml(Windows 是 %USERPROFILE%\.codex\config.toml):
toml
model = "gpt-6.1-sol"
model_provider = "agentrouter"
[model_providers.agentrouter]
name = "AgentRouter"
base_url = "https://agentrouter.org/v1"
env_key = "AGENTROUTER_API_KEY"
wire_api = "responses"
设置环境变量后,在项目文件夹里启动:
bash
export AGENTROUTER_API_KEY="sk-..."
codex
可以直接这样问它:"帮我把这个项目用到的库整理成 requirements.txt,然后告诉我怎么用清华镜像一次装好。"
常见报错
- 404:
base_url要以/v1结尾。 - 401:令牌没复制全,重新复制。
- 模型不存在:ID 是
gpt-6.1-sol,全小写。 responses相关错误:改成wire_api = "chat"。
各中转站汇总和配置教程:https://jliushi.github.io/ai-relay/