flexinference 1.5.2 → 1.5.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.3
4
+
5
+ Relaxes Messages `max_tokens` on the FlexInference side. The SDK no longer requires or
6
+ runtime-validates it before sending a `/messages` request; FlexInference forwards it when
7
+ set and lets Anthropic return its own request error when it is omitted.
8
+
9
+ ## 1.5.2
10
+
11
+ Adds zero-dependency runtime request validation matching the Python SDK: a request is now
12
+ checked for `model` and the per-endpoint required fields before it is sent, with the two SDKs
13
+ held to identical behavior by shared parity fixtures. The generated `Error` type also gains a
14
+ `doc_url` field, so an error now carries a link to its documentation.
15
+
3
16
  ## 1.5.1
4
17
 
5
18
  Small robustness fixes for the transport, no API changes. A non-streaming request that hits
package/README.md CHANGED
@@ -34,7 +34,7 @@ FlexInference routes to **OpenAI**, **Google Gemini**, and **Anthropic**. Send t
34
34
 
35
35
  - **OpenAI:** `default` (the standard tier), `priority`, `auto`, and flex on flex-capable models. You reach flex by passing a duration.
36
36
  - **Gemini:** `default` maps to Gemini's standard tier. You also get `priority` and flex on the Gemini flex models (`gemini-3.5-flash`, `gemini-3.1-flash-lite`, `gemini-3.1-pro-preview`, `gemini-3-flash-preview`, `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-2.5-flash-lite`). Gemini has no `auto` tier, so `start_within: "auto"` on a Gemini model returns `400`.
37
- - **Anthropic (Claude):** proxy-only. `default`, `priority`, and `auto` work; there is **no flex tier**, so a duration `start_within` on a `claude-*` model returns `400 flex_unsupported_for_anthropic`. Anthropic requires a token cap, so set `max_output_tokens` (`max_completion_tokens` on Chat, `max_tokens` on Messages) or you get `400 missing_max_tokens`. You keep the unified API and tier control, and draw down your own Anthropic credits.
37
+ - **Anthropic (Claude):** proxy-only. `default`, `priority`, and `auto` work; there is **no flex tier**, so a duration `start_within` on a `claude-*` model returns `400 flex_unsupported_for_anthropic`. Anthropic requires an output-token field upstream. FlexInference forwards `max_output_tokens` (`max_completion_tokens` on Chat, `max_tokens` on Messages) when set and does not synthesize a default, so omitting it returns Anthropic's own request error. You keep the unified API and tier control, and draw down your own Anthropic credits.
38
38
 
39
39
  Add the provider key you'll use (OpenAI, Gemini, and/or Anthropic) in the [dashboard](https://www.flexinference.com/dashboard). Text, streaming, structured outputs, function calling, image input, and web search work across providers (send a Responses `web_search` tool; we map it to Gemini's `google_search`).
40
40
 
@@ -85,7 +85,7 @@ console.log(interactionText(res));
85
85
 
86
86
  ## Messages (Anthropic shape)
87
87
 
88
- Speak Anthropic's Messages shape and reach any model. `max_tokens` is required (Anthropic requires it). `messageText(res)` pulls the assistant text out of the message `content`.
88
+ Speak Anthropic's Messages shape and reach any model. Anthropic requires `max_tokens` upstream. FlexInference forwards it when set and does not synthesize a default, so omitting it returns Anthropic's own request error. `messageText(res)` pulls the assistant text out of the message `content`.
89
89
 
