@cldmv/llm-translator 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +8 -9
  2. package/dist/api/convert/anthropic/messages/to/openai/responses/request.mjs +2 -0
  3. package/dist/api/convert/openai/chat/to/openai/responses/request.mjs +2 -0
  4. package/dist/api/convert/openai/chat/to/openai/responses/response.mjs +2 -0
  5. package/dist/api/convert/openai/chat/to/openai/responses/stream.mjs +2 -0
  6. package/dist/api/convert/openai/responses/to/anthropic/messages/response.mjs +2 -0
  7. package/dist/api/convert/openai/responses/to/anthropic/messages/stream.mjs +2 -0
  8. package/dist/api/convert/openai/responses/to/openai/chat/request.mjs +6 -0
  9. package/dist/api/convert/openai/responses/to/openai/chat/response.mjs +2 -0
  10. package/dist/api/convert/openai/responses/to/openai/chat/stream.mjs +2 -0
  11. package/dist/api/detect.mjs +1 -1
  12. package/dist/api/driver/anthropic/info.mjs +1 -1
  13. package/dist/api/driver/azure/info.mjs +1 -1
  14. package/dist/api/driver/compatible/info.mjs +1 -1
  15. package/dist/api/driver/deepseek/info.mjs +1 -1
  16. package/dist/api/driver/llamacpp/info.mjs +1 -1
  17. package/dist/api/driver/lmstudio/info.mjs +1 -1
  18. package/dist/api/driver/localai/info.mjs +1 -1
  19. package/dist/api/driver/mistral/info.mjs +1 -1
  20. package/dist/api/driver/ollama/info.mjs +1 -1
  21. package/dist/api/driver/ollama/request.mjs +1 -1
  22. package/dist/api/driver/openai/info.mjs +1 -1
  23. package/dist/api/driver/openrouter/info.mjs +1 -1
  24. package/dist/api/driver/sglang/info.mjs +1 -1
  25. package/dist/api/driver/tgi/info.mjs +1 -1
  26. package/dist/api/driver/vllm/info.mjs +1 -1
  27. package/dist/api/request.mjs +2 -2
  28. package/dist/api/response.mjs +1 -1
  29. package/dist/api/route.mjs +1 -1
  30. package/dist/api/send.mjs +1 -1
  31. package/dist/api/server/plugin.mjs +1 -1
  32. package/dist/api/server/start.mjs +1 -1
  33. package/dist/api/status.mjs +1 -1
  34. package/dist/api/stream.mjs +1 -1
  35. package/dist/api/token/count.mjs +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/lib/capture.mjs +1 -1
  38. package/dist/lib/cli.mjs +16 -7
  39. package/dist/lib/config.mjs +1 -1
  40. package/dist/lib/estimate.mjs +1 -1
  41. package/dist/lib/guard.mjs +2 -0
  42. package/dist/lib/http.mjs +1 -1
  43. package/dist/lib/metrics.mjs +4 -0
  44. package/dist/lib/presets.mjs +1 -1
  45. package/dist/lib/protocol.mjs +2 -0
  46. package/dist/lib/responses-upstream.mjs +13 -0
  47. package/dist/lib/responses.mjs +2 -0
  48. package/dist/lib/route.mjs +1 -1
  49. package/dist/lib/routes.mjs +1 -1
  50. package/dist/lib/settings.mjs +1 -1
  51. package/dist/lib/vllm.mjs +2 -2
  52. package/package.json +1 -1
  53. package/types/src/api/convert/anthropic/messages/to/openai/responses/request.d.mts +16 -0
  54. package/types/src/api/convert/openai/chat/to/openai/responses/request.d.mts +12 -0
  55. package/types/src/api/convert/openai/chat/to/openai/responses/response.d.mts +14 -0
  56. package/types/src/api/convert/openai/chat/to/openai/responses/stream.d.mts +18 -0
  57. package/types/src/api/convert/openai/responses/to/anthropic/messages/response.d.mts +8 -0
  58. package/types/src/api/convert/openai/responses/to/anthropic/messages/stream.d.mts +8 -0
  59. package/types/src/api/convert/openai/responses/to/openai/chat/request.d.mts +17 -0
  60. package/types/src/api/convert/openai/responses/to/openai/chat/response.d.mts +8 -0
  61. package/types/src/api/convert/openai/responses/to/openai/chat/stream.d.mts +10 -0
  62. package/types/src/api/driver/anthropic/info.d.mts +2 -1
  63. package/types/src/api/driver/azure/info.d.mts +2 -1
  64. package/types/src/api/driver/compatible/info.d.mts +2 -1
  65. package/types/src/api/driver/deepseek/info.d.mts +2 -1
  66. package/types/src/api/driver/fireworks/info.d.mts +2 -1
  67. package/types/src/api/driver/gemini/info.d.mts +2 -1
  68. package/types/src/api/driver/groq/info.d.mts +2 -1
  69. package/types/src/api/driver/llamacpp/info.d.mts +2 -1
  70. package/types/src/api/driver/lmstudio/info.d.mts +2 -1
  71. package/types/src/api/driver/localai/info.d.mts +2 -1
  72. package/types/src/api/driver/mistral/info.d.mts +2 -1
  73. package/types/src/api/driver/ollama/info.d.mts +2 -1
  74. package/types/src/api/driver/ollama/request.d.mts +1 -1
  75. package/types/src/api/driver/openai/info.d.mts +2 -1
  76. package/types/src/api/driver/openrouter/info.d.mts +2 -1
  77. package/types/src/api/driver/sglang/info.d.mts +2 -1
  78. package/types/src/api/driver/tgi/info.d.mts +2 -1
  79. package/types/src/api/driver/together/info.d.mts +2 -1
  80. package/types/src/api/driver/vllm/info.d.mts +2 -1
  81. package/types/src/api/driver/xai/info.d.mts +2 -1
  82. package/types/src/api/request.d.mts +3 -2
  83. package/types/src/api/route.d.mts +2 -2
  84. package/types/src/api/send.d.mts +1 -1
  85. package/types/src/api/server/plugin.d.mts +2 -2
  86. package/types/src/api/server/start.d.mts +1 -1
  87. package/types/src/api/status.d.mts +1 -1
  88. package/types/src/lib/config.d.mts +4 -3
  89. package/types/src/lib/estimate.d.mts +1 -1
  90. package/types/src/lib/guard.d.mts +25 -0
  91. package/types/src/lib/http.d.mts +4 -3
  92. package/types/src/lib/metrics.d.mts +58 -0
  93. package/types/src/lib/presets.d.mts +2 -1
  94. package/types/src/lib/protocol.d.mts +84 -0
  95. package/types/src/lib/responses-upstream.d.mts +58 -0
  96. package/types/src/lib/responses.d.mts +72 -0
  97. package/types/src/lib/route.d.mts +7 -3
  98. package/types/src/lib/routes.d.mts +3 -2
  99. package/types/src/lib/settings.d.mts +11 -6
  100. package/types/src/lib/vllm.d.mts +4 -4
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Describe the Groq driver (see `PRESETS.groq` in `lib/presets.mjs`).
3
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, fields?: string[], paths: Record<string,string>}} Driver facts.
3
+ * @returns {{name: string, protocol: string, protocols: string[], order: number, auth: string, strict: boolean, fields?: string[], paths: Record<string,string>}} Driver facts.
4
4
  */
