Skip to content
ThinkWatch
Start typing to search the docs.
ThinkWatch Core · Overview

ThinkWatch Core#

ThinkWatch Core is the gateway engine of the ThinkWatch products: a set of MIT-licensed Rust crates and twcore, a self-contained AI API gateway binary. twcore is the gateway inside the desktop app, ThinkWatch Lite, and also runs on its own as a systemd service on a Linux server. ThinkWatch Enterprise depends on four of the crates: tw-dialect, tw-guard, tw-breaker and tw-bedrock.

Scope of Core#

Core is a set of crates and one binary, not a desktop application. On a desktop, twcore comes with ThinkWatch Lite and is not installed separately. On a server, a single command installs it as a service, and ThinkWatch Lite on macOS, Windows or Linux connects to it; see Server deployment. Quick start with twcore covers the prebuilt binaries, building from source and a first configuration.

A change in Core reaches every product that uses it, so each change follows the rules in Development and tests.

What it does#

Clients such as Claude Code and Codex send their requests to the gateway, and Core provides the following:

  • Rule-based routing. Rules match on the model, the gateway key, the input size, the presence of tools or images and other properties of a request, and send it to an upstream or a group, rewrite its parameters or refuse it. When the client and the upstream use different API formats, the request is converted between Anthropic Messages, OpenAI Chat Completions, OpenAI Responses and Gemini.
  • Failover before the first byte. Until the first byte reaches the client, a failing upstream is replaced by the next one without the client noticing. After that point, the failure is reported. A circuit breaker keeps requests away from an upstream that keeps failing.
  • Cost accounting. Token usage and cache hits are priced from a public price table, which the control plane refreshes daily, or from a price sheet in the configuration. Each request records its cost and where the price came from. Estimated amounts are marked as such, and usage that cannot be priced is labelled unknown rather than given an invented figure.
  • Outbound redaction. Credentials and personal information anywhere in a request are replaced with placeholders before the request leaves, and restored when the model echoes them back.
  • Tool-call inspection. Tool calls returned by an upstream are checked against a rule set, and a dangerous call can be cut off mid-stream.
  • Content filter. The user messages and tool results a client sends are checked by keyword, regular expression or code point, and each rule refuses the request, deletes what it matched or only records it; the built-in rules also catch hidden characters that can carry instructions. Each of the three guards is set to off, observe or enforce, and all start in observe.
  • An encrypted control plane. The desktop app and twcore commands reach core over a local socket (a loopback port on Windows) and, when it is enabled, a remote control port. Every control connection starts with a Noise handshake keyed by listen.control.key; there are no certificates.

Further reading#

License#

ThinkWatch Core is licensed under the MIT License. The source code is available on GitHub.

Last updated 2026-10-03 Edit on GitHub