This is a small local Kimi-K3 gateway for an authorized campus AI service. It translates the campus streaming endpoint into the Anthropic Messages shape used by Kimi Code and keeps the campus specific transport behind a separate client module.
git clone https://github.com/OwenxuSH/shanghaitech-kimi-gateway.git
cd shanghaitech-kimi-gateway
./scripts/install_macos.shThe installer creates a local virtual environment, installs the gateway and passkey helper, opens the ShanghaiTech IDS browser flow when no keystore exists, creates a local API key, and registers a launchd service on port 5000. It does not upload credentials.
For automatic renewal, the first setup must create a local IDS passkey keystore. The gateway keeps a short-lived token cache beside that file, refreshes it before expiry, and retries one upstream request after an authentication rejection. The keystore and cache are local credentials and are ignored by Git.
The service listens on http://127.0.0.1:5000 by default. Never commit tokens, cookies, keystores, or .env files.
GET /healthGET /v1/modelsPOST /v1/messages
Tool requests are translated to the Kimi transport envelopes <k3_action> and <k3_final>. The gateway validates the tool name and JSON arguments before returning Anthropic tool_use blocks. Tool results are sent back as a completed action record on the next request.
Add a provider in ~/.kimi-code/config.toml:
[providers.campus-kimi]
type = "anthropic"
base_url = "http://127.0.0.1:5000"
api_key = "replace-with-CAMPUS_AI_API_KEY"
[models."campus/kimi-k3"]
provider = "campus-kimi"
model = "Kimi-k3"
max_context_size = 150000
[loop_control]
reserved_context_size = 30000Replace the placeholder api_key with the value printed by the installer, then select campus/kimi-k3 in Kimi Code. The installer leaves the existing Kimi Code configuration untouched.
export CAMPUS_AI_KEYSTORE="$HOME/.config/campus-ai/ids.keystore"
export CAMPUS_AI_API_KEY="your-local-key"
campus-ai-gatewayThe upstream service is available only from an authorized network. This project does not bypass campus access controls.