跳到正文
DEV Community· OpenCode Bridge·· 8 小時前AI 評分52

OpenCode Bridge 為 OpenCode 模型提供本機 OpenAI 相容 API 和聊天介面

OpenCode Bridge: a local OpenAI-compatible API and chat for OpenCode models

AI 導讀

OpenCode Bridge 是一款本機應用程式,透過 OpenAI 相容 HTTP API 提供 OpenCode 可用模型,並附有瀏覽器聊天介面和 Windows EXE 啟動器。

正文

OpenCode Bridge

What is it?

OpenCode Bridge is a small local application that exposes the models available in OpenCode through an OpenAI-compatible HTTP API. It also ships a browser chat UI, a Windows EXE launcher and a multilingual interface (Russian, English, Chinese, Korean).

The idea is simple: if a program can talk to the OpenAI API, it can talk to OpenCode models. No cloud proxy, no API key for the models themselves — just a server on 127.0.0.1:8080.

Features

  • GET /v1/models, POST /v1/chat/completions, POST /v1/completions.
  • Real SSE streaming via OpenCode's session.text.delta events — chunks arrive while the model is still generating.
  • A web chat with conversation history, streaming output, a system prompt field and a language switcher.
  • Four UI languages: Russian, English, Chinese and Korean. The model is instructed to answer in the user's language.
  • Optional API key authentication and CORS restricted to local origins.
  • A workaround for the daily free-model limit: clean forks of an already admitted session inherit the right to generate.
  • A Windows EXE that starts the server, opens the browser and lives in the tray.

Quick start

  1. Install Node.js 18+ and OpenCode v2.
  2. Run opencode service start.
  3. Double-click OpenCode Bridge.exe (or run node src/server.js).
  4. Open http://127.0.0.1:8080/ or point another app to http://127.0.0.1:8080/v1.

Example request:

curl http://127.0.0.1:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"opencode/hy4-flash-free","messages":[{"role":"user","content":"Hello!"}]}'

Using it from other programs

  • Base URL: http://127.0.0.1:8080/v1
  • API Key: any string, e.g. dummy (when no key is configured)
  • Model: e.g. opencode/hy4-flash-free

This works with Cursor, Continue, Open WebUI, LibreChat, LangChain, the Python openai package and similar clients.

Multilingual summary

  • RU: Локальный мост к моделям OpenCode: веб-чат, OpenAI-совместимый API, четыре языка интерфейса и EXE-запускальщик.
  • ZH: OpenCode 模型的本地桥接:网页聊天、OpenAI 兼容 API、四种界面语言与 EXE 启动器。
  • KO: OpenCode 모델용 로컬 브리지: 웹 채팅, OpenAI 호환 API, 4개 언어 인터페이스와 EXE 실행 프로그램.

Links

Caveats

Free OpenCode models have a daily quota; the bridge works around it but cannot create new quota. temperature/top_p are ignored, and max_tokens/stop are applied as post-processing. In fork mode, tool permissions cannot be hard-disabled — keep the server on localhost and set an API key if needed.

Feedback and contributions are welcome!

來源:DEV Community · dev.to