90
90
  ```ts
91
91
  import { messageText } from "flexinference";
package/dist/index.js CHANGED
@@ -162,9 +162,7 @@ function parseStartWithin(value) {
162
162
  const match = DURATION_RE.exec(value);
163
163
  if (match === null)
164
164
  return { kind: "invalid", reason: "malformed", value };
165
- const seconds = Number(match[1]) * SECONDS_PER_HOUR +
166
- Number(match[2]) * SECONDS_PER_MINUTE +
167
- Number(match[3]);
165
+ const seconds = Number(match[1]) * SECONDS_PER_HOUR + Number(match[2]) * SECONDS_PER_MINUTE + Number(match[3]);
168
166
  return { kind: "duration", value, seconds };
169
167
  }
170
168
  // Runtime guard so plain-JS callers (who get no compile-time check) still fail
@@ -191,7 +189,7 @@ function assertStartWithin(body) {
191
189
  }
192
190
  // Per-endpoint required fields beyond the model/start_within envelope. Mirrors the Python
193
191
  // _RequestSpec table in _validation.py: responses/interactions require `input` (presence only);
194
- // chat requires `messages` (array); messages requires `messages` (array) + `max_tokens` (number).
192
+ // chat/messages require `messages` (array).
195
193
  const RESPONSES_REQUEST_SPEC = {
196
194
  required: [{ name: "input", kind: "present" }],
197
195
  };
@@ -202,10 +200,7 @@ const INTERACTIONS_REQUEST_SPEC = {
202
200
  required: [{ name: "input", kind: "present" }],
203
201
  };
204
202
  const MESSAGES_REQUEST_SPEC = {
205
- required: [
206
- { name: "messages", kind: "array" },
207
- { name: "max_tokens", kind: "finiteNumber" },
208
- ],
203
+ required: [{ name: "messages", kind: "array" }],
209
204
  };
210
205
  // Read one field by reference off the raw body without copying it. `undefined` (or a non-object
211
206
  // body) is treated as missing; `null` counts as present, matching Python's `name in body`
package/dist/types.d.ts CHANGED
@@ -90,7 +90,7 @@ export interface paths {
90
90
  };
91
91
  get?: never;
92
92
  put?: never;
93
- /** Create a message. The fourth FlexInference caller format (Anthropic Messages shape in and out); works for any model via the canonical Responses path. Send start_within and do not send service_tier. max_tokens is required. */
93
+ /** Create a message. The fourth FlexInference caller format (Anthropic Messages shape in and out); works for any model via the canonical Responses path. Send start_within and do not send service_tier. Anthropic requires max_tokens upstream. FlexInference forwards it when set and does not synthesize a default, so omitting it returns Anthropic's own request error. */
94
94
  post: operations["createMessage"];
95
95
  delete?: never;
96
96
  options?: never;
@@ -5794,11 +5794,11 @@ export interface components {
5794
5794
  };
5795
5795
  /**
5796
5796
  * Message Create Params
5797
- * @description Request body for POST /v1/messages (Anthropic Messages shape). Works for any model via the canonical Responses path. max_tokens is required (Anthropic requires it and the router rejects a claude-* request that reaches the Anthropic upstream without a canonical max_output_tokens). Does not accept service_tier (the router owns the tier). start_within is required at runtime but left optional here.
5797
+ * @description Request body for POST /v1/messages (Anthropic Messages shape). Works for any model via the canonical Responses path. Anthropic requires max_tokens upstream. FlexInference forwards it when set and does not synthesize a default, so omitting it returns Anthropic's own request error. Does not accept service_tier (the router owns the tier). start_within is required at runtime but left optional here.
5798
5798
  */
5799
5799
  MessageCreateParams: {
5800
5800
  model: string;
5801
- max_tokens: number;
5801
+ max_tokens?: number;
5802
5802
  /** @description System prompt as a string or an array of text blocks. */
5803
5803
  system?: string | components["schemas"]["MessageTextBlock"][];
5804
5804
  messages: components["schemas"]["Message"][];
@@ -6136,7 +6136,7 @@ export interface operations {
6136
6136
  "text/event-stream": components["schemas"]["MessageStreamEvent"];
6137
6137
  };
6138
6138
  };
6139
- /** @description Bad request. A FlexInference-layer rejection (type flexinference_error, e.g. missing_start_within, invalid_start_within, model_not_flex_capable, flex_unsupported_for_anthropic, missing_max_tokens, service_tier_not_allowed) or an upstream provider rejection passed through unchanged. */
6139
+ /** @description Bad request. A FlexInference-layer rejection (type flexinference_error, e.g. missing_start_within, invalid_start_within, model_not_flex_capable, flex_unsupported_for_anthropic, service_tier_not_allowed) or an upstream provider rejection passed through unchanged. */
6140
6140
  400: {
6141
6141
  headers: {
6142
6142
  [name: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flexinference",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Official TypeScript SDK for FlexInference - a deadline-aware, OpenAI-compatible inference router.",
5
5
  "license": "MIT",
6
6
  "author": "Aditya Perswal <adityaperswal@gmail.com>",