- Python 91.4%
- JavaScript 5.4%
- CSS 3%
- HTML 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
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. |
||
| core | ||
| docs | ||
| tests | ||
| .gitignore | ||
| config.example.json | ||
| license.md | ||
| pyproject.toml | ||
| readme.md | ||
| run_cli.py | ||
| uv.lock | ||
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 callllm— chunk-summarize old blobs (lastkeep_last_n_turnsstay raw); no extra cuthybrid— chunk-summarize, then head/tail-cut whatever is still overtrigger_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
- Client asks for a model name (e.g.
glm5.2) - Linx checks each provider’s
model_mappingsbypriority - 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, andreasoning_budget - Auto-create model aliases like
glm5.2-highwhen 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_modeflag - Restart tunnels when the provider edge dies, not only when the process exits
v0.2.2
- Providers configured via explicit
driverfield - 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