A thinking model spends a small max_tokens on reasoning and returns empty
content with finish_reason length. TensorFold on the d1 DeepSeek server
warns about this and suggests chat_template_kwargs enable_thinking false.
providers.<name>.thinking.offBelowMaxTokens (openai type, default off)
adds chat_template_kwargs: {"enable_thinking": false} to the upstream
body when a chat request caps its output under the value. It also does
this when /v1/messages translates a request for that provider. A request
with no cap, a cap at or above the value, or its own thinking choice
(reasoning_effort, reasoning, thinking, enable_thinking, or
chat_template_kwargs.enable_thinking or .thinking) is not changed. Other
client chat_template_kwargs keys are kept, and the client's map is not
modified. The response cache still keys on the client body.
An OpenAI-compatible stream that ended with neither a finish_reason nor
[DONE] counted as a finished answer. When the d1 model server died
mid-reply, the gateway sent the client an empty stream with no
finish_reason, and the smart router did not try its next tier.
forwardStream now returns errStreamTruncated for such a stream, wrapped
in errUpstream. Before any output reaches the client, the request fails
over or escalates to the next tier. After output, the client gets an
error event and no [DONE]. A stream with [DONE] but no finish_reason
keeps its old behaviour.
The passthrough proxy wrote the status line but flushed only on the first
body write. An MCP server-to-client stream (GET with text/event-stream)
can stay silent for a long time, so the client did not get the response
headers. Traefik in front of the standalone gateway waited for its 20m
responseHeaderTimeout and then returned 504.
The proxy now flushes the headers at once when the upstream answers with
text/event-stream.
The OpenAI SDKs refuse to start without an API key, so keyless callers
set a placeholder key. With users.anonymousGroup alone, that placeholder
gets 401.
Set users.anonymousAcceptAnyKey to true to serve a key that matches no
user as "anonymous". A configured user's key still resolves to that
user. A placeholder key does not count toward the auth-failure
throttle. The admin API and the metrics key fallback still use
identifyKeyed, so they still need a valid key. The option is false by
default, and it needs users.anonymousGroup.
TestPacing_ConcurrentPacedRequestsCappedPerUser counted every paced
request, but the gate caps only the requests that wait at the same time.
The delays were 4 to 44 ms, so with one CPU early requests finished and
freed their slots, and a fifth request was paced correctly. The test now
gives each request a delay of at least 3 s, waits until the gate holds
maxConcurrentPaced requests, and checks that two more requests return at
once without the paced header.
TestCacheHit_BodyParseSkippedWhenStatsAdminOff compared the CPU time of
a cache hit with admin on and off. The parse is a small part of a hit,
so the ratio fell below the 1.33 threshold on every run without -race.
A nil-by-default Gateway field now lets the test count the parses: a hit
with admin on parses the body, and a hit with admin off does not.
A request with "stream": true on POST /v1/messages now gets the
Anthropic Messages event stream instead of a 400. Claude Code streams
every call, so the route must stream before it can front an
OpenAI-compatible cluster.
For openai and gemini providers, the gateway asks the upstream for a
stream with include_usage and translates each chunk as it arrives. It
emits message_start, one content block group per text or tool_use
block, then message_delta and message_stop. Tool call arguments arrive
as input_json_delta. The stop reason uses the non-streaming mapping.
For anthropic providers, the gateway relays each upstream event and
rewrites only message.model in message_start. An upstream error event
reaches the client once, as sent.
Billing uses the stream usage. An error before the stream starts gets
the normal JSON error. An error after the start ends the stream with an
error event. Streams are never cached. yaegi-check now drives a
streamed request under the interpreter.
Set users.anonymousGroup to a configured group to serve requests that
carry no credential as the reserved user "anonymous" in that group. The
group grant applies, and the group memberLimits are the per-user limits
that all keyless callers share.
A request that sends an Authorization or x-api-key header must carry a
valid key, so a wrong or malformed credential still gets 401. The admin
API and the metrics key fallback use identifyKeyed and never admit the
anonymous user. The name "anonymous" is reserved while the option is
set. The option is empty by default, and then every route needs a key as
before.
The .traefik.yml testData now enables anonymous access, and yaegi-check
exercises it under the interpreter.
MCP GET event streams (the server-to-client channel) now run without the progress watchdog and are ended by the client, the upstream or Gateway.DrainIdleStreams.
The standalone binary drains them on shutdown and when a config reload retires a gateway, so they do not hold either open.
examples/standalone is a kustomization for the compiled gateway with restart draining, a configMapGenerator config, placeholder Secrets and an optional Traefik route.
TestHandleChat_RequestLimitExceeded_BodyNeverRead now pins the limiter clock and uses an unreachable local upstream, so it no longer flakes at a minute boundary or calls api.openai.com.
The standalone binary reloads its config file on change and on SIGHUP, and keeps the old gateway for running requests.
GoReleaser publishes the standalone binaries and a signed multi-arch image to ghcr.io/lukaszraczylo/traefik-llmgateway.
The plugin form does not change.
This change adds the redesigned admin panel and the smart router decision model assist.
It adds opt-in prompt-prefix caching per provider and cached-token pricing and metrics.
With Redis, the metrics route reports fleet-wide values. The redis.sharedState switch shares six coordination states across replicas.
PR CI grants actions read, which the shared go-pr workflow needs.
The pull request description has the full list and the verification.
Add smart routers: virtual models that score each request and route it to admin-defined model tiers. A retryable failure moves the request to a higher tier. The classifier v2 extracts prose, finds the original ask in long tool loops, adds an uncertainty margin and reads tool-output failures. Sessions, outcome signals, bounded calibration, adaptive selection within a tier, gated saturation downgrade, a first-byte timeout and an opt-in timeout fallback are included. Every new feature is off by default.
Add per-member group limits, a tokensPerMinute window that counts uncached input and output, rate-limit headers in three dialects, soft pacing before the hard limit, and a limitExemptKinds list so embedding and reranking traffic never counts toward or hits a limit.
Fix yaegi named-result state that made smartContentSize grow between calls.
The provider accordion reads the overview response, not the catalog, so
the earlier change never reached it. Add kinds and endpoints to the
overview provider view and group the accordion rows by kind. Endpoint ids
now read gx10/v1/decide, without a doubled slash.
Add a display-only kinds map to the provider config. Each pathBaseUrls key
now appears in the admin catalog as an endpoint row. The Models page splits
a provider into one sub-section per kind.
The error-rate axis rounded half-percent ticks up, so labels repeated (4%, 4%, 3%, 3%). Ticks now show one decimal where needed. The CSS layer test imported node:fs, which broke npm run build under vue-tsc, so it is removed.
The per-user detail cache grew without limit and now keeps the 20 most recently fetched users. Spend refresh built the breakdown from a stale ranking after the ranking failed or was superseded, and now skips that step. The FontAwesome stylesheet overrode Tailwind hidden and showed two accordion chevrons, so it now loads in a low cascade layer.
A new API key kept the previous key's data on screen until each store refreshed. All data stores now reset when the key changes. The Spend breakdown chart showed a column of identical zero ticks for an empty range, so it now shows an empty message. A stray quote in the Reliability page markup is removed.
CSV export prefixed negative numbers with an apostrophe, which corrupted the data. YAML emitted NaN and Infinity as plain strings. Context windows such as 1500 read as 2k. Numbers now skip the CSV formula guard, non-finite values use YAML float forms, and counts below 10k keep one decimal.
The burn-down chart drew the budget line even when it was more than ten times the spend, which flattened the spend curve. The line now hides with a note. Limits, pricing, model metadata and grant forms mark invalid inputs with aria-invalid and aria-describedby.
The table had 11 columns and scrolled at 1280px, hiding p50, p95 and error rate. It now shows compact price, one token column and a short error header. Context window stays in the model chip hover, and the :free flag moves into the price cell.
FontAwesome injected a style element at runtime. The admin CSP blocks that and logged a console error on every load. The UI now imports the stylesheet and disables auto injection.
Label configured model aliases with an alias badge wherever a model id shows.
List only providers with traffic in the window in provider chart legends.
Page long tables, show a scroll shadow on wide ones and drop the duplicate model link.
Show costs with thousands separators and magnitude-scaled decimals on cards and chart axes.
Use whole-number ticks for count charts and replace all-zero charts with a message.
Back off polling after failures.
Keep the CSV status region from widening the page on phones.
Regenerate admin_assets_gen.go.
Fetch the consumers list on the user detail page so admin and grant data show on a deep link.
Gate Recent errors, the Spend total and the forecast card on load state instead of showing zeros.
Show a stale notice on top lists when a refresh fails.
Clear the target name when the target kind changes.
Ignore out-of-order config responses.
Wrap long group names and event messages, and announce projected budget overruns to screen readers.
Regenerate admin_assets_gen.go.
Show a persistent notice when a refresh fails while old data is on screen.
Add retry to the Targets and Access Matrix error states.
Give tables names, skeletons a status role and CSV export a live region.
Abort admin requests after 15 seconds and share concurrent identical GETs.
Show a reload prompt when a lazy page chunk fails to load.
Ignore prototype keys in the location hash.
Stop formatContextWindow emitting 1000k, round latency before the 1s cutoff,
and treat NaN as not enough data in the month projection.
Regenerate admin_assets_gen.go.
The README claimed an at-most-one-request overshoot. Requests in flight
together all pass the pre-check, so the bound is concurrency times the
largest request cost.
time.After keeps its timer alive until it fires on go 1.22 semantics,
so each cancelled retry wait pinned a timer for up to 2s. A stoppable
timer releases it at once.
A secret field added under a new JSON key would pass through the config
endpoint unredacted because the redactor matches keys by name. The test
fails until each string key is redacted or declared non-secret.
Go leaves a float to int64 conversion implementation-defined when the value is out of range, so a huge max_tokens could become a negative number on some architectures. The conversion now saturates to the int64 range and refuses NaN.
The parser allocated the full declared bulk length before any payload arrived, so a stalled peer could pin 64 MiB per connection. The buffer now starts at 64 KiB and doubles only after the previous capacity has fully arrived. A test measures the allocation.
The loader read the whole users file into memory on the request path, whatever its size. The loader now reads at most the cap plus one byte and refuses a larger file. The last good user set stays active.
A panic inside the response copy skipped the caller's release, so the tee kept its reserved bytes in the shared budget for good. The proxy now releases the tee and keeps unwinding. A test reproduces the leak.
A successful but empty discovery answer replaced the known model set with nothing, so a flapping upstream made every discovered model return 404 until the next refresh. The registry now treats that answer as a failure. It keeps the previous set and counts the failure toward the discovery breaker.
The reserve step added first and checked after. Concurrent reservations saw a transient overshoot and were denied while room remained. The step now claims bytes only when they fit, so used never exceeds the limit.
An upstream could send millions of empty data lines in one event. The cap counted one byte per line, but each line kept a 16-byte string header in memory. The cap now counts the header too, so retained memory stays within the cap.
A zero or negative backoff passed validation and made retries fire with no pause. The config loader now rejects it. The wait ladder compares the backoff to the cap before it multiplies, so a very large backoff cannot overflow.
The adapter client re-sent provider API key headers to any redirect target. The client now returns the 3xx response to the caller. A test pins this behaviour.
Embeddings responses are large and rarely repeat. Each one was stored
for the cache TTL in the shared Redis. A burst of them raised memory
on the shared Dragonfly to its limit.
The cache now skips /v1/embeddings unless cache.cacheEmbeddings is
true. The default is false. Chat caching does not change.
The gateway now sends the concurrency limit as a RateLimit-Policy
field from draft-ietf-httpapi-ratelimit-headers. The value is
"concurrency";q=<n>;qu="concurrent-requests". The invented
X-Concurrency-Limit header is gone.
The new concurrencyAutodetect option is off by default. When on,
the gateway learns a limit for each configured provider. A 429, 503,
504 or upstream timeout sets the limit to half the in-flight
requests, with a minimum of 1. Four consecutive successes add 1.
At 64 the limit counts as unknown again.
Responses served via a provider advertise the smaller of
maxConcurrency and the learned value. An explicit maxConcurrency
always wins. Routing, retry and failover do not change.
Self-hosted upstreams serve few requests at once. A client that opens
many requests overloads them.
The new maxConcurrency option sends X-Concurrency-Limit on every
response. Clients that honour the header cap their own in-flight
requests. The default of 0 sends no header, so behaviour does not
change.
The unified chat and embeddings routes reject bodies above 4 MiB. Long
agent sessions exceed this limit and receive a 413.
Add Config.maxRequestBytes. Zero or a negative value keeps the 4 MiB
default. A positive value raises the cap, clamped to 64 MiB.
An adversarial body decodes to about 12x live heap. An operator who raises
the cap must also set maxInFlightBodyRequests and the pod memory limit.
- Add a process-wide gate on MCP tools/list backend connections. The
per-request limit alone let N callers open N times as many.
- Reject CONNECT and TRACE on native passthrough and on MCP and A2A
targets with 405.
- Scrub URL query strings and the target URL from a backend JSON-RPC
error message before it reaches the caller.
- Replace the value of redis.address in GET /admin/api/config. The
users file path stays visible by design.
- Escape line breaks in every log line so an upstream string cannot
forge log entries.
- Add stripClientAnthropicBeta. When true, POST /v1/messages does not
forward the client anthropic-beta header. The default stays false.