5
5
  export function info(): {
6
6
  name: string;
7
7
  protocol: string;
8
+ protocols: string[];
8
9
  order: number;
9
10
  auth: string;
10
11
  strict: boolean;
@@ -18,7 +18,7 @@
18
18
  */
19
19
  /**
20
20
  * Describe the llama.cpp driver.
21
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, protocols: string[], probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
22
22
  */
23
23
  export function info(): {
24
24
  name: string;
@@ -26,6 +26,7 @@ export function info(): {
26
26
  order: number;
27
27
  auth: string;
28
28
  strict: boolean;
29
+ protocols: string[];
29
30
  probes: string[];
30
31
  fields: string[];
31
32
  paths: Record<string, string>;
@@ -18,7 +18,7 @@
18
18
  */
19
19
  /**
20
20
  * Describe the LM Studio driver. It is found through `GET /api/v0/models`, LM Studio's own REST listing.
21
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, probes: string[], paths: Record<string,string>}} Driver facts.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, protocols: string[], probes: string[], paths: Record<string,string>}} Driver facts.
22
22
  */
23
23
  export function info(): {
24
24
  name: string;
@@ -26,6 +26,7 @@ export function info(): {
26
26
  order: number;
27
27
  auth: string;
28
28
  strict: boolean;
29
+ protocols: string[];
29
30
  probes: string[];
30
31
  paths: Record<string, string>;
31
32
  };
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * Describe the LocalAI driver. It is found through `GET /version` (`{ version: "v3.1.0 (<commit>)" }`) or LocalAI's discovery document at
21
21
  * `GET /.well-known/localai.json`. The extra fields are the ones LocalAI's request schema accepts beyond the OpenAI set.
22
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
22
+ * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, protocols: string[], probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
23
23
  */
24
24
  export function info(): {
25
25
  name: string;
@@ -27,6 +27,7 @@ export function info(): {
27
27
  order: number;
28
28
  auth: string;
29
29
  strict: boolean;
30
+ protocols: string[];
30
31
  probes: string[];
31
32
  fields: string[];
32
33
  paths: Record<string, string>;
@@ -18,11 +18,12 @@
18
18
  */
19
19
  /**
20
20
  * Describe the Mistral driver. Mistral accepts only 9-character alphanumeric tool-call ids, so the translator rewrites the client's ids.
21
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, hosts: string[], toolCallIds: {alphabet: string, min: number, max: number}, paths: Record<string,string>}} Driver facts.
21
+ * @returns {{name: string, protocol: string, protocols: string[], order: number, auth: string, strict: boolean, hosts: string[], toolCallIds: {alphabet: string, min: number, max: number}, paths: Record<string,string>}} Driver facts.
22
22
  */
23
23
  export function info(): {
24
24
  name: string;
25
25
  protocol: string;
26
+ protocols: string[];
26
27
  order: number;
27
28
  auth: string;
28
29
  strict: boolean;
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * Describe the Ollama driver. `protocol` is the OpenAI-compatible `/v1` API; `native` is the mode an upstream selects with `api: "native"`, Ollama's own
21
21
  * `/api/chat` (the `ollama.chat` protocol; the model list and embeddings stay on `/v1`).
22
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, probes: string[], paths: Record<string,string>, native: {protocol: string, paths: Record<string,string>}}} Driver facts.
22
+ * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, protocols: string[], probes: string[], paths: Record<string,string>, native: {protocol: string, paths: Record<string,string>}}} Driver facts.
23
23
  */
24
24
  export function info(): {
25
25
  name: string;
@@ -27,6 +27,7 @@ export function info(): {
27
27
  order: number;
28
28
  auth: string;
29
29
  strict: boolean;
30
+ protocols: string[];
30
31
  probes: string[];
31
32
  paths: Record<string, string>;
32
33
  native: {
@@ -2,7 +2,7 @@
2
2
  * Remove `tool_choice`, `n` and `logit_bias` (recorded in `state.dropped`; with `tool_choice: "none"` the tools are removed too, so a forbidden tool call cannot happen), replace images given by URL with a note, and warn once per
3
3
  * upstream when the prompt is estimated to exceed `contextWindow` (Ollama truncates silently).
4
4
  * @param {any} body - Chat Completions request body.
5
- * @param {any} [ctx] - `{ endpoint, settings, state, warn }`.
5
+ * @param {any} [ctx] - `{ endpoint, settings, state, warn, protocol }` (`protocol` is the one the request goes over).
6
6
  * @returns {any} Normalized body.
7
7
  */
8
8
  export function request(body: any, ctx?: any): any;
@@ -18,7 +18,7 @@
18
18
  */
19
19
  /**
20
20
  * Describe the OpenAI driver.
21
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, hosts: string[], fields: string[], paths: Record<string,string>}} Driver facts.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, protocols: string[], hosts: string[], fields: string[], paths: Record<string,string>}} Driver facts.
22
22
  */
23
23
  export function info(): {
24
24
  name: string;
@@ -26,6 +26,7 @@ export function info(): {
26
26
  order: number;
27
27
  auth: string;
28
28
  strict: boolean;
29
+ protocols: string[];
29
30
  hosts: string[];
30
31
  fields: string[];
31
32
  paths: Record<string, string>;
@@ -18,11 +18,12 @@
18
18
  */
19
19
  /**
20
20
  * Describe the OpenRouter driver. The API lives under `/api`; the `path` leaf adds it, so `paths` holds the usual `/v1/...` ones.
21
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, hosts: string[], paths: Record<string,string>}} Driver facts.
21
+ * @returns {{name: string, protocol: string, protocols: string[], order: number, auth: string, strict: boolean, hosts: string[], paths: Record<string,string>}} Driver facts.
22
22
  */
23
23
  export function info(): {
24
24
  name: string;
25
25
  protocol: string;
26
+ protocols: string[];
26
27
  order: number;
27
28
  auth: string;
28
29
  strict: boolean;
@@ -18,7 +18,7 @@
18
18
  */
19
19
  /**
20
20
  * Describe the SGLang driver.
21
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
21
+ * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, protocols: string[], probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
22
22
  */
23
23
  export function info(): {
24
24
  name: string;
@@ -26,6 +26,7 @@ export function info(): {
26
26
  order: number;
27
27
  auth: string;
28
28
  strict: boolean;
29
+ protocols: string[];
29
30
  probes: string[];
30
31
  fields: string[];
31
32
  paths: Record<string, string>;
@@ -19,11 +19,12 @@
19
19
  /**
20
20
  * Describe the TGI driver. It is found through `GET /info`, TGI's router description. `grammar` is allowed through the OpenAI front's
21
21
  * request filter because the request normalizer folds it into `response_format`, the only place the chat endpoint reads a grammar.
22
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
22
+ * @returns {{name: string, protocol: string, protocols: string[], order: number, auth: string, strict: boolean, probes: string[], fields: string[], paths: Record<string,string>}} Driver facts.
23
23
  */
24
24
  export function info(): {
25
25
  name: string;
26
26
  protocol: string;
27
+ protocols: string[];
27
28
  order: number;
28
29
  auth: string;
29
30
  strict: boolean;
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Describe the Together AI driver (see `PRESETS.together` in `lib/presets.mjs`).
3
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, fields?: string[], paths: Record<string,string>}} Driver facts.
3
+ * @returns {{name: string, protocol: string, protocols: string[], order: number, auth: string, strict: boolean, fields?: string[], paths: Record<string,string>}} Driver facts.
4
4
  */
5
5
  export function info(): {
6
6
  name: string;
7
7
  protocol: string;
8
+ protocols: string[];
8
9
  order: number;
9
10
  auth: string;
10
11
  strict: boolean;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Describe the vLLM driver. `paths.health` (`GET /health`: 200 when the engine is up, 503 once it is dead; outside the API-key guard) is what `lib/health` probes before routing a request to a pool.
3
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, fields: string[], paths: Record<string,string>}} Driver facts.
3
+ * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, protocols: string[], fields: string[], paths: Record<string,string>}} Driver facts.
4
4
  */
5
5
  export function info(): {
6
6
  name: string;
@@ -8,6 +8,7 @@ export function info(): {
8
8
  order: number;
9
9
  auth: string;
10
10
  strict: boolean;
11
+ protocols: string[];
11
12
  fields: string[];
12
13
  paths: Record<string, string>;
13
14
  };
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Describe the xAI driver (see `PRESETS.xai` in `lib/presets.mjs`).
3
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, fields?: string[], paths: Record<string,string>}} Driver facts.
3
+ * @returns {{name: string, protocol: string, protocols: string[], order: number, auth: string, strict: boolean, fields?: string[], paths: Record<string,string>}} Driver facts.
4
4
  */
5
5
  export function info(): {
6
6
  name: string;
7
7
  protocol: string;
8
+ protocols: string[];
8
9
  order: number;
9
10
  auth: string;
10
11
  strict: boolean;
@@ -2,8 +2,8 @@
2
2
  * Route a client request body (in the configured `front` protocol) to an upstream and convert it to that upstream's
3
3
  * protocol. Does no I/O.
4
4
  * @param {any} body - Client request body (Anthropic Messages or OpenAI Chat Completions, per `front`).
5
- * @param {any} [options] - `{ front, headers, clientHeaders, filter, images, usage }`. `front` overrides the configured front for this call, `headers` are extra upstream headers, `clientHeaders` are client headers forwarded only to a native Anthropic upstream, `filter` restricts a forwarded OpenAI body to known fields (default: the `passthroughFilter` setting, off), `images: false` sends the request without images (used by the image fallback), `endpoint` sends to that member of the model's pool (used for failover; default: the first in the pool's order), `hold: true` (used by `send`) advances a round robin and takes the chosen endpoint's in-flight slot, which the caller then releases, `jsonObject: "instruction"` sends a `json_object` response format as a system instruction (used by the JSON fallback, and applied by itself once a refusal is remembered for the endpoint and model), `tools: false` sends the request without tools (used by the tool fallback), `usage: true` (used by `send`) makes a streaming OpenAI-front request always ask the upstream for its final usage chunk, `cacheSalt` (a trusted per-call vLLM `cache_salt`, which replaces the upstream's `cacheSalt` setting), `retry: true` (used by `send` for the same request sent again) keeps the `dropped` event from repeating, `log` is the logger events of this request also go to (used by the server), `budget` (from `createBudget`, one per `send` for all its attempts) limits the cost of decoding reasoning signatures.
6
- * @returns {Promise<{upstream: string, method: string, url: string, path: string, headers: Record<string,string>, body: any, state: any, pool: string[], images: {sent: boolean, retry: boolean, key: string}, tools: {sent: boolean, retry: boolean}, json: {sent: boolean, retry: boolean, key: string}}>} The upstream request and the state `response`/`stream`/`error` need. `pool` lists the names of the endpoints serving the model in the order they are tried (`upstream` is the first); `images` tells `send` whether the body carries images, whether a refusal may be retried without them and the key under which a refusal is remembered; `tools` tells it whether the body carries tools and whether a tool-parser refusal may be retried without them; `json` tells it whether the body carries the schema emulation of `json_object`, whether a refusal may be retried with the instruction and the key under which a refusal is remembered.
5
+ * @param {any} [options] - `{ front, headers, clientHeaders, filter, images, usage }`. `front` overrides the configured front for this call, `tokens: true` (used by `token.count`) never picks a native Messages route on a server whose own protocol is another, because the tokenizer reads Chat Completions messages, `wire: "responses"` says the body is the Chat Completions form of a Responses API request (so the protocol is chosen for a Responses client), `headers` are extra upstream headers, `clientHeaders` are client headers forwarded only to a native Anthropic upstream, `filter` restricts a forwarded OpenAI body to known fields (default: the `passthroughFilter` setting, off), `images: false` sends the request without images (used by the image fallback), `endpoint` sends to that member of the model's pool (used for failover; default: the first in the pool's order), `hold: true` (used by `send`) advances a round robin and takes the chosen endpoint's in-flight slot, which the caller then releases, `jsonObject: "instruction"` sends a `json_object` response format as a system instruction (used by the JSON fallback, and applied by itself once a refusal is remembered for the endpoint and model), `tools: false` sends the request without tools (used by the tool fallback), `usage: true` (used by `send`) makes a streaming OpenAI-front request always ask the upstream for its final usage chunk, `cacheSalt` (a trusted per-call vLLM `cache_salt`, which replaces the upstream's `cacheSalt` setting), `retry: true` (used by `send` for the same request sent again) keeps the `dropped` event from repeating, `log` is the logger events of this request also go to (used by the server), `budget` (from `createBudget`, one per `send` for all its attempts) limits the cost of decoding reasoning signatures.
6
+ * @returns {Promise<{upstream: string, method: string, url: string, path: string, headers: Record<string,string>, body: any, state: any, pool: string[], more: boolean, images: {sent: boolean, retry: boolean, key: string}, tools: {sent: boolean, retry: boolean}, json: {sent: boolean, retry: boolean, key: string}}>} The upstream request and the state `response`/`stream`/`error` need. `pool` lists the names of the endpoints serving the model in the order they are tried (`upstream` is the first); `more` is true when the upstream is `api: "auto"` and has another protocol to fall back to; `images` tells `send` whether the body carries images, whether a refusal may be retried without them and the key under which a refusal is remembered; `tools` tells it whether the body carries tools and whether a tool-parser refusal may be retried without them; `json` tells it whether the body carries the schema emulation of `json_object`, whether a refusal may be retried with the instruction and the key under which a refusal is remembered.
7
7
  */
8
8
  export function request(body: any, options?: any): Promise<{
9
9
  upstream: string;
@@ -14,6 +14,7 @@ export function request(body: any, options?: any): Promise<{
14
14
  body: any;
15
15
  state: any;
16
16
  pool: string[];
17
+ more: boolean;
17
18
  images: {
18
19
  sent: boolean;
19
20
  retry: boolean;
@@ -2,8 +2,8 @@
2
2
  * Resolve a client request body to its upstream and model (after aliases and routing) without doing any I/O, for example to
3
3
  * check a model allow-list before `send`. Uses the same routing as `request`.
4
4
  * @param {any} body - Client request body (Anthropic Messages or OpenAI Chat Completions, per `front`).
5
- * @param {any} [options] - `{ front }` overrides the configured front for this call.
6
- * @returns {{upstream: string, model: string, requested: string | undefined, protocol: string, backend: string, native: boolean, unserved: boolean, pool: string[]}} `upstream` is the first endpoint `send` would try right now (the endpoint name), `model` the name sent upstream, `requested` the name the client used, `protocol` the upstream's protocol (`openai.chat` or `anthropic.messages`), `backend` the driver detection chose (`vllm`, `openai`, `anthropic` or `compatible`, the `driver` that `status()` reports), `native` whether the body is forwarded without conversion and `unserved` whether no upstream lists the model and `pool` the names of all endpoints serving the model in the order they would be tried (failover candidates). When several endpoints serve the model this is a snapshot of the current health, in-flight counts and round robin position and it does not move the round robin; `send` decides again and may use another member, so the endpoint that answered is `usage.upstream`.
5
+ * @param {any} [options] - `{ front, wire }`: `front` overrides the configured front for this call, `wire: "responses"` routes the Chat Completions form of a Responses API request.
6
+ * @returns {{upstream: string, model: string, requested: string | undefined, protocol: string, backend: string, native: boolean, unserved: boolean, pool: string[]}} `upstream` is the first endpoint `send` would try right now (the endpoint name), `model` the name sent upstream, `requested` the name the client used, `protocol` the protocol this request goes over (`anthropic.messages`, `openai.chat`, `openai.responses` or `ollama.chat`; see the upstream's `api` setting), `backend` the driver detection chose (`vllm`, `openai`, `anthropic` or `compatible`, the `driver` that `status()` reports), `native` whether the body is forwarded without conversion and `unserved` whether no upstream lists the model and `pool` the names of all endpoints serving the model in the order they would be tried (failover candidates). When several endpoints serve the model this is a snapshot of the current health, in-flight counts and round robin position and it does not move the round robin; `send` decides again and may use another member, so the endpoint that answered is `usage.upstream`.
7
7
  * @throws {TranslatorError} `invalid_body` (400) when the body is not a JSON object.
8
8
  */
9
9
  export function route(body: any, options?: any): {
@@ -25,7 +25,7 @@
25
25
  * a stream has started, an error chunk and `[DONE]`. Aborting the caller's signal aborts every branch. An OpenAI-protocol upstream
26
26
  * receives `n` unchanged and answers it itself.
27
27
  * @param {any} body - Client request body (per `front`).
28
- * @param {any} [options] - `{ signal, front, headers, clientHeaders, filter, cacheSalt, onUsage, log }`: abort signal for the upstream call, per-call front, extra upstream headers, client headers forwarded to a native Anthropic upstream, the pass-through body filter (see `request`) and the usage callback (an exception in it is reported as a `usage` event and never breaks the reply) and the logger this request's events also go to (used by the server).
28
+ * @param {any} [options] - `{ signal, front, wire, headers, clientHeaders, filter, cacheSalt, onUsage, log }`: abort signal for the upstream call, per-call front, `wire: "responses"` for the Chat Completions form of a Responses API request, extra upstream headers, client headers forwarded to a native Anthropic upstream, the pass-through body filter (see `request`) and the usage callback (an exception in it is reported as a `usage` event and never breaks the reply) and the logger this request's events also go to (used by the server).
29
29
  * @returns {Promise<{status: number, headers: Record<string,string>, body: any, usage: Promise<any>} | {status: number, headers: Record<string,string>, stream: AsyncIterable<{event?: string, data: *}>, usage: Promise<any>}>} A JSON reply, or a stream reply when the client asked for streaming and the upstream accepted.
30
30
  */
31
31
  export function send(body: any, options?: any): Promise<{
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Fastify plugin. Anthropic front: `POST /v1/messages`, `POST /v1/messages/count_tokens`, `GET /v1/models`, `GET /v1/models/{id}`,
3
- * `GET|HEAD /` and `/api/hello`. OpenAI front: `POST /v1/chat/completions`, `POST /v1/embeddings`, `GET /v1/models`, `GET /v1/models/{id}`, `GET|HEAD /`. Responses stream as
3
+ * `GET|HEAD /` and `/api/hello`. OpenAI front: `POST /v1/chat/completions`, `POST /v1/responses`, `POST /v1/responses/input_tokens`, `POST /v1/embeddings`, `GET /v1/models`, `GET /v1/models/{id}`, `GET|HEAD /`. Responses stream as
4
4
  * `text/event-stream` with keep-alive pings; a client disconnect aborts the upstream request. Register it with
5
5
  * `app.register(api.server.plugin, { apiKey })`. `authorize(request)` (sync or async) runs after `apiKey` and the body parse and decides
6
6
  * with `true` / `{ ok: true, context }` or `false` / `{ ok: false, status, message }`; `onUsage(report, context)` receives each request's usage report. When the Fastify `logger` is enabled, events also go to it as structured lines (`{ event }` plus the message), through the request's logger for events of a request.
7
7
  * @param {any} fastify - Fastify instance.
8
- * @param {any} [options] - `{ front, apiKey, bodyLimit, authorize, onUsage }`. `authorize(request)` and `onUsage(report, context)` are described above. `front` sets the protocol this plugin instance serves (default: the translator's front, other plugin instances and `api.send` are unaffected); `apiKey` (string or array) is required from clients. Forwarded OpenAI bodies are restricted to known fields unless the `passthroughFilter` setting is `false`.
8
+ * @param {any} [options] - `{ front, apiKey, bodyLimit, authorize, onUsage, metrics, cors, rateLimit }`. `cors` (a list of origins, `"*"` for any) and `rateLimit` (`{ requests, windowMs }`) are described in docs/server.md and are off unless set. `metrics: true` adds `GET /metrics` (Prometheus text format, behind the same authentication as every other route; off by default, then an unknown route). `authorize(request)` and `onUsage(report, context)` are described above. `front` sets the protocol this plugin instance serves (default: the translator's front, other plugin instances and `api.send` are unaffected); `apiKey` (string or array) is required from clients. Forwarded OpenAI bodies are restricted to known fields unless the `passthroughFilter` setting is `false`.
9
9
  * @returns {Promise<void>} Resolves once the routes are registered.
10
10
  */
11
11
  export function plugin(fastify: any, options?: any): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Start an HTTP server in front of the translator. Fastify is an optional peer dependency and is imported here.
3
- * @param {any} [options] - `{ host = "127.0.0.1", port = 8787, front, apiKey, bodyLimit, logger, allowUnauthenticated, authorize, onUsage }`. `authorize(request)` and `onUsage(report, context)` are described at `server.plugin`. Listening on a non-loopback address without an `apiKey` or an `authorize` hook is refused unless `allowUnauthenticated` is true.
3
+ * @param {any} [options] - `{ host = "127.0.0.1", port = 8787, front, apiKey, bodyLimit, logger, allowUnauthenticated, authorize, onUsage, metrics, tls, cors, rateLimit }`. `authorize(request)` and `onUsage(report, context)` are described at `server.plugin`. `tls` is `{ key, cert, ca, passphrase }` (file paths; `key` and `cert` together) and serves HTTPS; `cors` is a list of allowed origins (`"*"` for any); `rateLimit` is `{ requests, windowMs = 60000 }` per API key (remote address without one). Each is off unless set; see docs/server.md. Listening on a non-loopback address without an `apiKey` or an `authorize` hook is refused unless `allowUnauthenticated` is true.
4
4
  * @returns {Promise<{url: string, host: string, port: number, app: any, close: () => Promise<void>}>} Running server handle.
5
5
  */
6
6
  export function start(options?: any): Promise<{
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Describe the translator's upstreams. Secrets (API keys, headers) are never included.
3
- * @returns {{front: string, upstreams: any[]}} Front protocol and per-upstream detection results and health (see `endpoint.status`). `messages` is true while an Anthropic-front request to a vLLM upstream goes to its native `/v1/messages` (the `nativeMessages` setting; a request it cannot take is still converted), false when it is converted, and null for any other driver.
3
+ * @returns {{front: string, upstreams: any[]}} Front protocol and per-upstream detection results and health (see `endpoint.status`). `api` is the upstream's `api` setting as the canonical id (or `"auto"`) and `protocols` the protocols its driver speaks. `protocol` is the one a request in the configured front's protocol goes over now (under `api: "auto"` that is the first of the client's own protocol and Chat Completions that the server has, so an upstream that answered 404, 405 or 501 to one has moved on until the next detection). `responses` is true while that holds for a Responses API request (a Responses client on an OpenAI front), and `messages` is true while an Anthropic request to a vLLM upstream goes to its native `/v1/messages` (a request it cannot take is still converted), false when it is converted, and null for any other driver.
4
4
  */
5
5
  export function status(): {
6
6
  front: string;
@@ -2,9 +2,10 @@
2
2
  * Normalize one upstream entry into the runtime endpoint record.
3
3
  * @param {string | UpstreamConfig} entry - Upstream URL or config object.
4
4
  * @param {number} index - Position in the list.
5
+ * @param {any} [globalSettings] - The config's global `settings`.
5
6
  * @returns {any} Runtime endpoint.
6
7
  */
7
- export function endpoint(entry: string | UpstreamConfig, index: number): any;
8
+ export function endpoint(entry: string | UpstreamConfig, index: number, globalSettings?: any): any;
8
9
  /**
9
10
  * Validate and normalize the translator config.
10
11
  * @param {any} [config] - Raw config passed to `createTranslator`.
@@ -37,9 +38,9 @@ export type UpstreamConfig = {
37
38
  */
38
39
  deployment?: string;
39
40
  /**
40
- * Which API of the server to use: `"openai"` (default) is the OpenAI-compatible one, `"native"` the server's own chat API, for a driver that has one (Ollama's `/api/chat`).
41
+ * Which protocol of the server to speak, `"auto"` by default. Canonical ids are `"anthropic.messages"`, `"openai.chat"`, `"openai.responses"` and `"ollama.chat"`; `"messages"`, `"anthropic"` and `"claude"` mean the first, `"chat"`, `"openai"` and `"chatgpt"` the second, `"responses"` and `"codex"` the third and `"native"` and `"ollama"` the last. `"auto"` goes over the client's own protocol when the driver's server speaks it (Chat Completions otherwise) and falls back to the next one when the server answers 404, 405 or 501; an explicit value is always that protocol and never falls back. A protocol the driver does not list fails detection with `unsupported_api`.
41
42
  */
42
- api?: "openai" | "native";
43
+ api?: string;
43
44
  /**
44
45
  * Driver name, or `"auto"` (default) to detect.
45
46
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Rough prompt size: one token per four characters of the serialized system prompt, messages and tools.
2
+ * Rough prompt size: one token per four characters of the serialized system prompt, messages (or `input`) and tools.
3
3
  * @param {any} body - Upstream request body.
4
4
  * @returns {number} Estimated tokens.
5
5
  */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Read the TLS files named by `options.tls` into the `https` options of Fastify / `node:https`.
3
+ * @param {any} tls - `{ key, cert, ca, passphrase }`: file paths (`ca` may be a list), `passphrase` a string; or undefined for plain HTTP.
4
+ * @returns {Promise<object | null>} `https` options, or null when TLS is not configured.
5
+ */
6
+ export function tlsOptions(tls: any): Promise<object | null>;
7
+ /**
8
+ * Build the CORS policy.
9
+ * @param {any} option - A list of origins, or `{ origins }`. `"*"` allows every origin. Undefined, null or an empty list turns CORS off.
10
+ * @returns {{ headers: (origin: string | undefined) => Record<string,string>, preflight: (origin: string | undefined, requested: string | undefined) => Record<string,string> } | null} Policy, or null when off.
11
+ */
12
+ export function cors(option: any): {
13
+ headers: (origin: string | undefined) => Record<string, string>;
14
+ preflight: (origin: string | undefined, requested: string | undefined) => Record<string, string>;
15
+ } | null;
16
+ /**
17
+ * Build a fixed-window rate limiter.
18
+ * @param {any} option - `{ requests, windowMs = 60000 }` (requests per window per client); undefined, null or false turns it off.
19
+ * @param {() => number} [now] - Clock in ms (tests).
20
+ * @returns {{ take: (key: string) => number, size: () => number } | null} Limiter, or null when off. `take(key)` returns 0 when the request may go on, else the seconds to wait.
21
+ */
22
+ export function rateLimit(option: any, now?: () => number): {
23
+ take: (key: string) => number;
24
+ size: () => number;
25
+ } | null;
@@ -26,14 +26,15 @@ export function join(base: string, path: string): string;
26
26
  /**
27
27
  * The path (with any query) of a call on an upstream. A driver that has a `path(kind, { endpoint, model })` leaf builds it from the endpoint
28
28
  * and the model (Azure OpenAI puts the deployment and `api-version` there); otherwise `info().paths[kind]` is used, with the standard
29
- * OpenAI path for `embeddings` and `models` when the driver does not name one.
29
+ * OpenAI path for `responses`, `embeddings` and `models` when the driver does not name one.
30
30
  * @param {any} driver - Driver record (`info` and the optional `path` leaf).
31
- * @param {"chat" | "messages" | "embeddings" | "models"} kind - Which call.
31
+ * @param {"chat" | "messages" | "responses" | "embeddings" | "models"} kind - Which call.
32
32
  * @param {any} endpoint - Runtime endpoint.
33
33
  * @param {string} [model] - The upstream's model name for the request.
34
+ * @param {string} [protocol] - The protocol the request goes over.
34
35
  * @returns {Promise<string>} Path starting with `/`.
35
36
  */
36
- export function pathOf(driver: any, kind: "chat" | "messages" | "embeddings" | "models", endpoint: any, model?: string): Promise<string>;
37
+ export function pathOf(driver: any, kind: "chat" | "messages" | "responses" | "embeddings" | "models", endpoint: any, model?: string, protocol?: string): Promise<string>;
37
38
  /**
38
39
  * Whether a listen address only accepts connections from this machine.
39
40
  * @param {string} host - Host or address.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Escape a label value: backslash, double quote and line feed.
3
+ * @param {any} value - Label value.
4
+ * @returns {string} Escaped text.
5
+ */
6
+ export function escapeLabel(value: any): string;
7
+ /**
8
+ * Escape `# HELP` text: backslash and line feed.
9
+ * @param {string} text - Help text.
10
+ * @returns {string} Escaped text.
11
+ */
12
+ export function escapeHelp(text: string): string;
13
+ /**
14
+ * Create an empty registry.
15
+ * @returns {{ counter: (name: string, help: string) => void, histogram: (name: string, help: string, buckets?: number[]) => void, inc: (name: string, labels: Record<string, any>, by?: number) => void, observe: (name: string, labels: Record<string, any>, value: number) => void, render: (gauges?: {name: string, help: string, samples: {labels: Record<string, any>, value: number}[]}[]) => string }} Registry.
16
+ */
17
+ export function create(): {
18
+ counter: (name: string, help: string) => void;
19
+ histogram: (name: string, help: string, buckets?: number[]) => void;
20
+ inc: (name: string, labels: Record<string, any>, by?: number) => void;
21
+ observe: (name: string, labels: Record<string, any>, value: number) => void;
22
+ render: (gauges?: {
23
+ name: string;
24
+ help: string;
25
+ samples: {
26
+ labels: Record<string, any>;
27
+ value: number;
28
+ }[];
29
+ }[]) => string;
30
+ };
31
+ /**
32
+ * The kind of an error, or null when the request did not fail: `upstream` (the upstream answered with an error or could not be reached
33
+ * as far as the usage report knows), `translator` (a failure in the translator itself, a 5xx or an in-band stream error) and `client`
34
+ * (a refused request: bad body, authentication, unknown model or route). A client that left is not an error.
35
+ * @param {number} status - HTTP status as written (499 when the client left).
36
+ * @param {any} report - The request's usage report, or null.
37
+ * @returns {"upstream" | "translator" | "client" | null} Kind.
38
+ */
39
+ export function kind(status: number, report: any): "upstream" | "translator" | "client" | null;
40
+ /**
41
+ * Create the metrics of one server: a registry plus the request recorder and the scrape renderer. Label values stay bounded: `front` is
42
+ * one of two protocols, `route` is the route pattern (never the URL), `driver` is a driver name, `upstream` a configured upstream name
43
+ * and `code` an HTTP status. The model a client asked for, request ids and API keys are never labels.
44
+ * @param {{ front: "anthropic" | "openai", endpoints: () => any[] }} source - The server's front and its runtime endpoints.
45
+ * @returns {{ hook: (request: any, reply: any) => Promise<void>, attach: (request: any, sending: Promise<any>) => void, render: () => string }} Recorder.
46
+ */
47
+ export function recorder(source: {
48
+ front: "anthropic" | "openai";
49
+ endpoints: () => any[];
50
+ }): {
51
+ hook: (request: any, reply: any) => Promise<void>;
52
+ attach: (request: any, sending: Promise<any>) => void;
53
+ render: () => string;
54
+ };
55
+ /** `Content-Type` of the text exposition format. */
56
+ export const CONTENT_TYPE: "text/plain; version=0.0.4; charset=utf-8";
57
+ /** Request duration buckets in seconds: LLM replies run from milliseconds (errors, embeddings) to minutes (long streams). */
58
+ export const BUCKETS: number[];
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * The driver facts of a preset.
3
3
  * @param {string} name - Preset name.
4
- * @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, hosts: string[], fields?: string[], paths: Record<string,string>}} Driver facts.
4
+ * @returns {{name: string, protocol: string, protocols: string[], order: number, auth: string, strict: boolean, hosts: string[], fields?: string[], paths: Record<string,string>}} Driver facts.
5
5
  */
6
6
  export function describe(name: string): {
7
7
  name: string;
8
8
  protocol: string;
9
+ protocols: string[];
9
10
  order: number;
10
11
  auth: string;
11
12
  strict: boolean;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The canonical `api` value for what a config says.
3
+ * @param {any} value - The configured `api`.
4
+ * @returns {string | undefined} `"auto"` or a canonical protocol id; undefined for anything that is not an accepted name.
5
+ */
6
+ export function canonical(value: any): string | undefined;
7
+ /**
8
+ * The protocols a driver's server speaks: `info().protocols`, plus its own `protocol`, plus (for a driver that still declares the older flags)
9
+ * the Responses API (`responses: true`) and its `native` mode.
10
+ * @param {any} info - Driver facts.
11
+ * @returns {string[]} Canonical ids, without duplicates.
12
+ */
13
+ export function supported(info: any): string[];
14
+ /**
15
+ * The protocol a client speaks to the translator.
16
+ * @param {"anthropic" | "openai"} front - The front.
17
+ * @param {string} [wire] - `"responses"` for a request that came in on the Responses API.
18
+ * @returns {string} Protocol id.
19
+ */
20
+ export function frontOf(front: "anthropic" | "openai", wire?: string): string;
21
+ /**
22
+ * The protocols to try for a request, best first.
23
+ * With an explicit `api` that is the one protocol. Under `auto` it is the client's own protocol, then Chat Completions, then (so a driver that speaks
24
+ * neither, such as Anthropic's, is still reachable by conversion) the driver's own protocol, minus the ones this upstream is known not to have.
25
+ * @param {{api: string, front: string, info: any, missing?: Set<string>, usable?: (protocol: string) => boolean}} spec - `api` is the endpoint's canonical setting, `front` the client's protocol, `info` the driver facts, `missing` the protocols remembered missing for the upstream (ignored for an explicit `api`) and `usable` a further per-request check.
26
+ * @returns {string[]} Protocols in order; never empty.
27
+ */
28
+ export function candidates({ api, front, info, missing, usable }: {
29
+ api: string;
30
+ front: string;
31
+ info: any;
32
+ missing?: Set<string>;
33
+ usable?: (protocol: string) => boolean;
34
+ }): string[];
35
+ /**
36
+ * Remember that an upstream has no route for a protocol, so later requests skip it until the next detection.
37
+ * @param {any} state - Translator state (`missing`).
38
+ * @param {string} name - Upstream name.
39
+ * @param {string} protocol - Protocol id.
40
+ * @returns {void}
41
+ */
42
+ export function remember(state: any, name: string, protocol: string): void;
43
+ /**
44
+ *
45
+ * @Project: @cldmv/llm-translator
46
+ * @Filename: /src/lib/protocol.mjs
47
+ * @Date: 2026-11-18T09:00:00-08:00 (1795021200)
48
+ * @Author: Nate Corcoran <CLDMV>
49
+ * @Email: <Shinrai@users.noreply.github.com>
50
+ * -----
51
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
52
+ * @Last modified time: 2026-11-18T09:00:00-08:00 (1795021200)
53
+ * -----
54
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
55
+ *
56
+ */
57
+ /**
58
+ * @fileoverview The upstream protocols, the names the `api` setting accepts for them, and how a request picks one.
59
+ * @module @cldmv/llm-translator/lib/protocol
60
+ */
61
+ export const MESSAGES: "anthropic.messages";
62
+ export const CHAT: "openai.chat";
63
+ export const RESPONSES: "openai.responses";
64
+ export const OLLAMA: "ollama.chat";
65
+ /** The canonical protocol ids, in the order the docs list them. */
66
+ export const IDS: string[];
67
+ /** Every accepted spelling of the `api` setting and the canonical id it stands for. */
68
+ export const ALIASES: Readonly<{
69
+ auto: "auto";
70
+ "anthropic.messages": "anthropic.messages";
71
+ messages: "anthropic.messages";
72
+ anthropic: "anthropic.messages";
73
+ claude: "anthropic.messages";
74
+ "openai.chat": "openai.chat";
75
+ chat: "openai.chat";
76
+ openai: "openai.chat";
77
+ chatgpt: "openai.chat";
78
+ "openai.responses": "openai.responses";
79
+ responses: "openai.responses";
80
+ codex: "openai.responses";
81
+ "ollama.chat": "ollama.chat";
82
+ native: "ollama.chat";
83
+ ollama: "ollama.chat";
84
+ }>;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Convert a Chat Completions request body into a Responses request body.
3
+ *
4
+ * System messages before the first turn become `instructions`; assistant turns become message and `function_call` items and their
5
+ * tool results `function_call_output` items. The request is always stateless (`store: false`); with `reasoningRoundTrip` the encrypted
6
+ * reasoning of earlier turns is asked for (`include`) and sent back as `reasoning` items. Fields the Responses API has no counterpart
7
+ * for (`stop`, `seed`, the penalties, `logit_bias`, `logprobs`) are dropped and recorded in `state.dropped`.
8
+ * @param {any} chat - Chat Completions body.
9
+ * @param {Partial<import("./settings.mjs").Settings>} [settings] - Translator settings.
10
+ * @returns {{ body: any, state: any }} Responses body and conversion state (`front`, `model`, `stream`, `includeUsage`, `dropped`).
11
+ * @throws {TranslatorError} For a body without `messages`, `n` above 1 (`send` fans that out instead), an unknown role, or an unknown field when configured to error.
12
+ */
13
+ export function request(chat: any, settings?: Partial<import("./settings.mjs").Settings>): {
14
+ body: any;
15
+ state: any;
16
+ };
17
+ /**
18
+ * Chat Completions usage for a Responses usage object.
19
+ * @param {any} usage - Responses `usage`.
20
+ * @returns {object | undefined} Chat usage, or undefined when the reply carried none.
21
+ */
22
+ export function usageOf(usage: any): object | undefined;
23
+ /**
24
+ * Convert a (non-streaming) Responses reply into a Chat Completions reply.
25
+ *
26
+ * Message text becomes `content` (a refusal `refusal`), `function_call` items `tool_calls`, and the summary of reasoning items the
27
+ * reasoning field named by `reasoningField`. With `reasoningRoundTrip` every reasoning item that carries `encrypted_content` is also
28
+ * returned as a `reasoning_details` item (format `openai-responses-v1`), which the Anthropic converter signs into the thinking block and the
29
+ * request converter turns back into a `reasoning` item.
30
+ * @param {any} reply - Responses object.
31
+ * @param {any} [state] - State from the request converter (`model`; `upstreamUsage` is written to it).
32
+ * @param {Partial<import("./settings.mjs").Settings>} [settings] - Translator settings.
33
+ * @returns {any} Chat completion.
34
+ * @throws {TranslatorError} When the reply is not an object with an `output` list, or did not finish.
35
+ */
36
+ export function response(reply: any, state?: any, settings?: Partial<import("./settings.mjs").Settings>): any;
37
+ /**
38
+ * Convert a Responses event stream into Chat Completions chunks followed by `[DONE]`.
39
+ *
40
+ * `source` is SSE text or bytes, parsed events, or bare event payloads (they carry their own `type`). Text, refusal, reasoning summary and
41
+ * argument deltas become the matching `delta` fields; a tool call starts with its `id` and name when its item is added. With
42
+ * `reasoningRoundTrip` the encrypted reasoning arrives as one `reasoning_details` chunk when its item is done. The final usage goes out as a
43
+ * `choices: []` chunk when `state.includeUsage` is not false. A `response.failed` or `error` event, or a stream that ends before a final
44
+ * event, becomes an `{ error }` chunk followed by `[DONE]`.
45
+ * @param {ReadableStream | AsyncIterable<unknown> | Iterable<unknown> | string | Uint8Array} source - Responses stream.
46
+ * @param {any} [state] - State from the request converter (`model`, `includeUsage`; `upstreamUsage` is written to it).
47
+ * @param {Partial<import("./settings.mjs").Settings>} [settings] - Translator settings.
48
+ * @returns {AsyncGenerator<{ data: any }, void, undefined>} Chat chunks.
49
+ */
50
+ export function stream(source: ReadableStream | AsyncIterable<unknown> | Iterable<unknown> | string | Uint8Array, state?: any, settings?: Partial<import("./settings.mjs").Settings>): AsyncGenerator<{
51
+ data: any;
52
+ }, void, undefined>;
53
+ /** Protocol name of an upstream that speaks the Responses API. */
54
+ export const PROTOCOL: "openai.responses";
55
+ /** Statuses that mean the server has no Responses API: the route is missing (404, 405) or not implemented (501). */
56
+ export const MISSING: number[];
57
+ /** `format` of the `reasoning_details` items that carry a Responses reasoning item (the encrypted content and its summary). */
58
+ export const FORMAT: "openai-responses-v1";