# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: CLI Proxy API (CPA)
spec:
    description: OpenAI/Gemini/Claude/Codex compatible API proxy with OAuth support for AI coding tools
    coverImage: https://opengraph.githubassets.com/1/router-for-me/CLIProxyAPI
    icon: https://avatars.githubusercontent.com/u/233033915?s=64&v=4
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: Domain for accessing CLIProxyAPI (API will be available at https://<domain>)
        - key: MANAGEMENT_PASSWORD
          type: STRING
          name: Management Password
          description: Password for accessing the management web UI (required for remote configuration)
        - key: API_KEY
          type: STRING
          name: API Key
          description: API key for connecting your AI coding tools (e.g. sk-xxxx)
    tags:
        - AI
        - API
        - Proxy
        - Tool
    readme: |-
        # CLI Proxy API

        For full documentation, see [help.router-for.me](https://help.router-for.me/).

        This template pre-configures persistent auth-dir for OAuth credentials, with all necessary ports exposed.

        ## Quick Start

        1. **Bind domain to port 8317**: Go to Networking > Domain, bind your `*.zeabur.app` domain to port **8317**
        2. Open Management UI: `https://<your-domain>/management.html?key=<MANAGEMENT_PASSWORD>`
        3. Click OAuth button to authenticate your provider
        4. Connect your tool with **Base URL** `https://<your-domain>/v1` and **API Key** from `API_KEY` variable

        ## Variables

        | Variable | Description |
        |---|---|
        | `PUBLIC_DOMAIN` | Domain bound to this service (auto-configured by Zeabur) |
        | `MANAGEMENT_PASSWORD` | Password for Management UI and API |
        | `API_KEY` | API key for connecting your AI coding tools |

        ## Persistent Storage

        All data is stored under `/data` (persistent volume):

        | Path | Description |
        |---|---|
        | `/data/config.yaml` | Main configuration file |
        | `/data/.cli-proxy-api/` | OAuth credentials directory ([auth-dir](https://help.router-for.me/configuration/auth-dir.html)) |
        | `/data/logs/` | Application logs |

        ## Ports

        | Port | Purpose |
        |---|---|
        | 8317 | API & Management UI (HTTP) |
        | 8085 | OAuth Callback (HTTP) |
        | 1455 | Codex OAuth (TCP) |
        | 54545 | Claude OAuth (TCP) |
        | 51121 | Antigravity OAuth (TCP) |
        | 11451 | iFlow OAuth (TCP) |
        | 56121 | xAI/Grok OAuth (TCP) |
    services:
        - name: CLIProxyAPI
          icon: https://avatars.githubusercontent.com/u/233033915?s=64&v=4
          template: PREBUILT
          spec:
            id: cliproxyapi
            source:
                image: eceasy/cli-proxy-api:latest
                command:
                    - /bin/sh
                    - -c
                    - 'if [ ! -f /data/config.yaml ]; then cp /CLIProxyAPI/config.example.yaml /data/config.yaml && sed -i "s|auth-dir:.*|auth-dir: \"/data/.cli-proxy-api\"|" /data/config.yaml && sed -i ''s|logging-to-file:.*|logging-to-file: true|'' /data/config.yaml && sed -i "s|your-api-key-1|${API_KEY}|" /data/config.yaml && sed -i ''/your-api-key-2/d'' /data/config.yaml && sed -i ''/your-api-key-3/d'' /data/config.yaml && ln -sf /data/logs /CLIProxyAPI/logs; fi && /CLIProxyAPI/CLIProxyAPI --config /data/config.yaml'
            ports:
                - id: api
                  port: 8317
                  type: HTTP
                - id: management
                  port: 8085
                  type: HTTP
                - id: codexoauth
                  port: 1455
                  type: TCP
                - id: claudeoauth
                  port: 54545
                  type: TCP
                - id: antigravity
                  port: 51121
                  type: TCP
                - id: iflowoauth
                  port: 11451
                  type: TCP
                - id: xaioauth
                  port: 56121
                  type: TCP
            volumes:
                - id: data
                  dir: /data
            env:
                DEPLOY:
                    default: cloud
                    expose: false
                PORT:
                    default: "8317"
                    expose: true
localization:
    zh-CN:
        description: OpenAI/Gemini/Claude/Codex 兼容的 API 代理服务，支持 OAuth 认证
        readme: |-
            # CLI Proxy API

            完整文档请见 [help.router-for.me](https://help.router-for.me/)。

            此模板预先配置持久化的 auth-dir 存储 OAuth 凭证，并开放所有必要的端口。

            ## 快速开始

            1. **绑定域名至 port 8317**：前往 Networking > Domain，将 `*.zeabur.app` 绑定至端口 **8317**
            2. 打开管理界面：`https://<your-domain>/management.html?key=<MANAGEMENT_PASSWORD>`
            3. 点击 OAuth 按钮认证您的供应商
            4. 使用 **Base URL** `https://<your-domain>/v1` 和 `API_KEY` 变量中的密钥连接工具

            ## 变量

            | 变量 | 说明 |
            |---|---|
            | `PUBLIC_DOMAIN` | 绑定到此服务的域名（Zeabur 自动配置） |
            | `MANAGEMENT_PASSWORD` | 管理界面与 API 的密码 |

            ## 持久化存储

            所有数据存储在 `/data`（持久化卷）：

            | 路径 | 说明 |
            |---|---|
            | `/data/config.yaml` | 主配置文件 |
            | `/data/.cli-proxy-api/` | OAuth 凭证目录 ([auth-dir](https://help.router-for.me/configuration/auth-dir.html)) |

            ## 端口

            | 端口 | 用途 |
            |---|---|
            | 8317 | API 与管理界面 (HTTP) |
            | 8085 | OAuth 回调 (HTTP) |
            | 1455 | Codex OAuth (TCP) |
            | 54545 | Claude OAuth (TCP) |
            | 51121 | Antigravity OAuth (TCP) |
            | 11451 | iFlow OAuth (TCP) |
            | 56121 | xAI/Grok OAuth (TCP) |
    zh-TW:
        description: OpenAI/Gemini/Claude/Codex 相容的 API 代理服務，支援 OAuth 認證
        readme: |-
            # CLI Proxy API

            完整文件請見 [help.router-for.me](https://help.router-for.me/)。

            此模板預先設定持久化的 auth-dir 儲存 OAuth 憑證，並開放所有必要的連接埠。

            ## 快速開始

            1. **綁定網域至 port 8317**：前往 Networking > Domain，將 `*.zeabur.app` 綁定至連接埠 **8317**
            2. 開啟管理介面：`https://<your-domain>/management.html?key=<MANAGEMENT_PASSWORD>`
            3. 點擊 OAuth 按鈕認證您的供應商
            4. 使用 **Base URL** `https://<your-domain>/v1` 和 `API_KEY` 變數中的金鑰連接工具

            ## 變數

            | 變數 | 說明 |
            |---|---|
            | `PUBLIC_DOMAIN` | 綁定到此服務的網域（Zeabur 自動設定） |
            | `MANAGEMENT_PASSWORD` | 管理介面與 API 的密碼 |

            ## 持久化儲存

            所有資料儲存在 `/data`（持久化磁碟區）：

            | 路徑 | 說明 |
            |---|---|
            | `/data/config.yaml` | 主設定檔 |
            | `/data/.cli-proxy-api/` | OAuth 憑證目錄 ([auth-dir](https://help.router-for.me/configuration/auth-dir.html)) |

            ## 連接埠

            | 連接埠 | 用途 |
            |---|---|
            | 8317 | API 與管理介面 (HTTP) |
            | 8085 | OAuth 回呼 (HTTP) |
            | 1455 | Codex OAuth (TCP) |
            | 54545 | Claude OAuth (TCP) |
            | 51121 | Antigravity OAuth (TCP) |
            | 11451 | iFlow OAuth (TCP) |
            | 56121 | xAI/Grok OAuth (TCP) |
