Skip to content
المشاريع

حول

Open-source LLM router and gateway: any OpenAI-compatible model in any coding agent or app that speaks the OpenAI or Anthropic API. Format translation, tool-call repair, fallback.

أدوات التطوير

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
جارٍ جمع السجل
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

Voight Router: any coding agent or app on any OpenAI-compatible model

Voight Router

CI npm License OpenSSF Scorecard

Guides · npm · Hosted version · Changelog

Coding agents and AI apps are tied to one API format, and open models often break their tool calls. Voight Router sits in between, so any agent or app that speaks the OpenAI or Anthropic API can use any OpenAI-compatible model: a hosted provider, or your own vLLM, llama.cpp, Ollama or LM Studio.

  • Format translation, both ways. Anthropic Messages or the OpenAI Responses API in, OpenAI Chat Completions to the model, the caller's format out. Streaming, tool calls, images and tool errors included.
  • Tool call repair. Broken tool-call arguments from open models are fixed before they reach the agent: JSON syntax, and values that do not match the tool's schema.
  • OpenRouter compatible. Fallback models, provider preferences, usage and reasoning options, and the /api/v1 paths, so OpenRouter code switches by changing the base URL.
  • Fallback. List several upstreams; if one fails before answering, the next one takes the call. Answers are never spliced across upstreams.
  • Runs anywhere. With npx, a container image or a single-file binary, or as a library in your own gateway. Zero runtime dependencies, about 60 kB packed.
  • Nothing stored. Prompts and answers only pass through memory. Logs hold method, path, upstream, status and time.

Works with

Each agent below was run end to end through the router: editing files, running commands and fixing code until its tests passed. Every guide names the version it was tested with.

Agent Format it speaks Guide
Aider OpenAI Chat Completions aider.md
Claude Code Anthropic Messages, translated claude-code.md
Cline OpenAI Chat Completions cline.md
Codex CLI OpenAI Responses, translated codex.md
Continue OpenAI Chat Completions continue.md
Crush OpenAI Chat Completions crush.md
Goose OpenAI Chat Completions goose.md
Kilo Code OpenAI Chat Completions kilo-code.md
Oh My Pi OpenAI Chat Completions oh-my-pi.md
OpenCode OpenAI Chat Completions opencode.md
Pi OpenAI Chat Completions pi.md
Roo Code OpenAI Chat Completions roo-code.md

Your own app works the same way: point any OpenAI or Anthropic SDK, or plain HTTP, at the router.

Quick start

Start the router in front of your provider. Keys are read from environment variables, never from arguments.

export PROVIDER_API_KEY=...
npx @voightxyz/router \
  --upstream https://api.your-provider.com/v1 \
  --api-key-env PROVIDER_API_KEY \
  --model your-model-id

Then point any agent or app at it: http://127.0.0.1:4000/v1 for OpenAI clients, http://127.0.0.1:4000 for Anthropic ones. For example:

curl http://127.0.0.1:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "your-model-id", "messages": [{"role": "user", "content": "Hello"}]}'

With --model set, every request goes to that model, whatever model name the client sends (some agents also make background calls with their own model names). For each coding agent, follow its guide.

A local model works the same way, for example Ollama:

npx @voightxyz/router --upstream http://127.0.0.1:11434/v1 --model qwen3:32b

Without Node

Container image (Linux, amd64 and arm64). Inside the container the router listens on all interfaces:

docker run --rm -p 4000:4000 -e PROVIDER_API_KEY \
  ghcr.io/voightxyz/router \
  --upstream https://api.your-provider.com/v1 \
  --api-key-env PROVIDER_API_KEY \
  --model your-model-id

Single-file binary for Linux (x64, arm64), macOS (Apple Silicon, Intel) and Windows (x64), attached to every release with SHA256SUMS. The binaries are not signed by Apple or Microsoft, so the first run shows a warning. On macOS, after checking the checksum:

