File size: 1,931 Bytes
26a61c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Install CLIProxyAPI binary + scaffold config under agents/cliproxyapi/_vendor/.
# Re-run any time to upgrade. Linux x86_64 only here; adjust BINARY_NAME for
# other platforms (see github.com/router-for-me/CLIProxyAPI/releases).
#
# Override the release with: CLIPROXYAPI_VERSION=v0.5.2 bash install.sh
set -euo pipefail

VERSION="${CLIPROXYAPI_VERSION:-v0.5.2}"
HERE="$(cd "$(dirname "$0")" && pwd)"
DEST="${HERE}/_vendor"
BINARY_NAME="cli-proxy-api-linux-amd64"
URL="https://github.com/router-for-me/CLIProxyAPI/releases/download/${VERSION}/${BINARY_NAME}"

mkdir -p "${DEST}"
cd "${DEST}"

if [[ -x ./cli-proxy-api ]]; then
    echo "cli-proxy-api already present at ${DEST}/cli-proxy-api (delete to force re-download)"
else
    echo "Downloading ${URL}"
    curl -fL --retry 3 -o cli-proxy-api "${URL}"
    chmod +x cli-proxy-api
fi

if [[ ! -f config.yaml ]]; then
    cp ../config.example.yaml config.yaml
    echo "Copied agents/cliproxyapi/config.example.yaml → _vendor/config.yaml"
    echo "  → Edit the 'api-keys:' list before first use."
fi

cat <<EOF

Installed CLIProxyAPI ${VERSION} under ${DEST}

Next steps:
  1. Edit ${DEST}/config.yaml — set the 'api-keys:' list to a secret of your
     choosing (the agent runners read CLIPROXYAPI_KEY which must match).
  2. OAuth-login each upstream you intend to use, e.g.:
       cd ${DEST}
       ./cli-proxy-api --config config.yaml login claude
       ./cli-proxy-api --config config.yaml login codex
     The resulting token JSONs land in ~/.cli-proxy-api/ by default.
  3. Start the proxy in the background:
       cd ${DEST}
       nohup ./cli-proxy-api --config config.yaml > proxy.log 2>&1 &
  4. (Optional) Start the max_tokens-clamp passthrough used by aibuildai:
       cd ${HERE%/cliproxyapi}/..   # repo root
       .venv/bin/python -m agents.cliproxyapi.clamp_proxy &
  5. export CLIPROXYAPI_KEY=<the api-key you set in step 1>
EOF