logo
7
2
WeChat Login

ModelBridge

中文文档 | Configuration reference

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. See CONFIG.md for the full environment-variable reference, supported target protocols, model-list routes and conversion notes.

Quick Start

Install:

curl -fsSL https://cdn.bring.cool/cnb/Bring/Project/Series/ModelBridge@main/install.sh | sh

Windows PowerShell:

irm https://cdn.bring.cool/cnb/Bring/Project/Series/ModelBridge@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.

Health check:

curl http://localhost:8080/healthz

Inbound Routes

ProtocolRoute
OpenAI ChatPOST /v1/chat/completions
OpenAI ResponsesPOST /v1/responses
Claude MessagesPOST /v1/messages
GeminiPOST /v1beta/models/{model}:generateContent
Gemini streamPOST /v1beta/models/{model}:streamGenerateContent
Ollama ChatPOST /api/chat

Model-list routes (GET /v1/models, GET /v1beta/models, GET /api/tags) 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

About

基于 Go/Gin 的 LLM API 协议转换代理。同时暴露 OpenAI Chat、OpenAI Responses、Claude Messages、Gemini、Ollama 五种协议入口,通过共享 IR 星型架构实现任意协议互转,转发到单一上游。支持 SSE 流式、工具调用、多模态图片,可作为独立服务或 Go 库使用。

5.12 MiB
7 forks2 stars1 branches34 TagREADMEApache-2.0 license
Language
Go97.1%
Shell2%
Dockerfile0.1%
Lua0%
Others0.8%