feat: 实现ChatGPT Codex路由器的核心功能
- 添加完整的项目基础结构,包括配置、类型定义和常量 - 实现OAuth认证流程和令牌管理 - 开发请求转换和响应处理逻辑 - 添加SSE流处理和ChatCompletions API转换 - 实现模型映射和提示指令系统 - 包含Docker部署配置和快速启动文档 - 添加自动登录功能和测试脚本
This commit is contained in:
123
QUICK_START.md
Normal file
123
QUICK_START.md
Normal file
@@ -0,0 +1,123 @@
|
||||
# Quick Start Guide
|
||||
|
||||
## First Time Setup (Auto Login)
|
||||
|
||||
1. **Start the server:**
|
||||
```bash
|
||||
cd /home/mars/project/chatgpt-codex-router
|
||||
npm start
|
||||
```
|
||||
|
||||
2. **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.
|
||||
```
|
||||
|
||||
3. **Complete OAuth in your browser:**
|
||||
- The browser should open automatically
|
||||
- Login to your ChatGPT account
|
||||
- Authorize the application
|
||||
- The browser will show "Authentication Successful"
|
||||
|
||||
4. **Server is now ready:**
|
||||
- Token is saved to `~/.chatgpt-codex-router/tokens.json`
|
||||
- Server is running on http://localhost:3000
|
||||
|
||||
## 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
|
||||
```bash
|
||||
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
|
||||
```bash
|
||||
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:
|
||||
```bash
|
||||
# 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:
|
||||
```bash
|
||||
curl -X POST http://localhost:3000/auth/login
|
||||
```
|
||||
|
||||
### View Logs
|
||||
```bash
|
||||
# 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`:
|
||||
```json
|
||||
{
|
||||
"server": {
|
||||
"port": 3000
|
||||
},
|
||||
"logging": {
|
||||
"level": "info",
|
||||
"enableRequestLogging": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## More Information
|
||||
|
||||
- **Full Documentation**: See [README.md](README.md)
|
||||
- **Auto-Login Details**: See [AUTO_LOGIN.md](AUTO_LOGIN.md)
|
||||
- **Project Plan**: See [plan.md](plan.md)
|
||||
Reference in New Issue
Block a user