Skip to content

About

大妙 AI 本地代理 - Electron 桌面版,把腾讯云开发混元模型暴露为 OpenAI 兼容接口 http://localhost:8765/v1

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

damiao-proxy · 大妙 AI Local Proxy

English (default) · 简体中文

Turn Tencent CloudBase / Hunyuan models into a local OpenAI-compatible API at http://localhost:8765/v1, with a desktop control panel and multi-account billing routing. No WeChat DevTools required — one process, one port, works with any OpenAI-format client.

version platform runtime license


What it does

Hosted AI models behind Tencent's 小程序成长计划 (Growth Plan) token package can only be called through the CloudBase SDK — a plain HTTP call fails with AI_CHANNEL_NOT_ALLOWED. This project solves that by relaying through a CloudBase cloud function, then re-exposing everything as a standard OpenAI endpoint on localhost, so any agent can consume it.

Your agent (OpenAI format)
    │  POST /v1/chat/completions
    ▼
damiao-proxy  ── http://localhost:8765/v1 ──┐
    │                                       │
    ├── ① CloudBase SDK (anonymous login) ──┤──▶ Hunyuan / Qwen models
    └── ② Cloud function `ai-proxy` (HTTP) ─┘    (text · image · I2I)
  • Channel ① — SDK direct call: supports streaming, function calling (FC) and reasoning_content. Preferred.
  • Channel ② — Cloud function fallback: non-streaming, compatible with older deployments.

Features

  • OpenAI-compatible — /v1/chat/completions (stream + non-stream), /v1/models, /v1/images/generations.
  • Desktop app — Electron shell with system tray, portable .exe build, port auto-release on exit.
  • React control panel — live model catalog, connectivity test, account manager, metrics & charts, image workspace, conversation history.
  • Multi-account routing — Growth-Plan token account and resource-point account side by side; per-request account selection.
  • Function calling — tools / tool_choice passthrough with an agent tool loop (maxIter).
  • Vision & resource bridge — image input routed to a vision-capable model; PDF / text files extracted and injected into the prompt.
  • Image generation — text-to-image and image-to-image, with history and local caching.
  • Encrypted local secrets — apiKey values are stored AES-256-GCM encrypted, derived from the machine fingerprint.

Quick start

Run from source

git clone https://github.com/deity6/damiao-proxy.git
cd damiao-proxy
npm install
cp config.example.json config.json     # then fill in your CloudBase envId
node server.js

Then open http://localhost:8765/ for the control panel. On Windows you can also just double-click 启动代理.bat.

Desktop app (Electron)

npm install                 # installs electron + electron-builder (devDependencies)
npm start                   # launch the desktop shell (--debug opens devtools)
npm run dist:portable       # build a portable Windows .exe into release/

Connect your agent

Field Value
Base URL http://localhost:8765/v1
API Key any string (e.g. free-ai) — not validated
Default model hy3

Works with anything that speaks the OpenAI protocol: codex, claude-code-switch, WorkBuddy custom models, openai SDK clients, and so on.

curl

curl http://localhost:8765/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer free-ai" \
  -d '{"model":"hy3","messages":[{"role":"user","content":"Say hi in one sentence"}]}'

Python

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8765/v1", api_key="free-ai")
r = client.chat.completions.create(
    model="hy3",
    messages=[{"role": "user", "content": "Say hi in one sentence"}],
)
print(r.choices[0].message.content)

Streaming

curl -N http://localhost:8765/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"hy3","stream":true,"messages":[{"role":"user","content":"Count to five"}]}'

Model catalog

GET /v1/models returns the live list. Text and image generation share the same token package.

Growth-Plan token account (default, cloud-function channel)

Type Model id Group Notes
Text hy3 hunyuan-exp Hunyuan Hy3 (295B/21B MoE, 256K ctx). 3-level deep thinking + FC. Default
Text hunyuan-free hunyuan-exp Friendly alias of hy3, same underlying model
Text hy3-preview hunyuan-exp Preview entry, auto-routed to hy3
Image HY-Image-3.0-Plus-4090-Tob-v1.0 hunyuan-image Text-to-image (default), supports aspect ratio / revise / thinking
Image HY-Image-v3.0-I2I-ToB-v1.0.1 hunyuan-image Image-to-image (reference image + prompt)
Image hunyuan-image, hunyuan-image-v3.0-v1.0.4 hunyuan-image Retired upstream on 2026-07-15 — migrate to the v3.0 Plus model

Resource-point account (gateway channel)

Type Model id Vision Thinking FC
Text hy3, hy3-preview – ✅ ✅
Text qwen3.5-flash, qwen3.5-plus ✅ flash ✗ / plus ✓ ✅
Text hunyuan-role-latest, hy-role – ✗ ✅
Text hy-mt2-lite, hy-mt2-plus, hy-mt2-pro – ✗ ✗
Image HY-Image-3.0-Plus-4090-Tob-v1.0 (T2I), HY-Image-v3.0-I2I-ToB-v1.0.1 (I2I) – – –

