- 添加完整的项目基础结构,包括配置、类型定义和常量 - 实现OAuth认证流程和令牌管理 - 开发请求转换和响应处理逻辑 - 添加SSE流处理和ChatCompletions API转换 - 实现模型映射和提示指令系统 - 包含Docker部署配置和快速启动文档 - 添加自动登录功能和测试脚本
2.6 KiB
2.6 KiB
Quick Start Guide
First Time Setup (Auto Login)
-
Start the server:
cd /home/mars/project/chatgpt-codex-router npm start -
Watch for auto-login messages:
[WARN] No authentication token found. Initiating OAuth login... [INFO] OAuth login initiated. [INFO] Please complete the OAuth flow in your browser. -
Complete OAuth in your browser:
- The browser should open automatically
- Login to your ChatGPT account
- Authorize the application
- The browser will show "Authentication Successful"
-
Server is now ready:
- Token is saved to
~/.chatgpt-codex-router/tokens.json - Server is running on http://localhost:3000
- Token is saved to
Subsequent Starts
After first authentication, subsequent starts will show:
[INFO] Authentication token found and valid.
[INFO] Server started on http://0.0.0.0:3000
No login required!
Making API Calls
Simple Chat Request
curl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.2-codex",
"messages": [
{"role": "user", "content": "Hello, world!"}
]
}'
Streaming Request
curl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.2-codex",
"messages": [
{"role": "user", "content": "Tell me a joke"}
],
"stream": true
}'
Available Models
gpt-5.1- General purpose (none/low/medium/high)gpt-5.2- General purpose (none/low/medium/high/xhigh)gpt-5.1-codex- Coding (low/medium/high)gpt-5.1-codex-max- Advanced coding (low/medium/high/xhigh)gpt-5.1-codex-mini- Quick coding (medium/high)gpt-5.2-codex- Latest coding (low/medium/high/xhigh)
Troubleshooting
Port Already in Use
If port 1455 is occupied:
# Find and kill the process
lsof -ti:1455 | xargs kill -9
# Or use a different port
# (See AUTO_LOGIN.md for configuration options)
Manual Login
If auto-login fails:
curl -X POST http://localhost:3000/auth/login
View Logs
# All logs
tail -f logs/*-info.log
# Errors only
tail -f logs/*-error.log
# Warnings only
tail -f logs/*-warn.log
Configuration
Create ~/.chatgpt-codex-router/config.json:
{
"server": {
"port": 3000
},
"logging": {
"level": "info",
"enableRequestLogging": false
}
}
More Information
- Full Documentation: See README.md
- Auto-Login Details: See AUTO_LOGIN.md
- Project Plan: See plan.md