Skip to content

v0.7.0

Choose a tag to compare

@cldmv-bot cldmv-bot released this 08 Nov 22:16
· 6 commits to master since this release
ec6f299

llm-translator v0.7.0 Changelog

Release Date: November 2026
Release Type: Minor
Branch: next → master


Overview

Version 0.7.0 detects Anthropic-protocol servers that aren't on api.anthropic.com, lets a driver declare a tool-call id format the translator rewrites ids into, reports embeddings usage through onUsage, and makes capture record failed-over attempts and embeddings. It also adds npm run test:dist, which runs the full suite against the built dist/.

Nothing here needs a config change. The one difference an existing setup can see is at startup: a server no earlier driver claims now also gets a GET /v1/models with Anthropic headers. See the upgrade notes.


✨ Features

Detect Anthropic-protocol servers by probe (#134)

An Anthropic-compatible server on any host used to need backend: "anthropic". Now a server that no earlier driver claims is also asked for GET /v1/models with anthropic-version and the upstream's key as x-api-key. It is bound to the anthropic driver only when the answer is an Anthropic model list: no object key, a boolean has_more, first_id/last_id naming the first and last entry, and every entry with type: "model", a string id and a string display_name. An OpenAI-style list can never pass, and a server that answers with the OpenAI shape whatever headers it gets stays on the generic driver. The served models come from that list.

api.anthropic.com is still matched by host name with no request. The probe goes out together with the other startup probes, so it adds one request but no round trip. A server that requires a key and has none configured answers 401 and isn't detected; set apiKey or backend: "anthropic". Fixes #54.

Tool-call ids rewritten for strict upstream formats (#135)

Some backends only accept tool-call ids in a fixed format (Mistral wants nine alphanumeric characters, for example). A driver can now declare info().toolCallIds = { alphabet, min?, max? }, and the translator rewrites the client's ids into that format in both directions: an Anthropic client to an OpenAI-style server, and an OpenAI client to an Anthropic-protocol upstream. Ids the upstream returns are mapped back to the client's originals, streaming included.

There is no state between requests: an id that already fits passes through unchanged, and any other id becomes a SHA-256 hash of itself written in the allowed alphabet, so the same id maps the same way on every request and a call always matches its result. Conforming ids are reserved first, and collisions are rehashed with a counter. A format with too few free ids for the conversation fails with invalid_request. No built-in driver declares a format yet; the Mistral driver is #42. Fixes #20.

Embeddings usage through onUsage (#137)

api.embeddings.send and the /v1/embeddings route now report usage like chat does. Every reply, including error replies, has the non-enumerable usage promise, and onUsage is called once, with the authorize context on the server route. The report has front: "openai" and stream: false. input_tokens is the reply's prompt_tokens and the other token fields are null, and a reply without usage reports reported: false. Errors carry reason: "upstream_error", "aborted" or "error". Fixes #121.

Capture records failed-over attempts and embeddings (#136)

capture used to record only the endpoint that answered. Now every attempt of a request gets its own record, and the records share an exchange id (the first attempt's id) and a 1-based attempt. An attempt the request moved on from also has failover with the reason. Its response is the 5xx reply, or { error } for an unreachable upstream. A final failure that becomes the reply is recorded too, and embeddings are captured with the same header redaction. With capture off, failover behaves as before and no extra body is read. Fixes #122.

🔧 CI & tooling

test:dist and test:cjs (#126)

npm run test:dist builds the package and runs the whole suite against dist/ instead of src/, then the CJS entry tests. npm run test:cjs runs only the CJS tests, which load the CJS entry point. npm test runs the suite and then test:cjs, and ci:coverage now runs coverage and then test:dist.

📚 Documentation

🔧 Dependencies

Dev dependencies only:

  • eslint 10.13.0 → 10.14.0 (#129)
  • vitest and @vitest/coverage-v8 5.0.5 → 5.1.0 (#128)
  • fastify 5.12.7 → 5.12.8 and @cldmv/fix-headers 2.2.2 → 2.2.6 (#130)

Upgrade notes

  • One extra startup probe. A server no earlier driver claims now also gets GET /v1/models with anthropic-version and its key as x-api-key. It runs in parallel with the other probes and only binds a real Anthropic model list. Set backend on an upstream to skip probing altogether.
  • Capture records have new fields. Records now carry exchange and attempt, a failed-over attempt also carries failover, and a request that failed over writes more than one record. A tool that reads capture files should group them by exchange.
  • Third-party drivers: info().toolCallIds is optional. Without it, ids are passed through as before.
  • No other changes are needed.

coverage

Metric Coverage
Statements 100.0%
Branches 100.0%
Functions 100.0%
Lines 100.0%

Avg: 100.0% · 0be57c1 · Node lts/*

👥 Contributors