tar -xzf voight-router-macos-arm64.tar.gz
xattr -d com.apple.quarantine voight-router-macos-arm64
./voight-router-macos-arm64 --upstream http://127.0.0.1:11434/v1 --model qwen3:32b

Each release also carries an SBOM (voight-router-sbom.cdx.json) and build provenance for the binaries and the image, which you can verify with gh attestation verify <file> --repo Voightxyz/router. From 0.1.4 each binary's provenance is also attached next to it as <file>.intoto.jsonl, for offline checks with --bundle.

Check a model first

voight-check (Python, pip install voight-check) tells you whether a model behind any OpenAI-compatible endpoint, the router included, is ready for coding agents: valid tool calls, tool results, tool calls in streams, JSON, long context and prompt caching.

Configuration

Fallback

Repeat the upstream group. Order is priority:

npx @voightxyz/router \
  --upstream https://api.provider-a.com/v1 --api-key-env KEY_A --model model-a \
  --upstream http://127.0.0.1:8000/v1 --model model-b

The next upstream is tried when the current one is unreachable or answers 404, 408, 409, 429 or 5xx. A 400 is returned as is, since it would fail the same way anywhere.

Options

Option Default
--upstream <url> Base URL of an OpenAI-compatible API (repeat for fallback)
--api-key-env <NAME> Environment variable with the key for the upstream before it
--model <id> client's model Model id sent to the upstream before it
--name <label> upstream host Name of the upstream before it, for logs and provider preferences
--port <n> 4000
--host <addr> 127.0.0.1
--auth-token-env <NAME> Require clients to send this token (x-api-key or Authorization: Bearer)
--timeout <seconds> 600 Deadline for one call
--tool-repair <mode> translated Where broken tool-call arguments are repaired: translated, all or off. See Tool call repair
--cache-control <mode> drop keep passes Anthropic cache_control markers on as {"type": "ephemeral"} on the OpenAI text parts, for upstreams that read them (Alibaba Model Studio, for example). Leave it at drop for upstreams that do not

A single upstream can also come from VOIGHT_ROUTER_UPSTREAM, VOIGHT_ROUTER_API_KEY and VOIGHT_ROUTER_MODEL.

Endpoints

Route Format
POST /v1/messages Anthropic Messages (Claude Code, Anthropic SDKs), translated
POST /v1/responses OpenAI Responses API (Codex CLI, responses.create in the OpenAI SDKs), translated
POST /v1/chat/completions OpenAI Chat Completions, with the OpenRouter extras below
GET /v1/models The configured models
GET /health

Every /v1/... route also answers on /api/v1/..., the path OpenRouter clients use.

OpenRouter request shape

