Linx is a lightweight proxy that connects local models (via Ollama or Llama.cpp) or OpenRouter models as standard OpenAI-compatible endpoints. Available in both GUI and CLI versions for flexible model management.
  • Python 91.4%
  • JavaScript 5.4%
  • CSS 3%
  • HTML 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pascal Seeber f02d214620 feat: rewrite context compression as a hybrid cascade
Replace tiered LLM summarization with shrink, line-dedup, chunk-summarize,
then head/tail-cut. Config is now strategy/timeout_seconds; summarizer 429s
pause LLM stages instead of failing the request.
2026-08-31 14:13:40 +02:00
core feat: rewrite context compression as a hybrid cascade 2026-08-31 14:13:40 +02:00
docs feat(tunnel): restart when the provider edge connection dies 2026-08-07 08:08:54 +02:00
tests feat: rewrite context compression as a hybrid cascade 2026-08-31 14:13:40 +02:00
.gitignore feat: add structured debug logging behind --debug 2026-08-20 11:21:14 +02:00
config.example.json feat: rewrite context compression as a hybrid cascade 2026-08-31 14:13:40 +02:00
license.md docs: update readme and license 2026-04-16 13:37:20 +02:00
pyproject.toml chore: release 0.3.0 2026-08-07 08:08:54 +02:00
readme.md feat: rewrite context compression as a hybrid cascade 2026-08-31 14:13:40 +02:00
run_cli.py fix: make Ctrl+C shutdown finish cleanly 2026-08-20 13:50:59 +02:00
uv.lock fix(tunnel): correct Pinggy SSH flags, auth flow and URL detection 2026-06-01 18:22:08 +02:00

Linx

OpenAI-compatible proxy for Ollama, OpenRouter, Llama.cpp, and any OpenAI-style endpoint. Works with Cursor, Continue, VS Code extensions, etc.

Setup

pip install uv
uv sync
cp config.example.json config.json   # edit keys / providers
python run_cli.py

CLI

python run_cli.py --port 8080 --tunnel
Option Default Description
--port 8080 Server port
--host 127.0.0.1 Bind address
--tunnel off Public tunnel
--api-key none Require auth
--ollama from config Override Ollama URL

Config

Copy config.example.json → config.json (gitignored).

Each entry under providers needs a driver:

driver Role
ollama Local Ollama
openrouter OpenRouter
llamacpp llama.cpp server
openai Any OpenAI-compatible API (e.g. Z.AI)

priority controls routing order. model_mappings maps aliases → provider model names.

For reasoning models, set "reasoning": true on a mapping to auto-create aliases (model-low / -medium / -high / -max). You can also set per-model reasoning_effort, think, or reasoning_budget. Clients may send the same fields on each request.

Minimal example:

{
  "providers": {
    "ollama": {
      "driver": "ollama",
      "priority": 1,
      "enabled": true,
      "endpoint": "http://localhost:11434",
      "model_mappings": { "default": "llama3" }
    },
    "zai": {
      "driver": "openai",
      "priority": 2,
      "enabled": true,
      "endpoint": "https://api.z.ai/api/coding/paas/v4",
      "api_key": "…",
      "model_mappings": { "glm5.2": { "target": "GLM-5.2" } }
    }
  }
}

Tunnel

Set tunnel.type in config.json (or pass --tunnel):

Type Notes
cloudflare Needs cloudflared. Most stable.
pinggy Free SSH tunnel. ~60 min without token.

Context compression

Optional. When message tokens exceed trigger_tokens, older tool results and turns are densified before the request goes upstream. Recent turns stay untouched. If the result is still over the provider context limit, oldest messages are dropped.

strategy chooses the cascade:

  • truncate — head/tail cut, no extra model call
  • llm — chunk-summarize old blobs (last keep_last_n_turns stay raw); no extra cut
  • hybrid — chunk-summarize, then head/tail-cut whatever is still over trigger_tokens

If the result is still over the provider context limit, oldest messages are dropped.

Option Meaning
strategy truncate, llm, or hybrid
trigger_tokens Start compression above this
keep_last_n_turns Recent turns never compressed
provider / model Summarizer (llm / hybrid only)
timeout_seconds Budget for the summarizer batch (llm / hybrid only)

Routing

  1. Client asks for a model name (e.g. glm5.2)
  2. Linx checks each provider’s model_mappings by priority
  3. First match wins; fallback to the next provider if enabled

API

Method Path
GET /v1/models
POST /v1/chat/completions
GET /v1/providers/status
GET /api/tunnel/status
GET /api/tags

Tool calls (tools, tool_choice, parallel_tool_calls) are forwarded as-is. The model must support function calling.

Changelog

v0.3.0

  • Add reasoning controls: reasoning_effort, think, and reasoning_budget
  • Auto-create model aliases like glm5.2-high when a mapping has "reasoning": true
  • Set default effort per model in config; request values override them
  • Skip effort for models that do not support reasoning (request still works)
  • Remove unused thinking_mode flag
  • Restart tunnels when the provider edge dies, not only when the process exits

v0.2.2

  • Providers configured via explicit driver field
  • Context compression: older turns summarized harder, recent ones kept; cancel on disconnect
  • Preserve tool_call ids; truncate tool pairs together
  • No 429 retries (surface immediately)
  • Tunnel: drain stdout, soft-accept URL if verify/DNS flakes

v0.2.1

  • Pinggy tunnel; removed ngrok

v0.2.0

  • Cloudflare + localhost.run tunnels
  • Custom OpenAI-compatible providers
  • Tool use / agent support
  • Context compression

License

MIT — license.md