ModelBridge
中文文档 | 配置参考
ModelBridge is a Gin-based LLM API protocol bridge. It accepts requests in the
OpenAI Chat, OpenAI Responses, Anthropic Messages, Gemini, or Ollama Chat
schemas, converts them through a shared internal representation, and forwards
them to one configured upstream.
Quick Start
Install:
curl -fsSL https://cnb.cool/Bring/Project/Series/ModelBridge/-/git/raw/main/install.sh | sh
Windows PowerShell:
irm https://cnb.cool/Bring/Project/Series/ModelBridge/-/git/raw/main/install.ps1 | iex
Run against an OpenAI-compatible upstream:
TARGET_PROTOCOL=openai-chat \
TARGET_BASE_URL=https://api.openai.com/v1 \
TARGET_TOKEN="$OPENAI_API_KEY" \
go run ./cmd/server
TARGET_TOKEN may be empty for local or unauthenticated upstreams, or when
client authentication should pass through to the upstream. See CONFIG.md
for the full environment-variable reference.
Health check:
curl http://localhost:8080/healthz
Supported Protocols
Inbound routes:
| Protocol |
Route |
| OpenAI Chat |
POST /v1/chat/completions |
| OpenAI Responses |
POST /v1/responses |
| Claude Messages |
POST /v1/messages |
| Gemini |
POST /v1beta/models/{model}:generateContent |
| Gemini stream |
POST /v1beta/models/{model}:streamGenerateContent |
| Ollama Chat |
POST /api/chat |
| OpenAI model list |
GET /v1/models |
| Claude model list |
GET /v1/models with anthropic-version, or ?format=claude |
| Gemini model list |
GET /v1beta/models |
| Ollama model list |
GET /api/tags |
Target protocols:
openai-chat
openai-responses
claude
gemini
ollama
Examples
OpenAI Chat inbound:
curl http://localhost:8080/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4.1-mini",
"messages": [{"role": "user", "content": "hello"}]
}'
Streaming:
curl -N http://localhost:8080/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4.1-mini",
"stream": true,
"messages": [{"role": "user", "content": "stream a short answer"}]
}'
Model list:
curl http://localhost:8080/v1/models
ModelBridge fetches models from the configured target and writes the response in
the inbound client protocol's schema. More model-list options are documented in
CONFIG.md.
Docker
docker run --rm -p 8080:8080 \
-e TARGET_PROTOCOL=openai-chat \
-e TARGET_BASE_URL=https://api.openai.com/v1 \
-e TARGET_TOKEN="$OPENAI_API_KEY" \
docker.cnb.cool/bring/project/series/modelbridge:latest
Development
go test ./...
go test -coverprofile=coverage.out -covermode=atomic ./...
Smoke and benchmark workflows are documented in
docs/verification.md.
License
Licensed under the Apache License 2.0.
Copyright 2026 leun