Code written for OpenRouter works by changing only the base URL (http://127.0.0.1:4000/api/v1) and the key. The extras are taken out of the body, so upstreams only ever receive plain OpenAI requests:

Field What the router does
models: [...] Fallback models, tried in order after model when one fails before answering (when the upstreams do not force a model with --model)
provider.order, only, ignore, allow_fallbacks Applied to your upstreams, matched by --name
usage: { include: true } Usage in the answer, streams included
reasoning: { effort } Sent as OpenAI reasoning_effort
reasoning: { exclude: true } Reasoning removed from the answer
route, transforms, plugins Dropped
provider.max_price, data_collection, zdr Accepted, not enforced: the open gateway knows nothing about your upstreams' prices or data policies

Format translation

Anthropic Messages and OpenAI Responses requests are translated to Chat Completions for the model, and the answer goes back in the caller's format, streaming included. Tool calls are sent whole, so their JSON stays valid even when the upstream splits them. A stream that stops mid-answer ends with an error event, never with a fake end.

The field-by-field tables are in docs/translation.md. The translation layer runs in production in the hosted Voight Router and was tested with real sessions of Claude Code and Codex CLI.

Tool call repair

Open models sometimes send tool-call arguments that are not valid JSON, or that are valid but do not match the tool's schema. Without repair, the agent gets a failed tool call and the model has to write it again. The router fixes what it can before the answer reaches the agent.

JSON syntax: trailing or missing commas, raw line breaks and stray quotes inside strings (common when the model writes code into a file), single quotes, unquoted keys, True/None, comments, a code fence or text around the object, and closing brackets left out.

Values, against the tool's schema: "true" where a boolean is expected, "5" where a number is, a number where a string is, and arrays or objects sent as a JSON string, such as a todos list.

What it never does:

  • Repair an answer cut by the token limit. Finishing a half-written call would be a guess, so the agent sees that the model ran out of tokens.
  • Add, rename or remove a field, or touch a value whose schema uses anyOf, oneOf, allOf, not or $ref.
  • Keep a guess it cannot check. Reading a quote inside a string as part of the text, or adding a missing comma, is only kept when every field of the result is one the tool's schema declares. Otherwise, and whenever it cannot repair, the call stays as before: {} on the translated routes, and the model's own text on /v1/chat/completions.
  • Convert a number that would lose digits, such as a long id.
--tool-repair Where
translated (default) Answers translated for Claude Code, Codex and other Anthropic or Responses clients. Tool calls already arrive whole there, so streaming does not change.
all Also /v1/chat/completions. Streamed tool calls are then held back and sent whole, repaired, at the end of the answer, instead of as they are written.
off Nowhere.

Each repaired call adds repaired=N to the router's log line for that request. The content is never logged.

Use it as a library

import { anthropicToOpenAI, openAIToAnthropic, createAnthropicStream } from '@voightxyz/router'

const translated = anthropicToOpenAI(anthropicRequestBody)
if (!translated.ok) throw new Error(translated.message)
// send translated.body to any OpenAI-compatible API, then:
const message = openAIToAnthropic(openAIResponseJson, 'model-id')

// streaming: feed the upstream's SSE text, forward what comes out
const stream = createAnthropicStream({ publicModel: 'model-id' })
// stream.push(chunk) for each chunk, then stream.flush() + stream.end(failed)

The Responses API works the same way with responsesToOpenAI, openAIToResponses and createResponsesStream; pass the context the request translation returns to the answer builders.

The answer builders repair broken tool-call arguments by default; pass repair: { schemas, onRepair } (built with toolSchemas(body.tools)) to add the schema fixes and count repairs, or repair: { enabled: false } to turn it off. repairToolArguments(args, schema) repairs one call's arguments on its own.

Or mount the whole gateway in your own Node server:

import http from 'node:http'
import { createRouterHandler } from '@voightxyz/router'

http.createServer(createRouterHandler({ upstreams: [{ baseUrl: 'https://api.example.com/v1', apiKey: process.env.KEY, model: 'model-id' }] })).listen(4000)

Security

  • Binds to 127.0.0.1 by default. If you bind it elsewhere, set --auth-token-env; otherwise anyone who reaches it spends your keys.
  • Upstream keys come only from environment variables, so they stay out of shell history.
  • The upstream refusing the router's key is reported as a 502, never as the caller's authentication error.

To report a vulnerability, see SECURITY.md.

Known limits

  • PDF and file documents are not supported yet.
  • Nothing is stored, so previous_response_id is refused: send the whole conversation each time, as Codex does.
  • /v1/messages/count_tokens is not implemented.
  • Tool calls a model writes as plain text (for example <tool_call>{...}</tool_call> when its server does not parse them) are not turned into calls. Configure the model server's tool parser instead.
  • Claude Code assumes a Claude-sized context window. On a model with a smaller one, run /compact or start a new session before you reach the model's limit.

Roadmap

  • Prompt caching.
  • More tested agent guides.

Hosted version

Voight Router runs this same engine behind a single Voight key: one prepaid balance for many models, no provider accounts to manage, and every call visible in Voight Observability. Join the waitlist at voight.xyz/router.

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md for the setup, the tests and how to add a tested guide for another agent.

License

Apache 2.0

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…