Image generation is always served through the cloud function (hunyuan-image group) — the gateway cloudbase group returns 403 AI_MODEL_NOT_SUPPORTED for images.

API surface

OpenAI-compatible

Method Path Description
POST /v1/chat/completions Chat completion, stream supported. Aliases: /chat/completions, /v1
GET /v1/models Live model catalog for the active account set
POST /v1/images/generations Text-to-image and image-to-image

Control panel (used by the React UI)

Method Path Description
GET /api/status Service state, port, active account, environment info
GET PUT /api/settings Read / update settings (port, defaults, bridges)
POST /api/toggle Start or stop the proxy
POST /api/test Connectivity test (text or image)
GET POST /api/accounts List / create accounts
PUT DELETE /api/accounts/:id Update / delete an account
GET /api/accounts/trash Deleted accounts awaiting restore
POST /api/accounts/:id/restore Restore a deleted account
POST /api/accounts/test · /api/accounts/probe Test or probe an account's models
GET PUT /api/changelog Changelog data
GET /api/metrics Request / success / failure / token metrics
GET POST /api/conversations Conversation list / create
GET PUT DELETE /api/conversations/:id Read / update / delete a conversation
POST /api/system/open-path · /api/system/pick-directory · /api/system/migrate-storage Filesystem helpers
GET /api/logs Recent server logs
GET /api/images/history · /api/images/:name Generated image history and files

Configuration

Copy config.example.json to config.json and fill in your own values. config.json is git-ignored — never commit it.

Key Meaning
envId CloudBase environment ID
functionName Cloud function name (default ai-proxy)
deviceId Device identifier used for anonymous login
port Local port (default 8765; auto-increments if occupied)
defaultModel / modelAlias Real default model / the alias exposed to clients
proxyEnabled Whether the proxy starts automatically
visionBridge Route image inputs to a vision-capable model (eyeModel)
resourceBridge Extract PDF / text attachments (maxFileBytes, eyeModel)
agentTools Agent tool loop: enabled, unsafeTools, maxIter
accounts Account list (type: token | resource)
routing.defaultAccount Default account id

Deploy the cloud function

The relay cloud function lives in cloudfunctions/ai-proxy.

cd cloudfunctions/ai-proxy
npm install
# set your own envId in cloudbaserc.json, then deploy with tcb / CloudBase CLI

Requirements: Nodejs 18.15 runtime, anonymous login enabled, security rule allowing anonymous invocation of ai-proxy only.

Development

# Control panel (Vite + React)
cd ui
npm install
npm run dev       # dev server
npm run build     # build to ../dist, served automatically by server.js

# Portable desktop build
npm run dist:portable

Project structure

damiao-proxy/
├── server.js            # HTTP server: OpenAI endpoints + control-panel API + account routing
├── electron-main.js     # Electron shell, tray icon, port lifecycle
├── preload.js           # Renderer bridge
├── models.js            # Data-driven model catalog (token / resource-point)
├── config.example.json  # Config template (no secrets)
├── changelog.json       # Version history (source of CHANGELOG.md)
├── 启动代理.bat          # Windows one-click launcher
├── launcher.ps1         # PowerShell launcher
├── assets/              # Icon, tray icon, splash
├── ui/                  # React control panel (Vite)
├── mcp/                 # Optional MCP server for image generation
└── cloudfunctions/
    └── ai-proxy/        # CloudBase relay function (text + image)

Privacy & security

  • Everything runs locally. No telemetry, no third-party analytics.
  • Account apiKey values are encrypted with AES-256-GCM using a machine-derived key; copied files cannot be decrypted elsewhere.
  • config.json, data/, rp-key.txt and all logs are git-ignored by default.
  • Model prompts and responses go to Tencent CloudBase — follow their terms when using Growth-Plan tokens.

Known limitations

  • hy3 relayed through the proxy may return an empty content with only reasoning_content populated — an upstream quirk, not a proxy bug.
  • hunyuan-2.0-instruct does not support function calling natively; use hy3 if you need tools.
  • Image generation returns 422 when the upstream content filter rejects a prompt — rephrase and retry.
  • The gateway (cloudbase) channel does not serve image models; images always go through the cloud function.

Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.

This is an unofficial personal project. It is not affiliated with Tencent CloudBase or Hunyuan. Use it in compliance with the platform's terms of service.

About

大妙 AI 本地代理 - Electron 桌面版,把腾讯云开发混元模型暴露为 OpenAI 兼容接口 http://localhost:8765/v1

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages