forked from ericc-ch/copilot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-openai-https.bat
More file actions
71 lines (65 loc) · 2.06 KB
/
Copy pathstart-openai-https.bat
File metadata and controls
71 lines (65 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@echo off
:: Make the script location-independent: run everything relative to this file's
:: folder so .env, certs\, and `bun run ./src/main.ts` always resolve the same
:: way whether double-clicked or called by full path.
cd /d "%~dp0"
setlocal
TITLE Copilot API - OpenAI Proxy HTTPS (Codex, 9443)
echo ================================================
echo GitHub Copilot API - OpenAI Compatible Proxy
echo For use with Codex / OpenAI-compatible clients
echo HTTPS - Port: 9443
echo ================================================
echo.
:: Load environment variables from .env if it exists
if exist .env (
echo Loading environment from .env...
for /f "usebackq tokens=1,* delims==" %%A in (".env") do (
if not "%%A"=="" if not "%%A:~0,1%"=="#" (
set "%%A=%%B"
)
)
echo.
)
:: --- Port + TLS / HTTPS configuration ---------------------------------
set "PORT=9443"
:: LAN IP the other machine uses to reach this PC (must match a cert SAN).
set "LAN_IP=192.168.0.105"
:: Point the server at the self-signed cert generated by generate-cert.bat.
set "TLS_CERT=%~dp0certs\server.crt"
set "TLS_KEY=%~dp0certs\server.key"
if not exist "%TLS_CERT%" (
echo TLS certificate not found at "%TLS_CERT%".
echo Run generate-cert.bat first to create it.
echo.
pause
exit /b 1
)
:: Build if dist/ doesn't exist
if not exist dist (
echo Building project...
bun run build
echo.
)
echo Starting OpenAI-compatible proxy on https://localhost:%PORT%
echo Reachable from other machines at https://%LAN_IP%:%PORT%
echo.
echo Codex config (codex.json or ~/.codex/config.json):
echo {
echo "model": "gpt-4o",
echo "provider": "openai",
echo "providers": {
echo "openai": {
echo "name": "openai",
echo "base_url": "https://%LAN_IP%:%PORT%/v1",
echo "env_key": "OPENAI_API_KEY"
echo }
echo }
echo }
echo.
echo Or run Codex with:
echo set OPENAI_API_KEY=dummy ^& set OPENAI_BASE_URL=https://%LAN_IP%:%PORT%/v1 ^& codex
echo.
bun run ./src/main.ts start --port %PORT% --verbose
pause
endlocal