dot-inference 4.2.0__tar.gz → 4.4.0__tar.gz

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 (63) hide show
  1. {dot_inference-4.2.0 → dot_inference-4.4.0}/CHANGELOG.md +112 -1
  2. {dot_inference-4.2.0 → dot_inference-4.4.0}/PKG-INFO +38 -17
  3. {dot_inference-4.2.0 → dot_inference-4.4.0}/README.md +37 -16
  4. {dot_inference-4.2.0 → dot_inference-4.4.0}/docs/ARCHITECTURE.md +2 -2
  5. {dot_inference-4.2.0 → dot_inference-4.4.0}/docs/provider-quirks/tool-choice.md +25 -7
  6. {dot_inference-4.2.0 → dot_inference-4.4.0}/examples/demo.py +5 -5
  7. {dot_inference-4.2.0 → dot_inference-4.4.0}/pyproject.toml +1 -1
  8. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/README.md +2 -2
  9. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/__init__.py +4 -0
  10. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_client.py +49 -26
  11. dot_inference-4.4.0/src/dot_inference/_context_window.py +58 -0
  12. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_llm_registry.py +18 -10
  13. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_local_check.py +50 -3
  14. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_mistral_compat.py +2 -2
  15. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/models.yaml +128 -285
  16. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/settings.py +3 -3
  17. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_factories.py +104 -12
  18. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_images.py +1 -1
  19. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_llm_registry.py +66 -35
  20. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_local_check.py +68 -0
  21. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_mistral_compat.py +3 -3
  22. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_openai_compat.py +10 -10
  23. {dot_inference-4.2.0 → dot_inference-4.4.0}/uv.lock +1 -1
  24. {dot_inference-4.2.0 → dot_inference-4.4.0}/.env.template +0 -0
  25. {dot_inference-4.2.0 → dot_inference-4.4.0}/.gitignore +0 -0
  26. {dot_inference-4.2.0 → dot_inference-4.4.0}/.gitlab-ci.yml +0 -0
  27. {dot_inference-4.2.0 → dot_inference-4.4.0}/.pre-commit-config.yaml +0 -0
  28. {dot_inference-4.2.0 → dot_inference-4.4.0}/.python-version +0 -0
  29. {dot_inference-4.2.0 → dot_inference-4.4.0}/AUTHORS.md +0 -0
  30. {dot_inference-4.2.0 → dot_inference-4.4.0}/CONTRIBUTING.md +0 -0
  31. {dot_inference-4.2.0 → dot_inference-4.4.0}/LICENSE.md +0 -0
  32. {dot_inference-4.2.0 → dot_inference-4.4.0}/docs/DEVELOPMENT.md +0 -0
  33. {dot_inference-4.2.0 → dot_inference-4.4.0}/docs/PUBLISHING.md +0 -0
  34. {dot_inference-4.2.0 → dot_inference-4.4.0}/docs/VERSIONING.md +0 -0
  35. {dot_inference-4.2.0 → dot_inference-4.4.0}/docs/provider-quirks/openrouter-errors.md +0 -0
  36. {dot_inference-4.2.0 → dot_inference-4.4.0}/docs/provider-quirks/strict-schemas.md +0 -0
  37. {dot_inference-4.2.0 → dot_inference-4.4.0}/examples/demo_streaming.py +0 -0
  38. {dot_inference-4.2.0 → dot_inference-4.4.0}/examples/doc_stream.md +0 -0
  39. {dot_inference-4.2.0 → dot_inference-4.4.0}/scripts/provider-quirks/tool-choice/mistral_compare.sh +0 -0
  40. {dot_inference-4.2.0 → dot_inference-4.4.0}/scripts/provider-quirks/tool-choice/mistral_runaway.sh +0 -0
  41. {dot_inference-4.2.0 → dot_inference-4.4.0}/scripts/provider-quirks/tool-choice/openrouter_compare.sh +0 -0
  42. {dot_inference-4.2.0 → dot_inference-4.4.0}/scripts/provider-quirks/tool-choice/openrouter_runaway.sh +0 -0
  43. {dot_inference-4.2.0 → dot_inference-4.4.0}/scripts/test_all_models.py +0 -0
  44. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_cost_tracker.py +0 -0
  45. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_openai_compat.py +0 -0
  46. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_rate_limit.py +0 -0
  47. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_retry.py +0 -0
  48. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_routes.py +0 -0
  49. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_strict_schema.py +0 -0
  50. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_sync.py +0 -0
  51. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/_types.py +0 -0
  52. {dot_inference-4.2.0 → dot_inference-4.4.0}/src/dot_inference/mock.py +0 -0
  53. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/__init__.py +0 -0
  54. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_constrained_live.py +0 -0
  55. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_cost_tracker.py +0 -0
  56. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_mistral_live.py +0 -0
  57. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_rate_limit.py +0 -0
  58. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_retry.py +0 -0
  59. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_routes.py +0 -0
  60. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_settings.py +0 -0
  61. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_strict_schema.py +0 -0
  62. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_sync.py +0 -0
  63. {dot_inference-4.2.0 → dot_inference-4.4.0}/tests/test_types.py +0 -0
@@ -8,6 +8,115 @@ in alpha, a minor release may contain breaking changes, each marked **Breaking**
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [4.4.0] - 2026-11-17
12
+
13
+ ### Changed
14
+
15
+ - **Breaking:** `mistral/mistral-large-4` and `mistral/mistral-large-latest`
16
+ are registered `supports_forced_tool_choice: false`, as Claude Opus 5.5 and
17
+ Sonnet 5.5 are: `tool_choice="required"` or a tool name now raises
18
+ `ValueError` before the call. Mistral accepts `"required"` on Large 4 but
19
+ does not honour it: when the model would rather answer in text, it cannot
20
+ stop, and the reply runs to `max_tokens`, or for as long as the stream lasts
21
+ when none is set. An agent loop that forces every step hits it once its
22
+ work is done. Send `"auto"` instead, and take a text reply as the answer
23
+ ([tool-choice.md](docs/provider-quirks/tool-choice.md)). Mistral Small 4 is
24
+ unchanged.
25
+
26
+ ## [4.3.0] - 2026-11-14
27
+
28
+ ### Added
29
+
30
+ - `resolve_context_window(model)`: the context window to size a model's prompts
31
+ from. For a model routed to `local`, the one its server serves
32
+ (`max_model_len`, read from vLLM and SGLang servers only); for any other, the
33
+ registry's. It raises `ValueError` when that window is not known, and does not
34
+ fall back on the registry's for a local model: the registry declares none, no
35
+ local `base_url` is set, the server does not serve the model, or it does not
36
+ report its window. `check_local_endpoint` is unchanged: its `.context_window`
37
+ stays `None` in the last two cases.
38
+ - `effective_reasoning_effort(model, settings)`: the reasoning effort a client
39
+ from `get_llm_client` sends for a model, in the same order (the call's
40
+ `reasoning_effort=`, the model's default, the settings'). `None` when no
41
+ effort is sent: none is set, or the model takes none on the provider it is
42
+ routed to. `get_llm_client` resolves the effort through it.
43
+ - Context window for `qwen/qwen3.5-9b` (262144), from OpenRouter's model list.
44
+ - Registry entries `openai/gpt-6.1-terra`, `google/gemini-4-carbon`,
45
+ `google/gemini-4-hydrogen`, `minimax/minimax-m3.1-flash` and
46
+ `qwen/qwen3.8-27b`, from OpenRouter's model list and the providers' model
47
+ pages (2026-11-14).
48
+
49
+ ### Removed
50
+
51
+ - **Breaking:** registry entries whose model is deprecated, retired, a
52
+ preview, or superseded by a newer one of the same provider. Such a name is
53
+ still sent as is, with a warning, without the registry's capabilities and
54
+ prices; a `DOTI_CUSTOM_MODELS` file can declare it again.
55
+
56
+ Prices are OpenRouter's (its model list, $ per million input / output
57
+ tokens); lifecycle dates are the providers' (2026-11-14). A small model is
58
+ replaced by the lowest-priced model of the new generation.
59
+
60
+ | Removed | $/M | Why | Instead | $/M |
61
+ | --- | --- | --- | --- | --- |
62
+ | `openai/gpt-5` | 1.25 / 10 | OpenAI shuts it down on 2026-12-11 | `openai/gpt-6.1-sol` | 2 / 10 |
63
+ | `openai/gpt-5-mini` | 0.25 / 2 | OpenAI shuts it down on 2026-12-11 (OpenAI names `gpt-6.1-terra`, 1 / 5) | `openai/gpt-6-luna` | 0.10 / 0.50 |
64
+ | `openai/gpt-5.1` | 1.25 / 10 | OpenAI shuts it down on 2027-04-01 | `openai/gpt-6.1-sol` | 2 / 10 |
65
+ | `openai/gpt-5.4-nano` | 0.20 / 1.25 | OpenAI shuts it down on 2027-04-01 | `openai/gpt-6-luna` | 0.10 / 0.50 |
66
+ | `openai/gpt-5.2` | 1.75 / 14 | not deprecated; previous generation | `openai/gpt-6.1-sol` | 2 / 10 |
67
+ | `openai/gpt-5.4` | 2.50 / 15 | not deprecated; previous generation | `openai/gpt-6.1-sol` | 2 / 10 |
68
+ | `openai/gpt-5.4-mini` | 0.75 / 4.50 | not deprecated; previous generation | `openai/gpt-6-luna` | 0.10 / 0.50 |
69
+ | `anthropic/claude-haiku-4.5` | 1 / 5 | its retirement date, "not sooner than" 2026-10-15, has passed | `anthropic/claude-haiku-5.5` | 0.10 / 0.50 |
70
+ | `anthropic/claude-sonnet-4.6` | 3 / 15 | not deprecated; previous generation | `anthropic/claude-sonnet-5.5` | 2 / 10 |
71
+ | `anthropic/claude-opus-4.6` | 5 / 25 | not deprecated; previous generation | `anthropic/claude-opus-5.5` | 4 / 20 |
72
+ | `google/gemini-3-flash` | 0.50 / 3 | a preview, to which Google's deprecations page gives a replacement | `google/gemini-3.8-flash` | 0.825 / 4.125 |
73
+ | `google/gemini-3-pro` | 2 / 12 | a preview; previous generation | `google/gemini-4-carbon` | 2 / 10 (4 / 20 from 2026-12-01) |
74
+ | `mistral/mistral-medium-3.1` | 0.40 / 2 | Mistral retired it on 2026-08-31 | `mistral/mistral-large-4` | 0.70 / 2.10 |
75
+ | `mistral/mistral-medium-3.5` | 1.50 / 7.50 | Mistral retires it on 2027-04-30, Large 4 being its alternative | `mistral/mistral-large-4` | 0.70 / 2.10 |
76
+ | `minimax/minimax-m2.7` | 0.21 / 0.84 | previous generation | `minimax/minimax-m3.1-flash` | 0.15 / 0.60 |
77
+ | `qwen/qwen3.5-27b` | 0.26 / 2.60 | previous generation | `qwen/qwen3.8-27b` | 0.15 / 1.875 |
78
+
79
+ Claude Sonnet 5.5 and Opus 5.5 reject a forced `tool_choice`, which Sonnet
80
+ 4.6 and Opus 4.6 accepted (see
81
+ [tool-choice.md](docs/provider-quirks/tool-choice.md)).
82
+
83
+ ### Changed
84
+
85
+ - **Breaking:** `mistral/mistral-large-latest` describes Mistral Large 4,
86
+ which La Plateforme now resolves it to (its model list, 2026-11-14), and no
87
+ longer Large 3: reasoning with the efforts of `mistral/mistral-large-4`,
88
+ $0.70/M input and $2.10/M output, a 1048576-token window. Its OpenRouter
89
+ route goes to `mistralai/mistral-large-4-0` in place of
90
+ `mistralai/mistral-large-2512` (Large 3, which Mistral retires on
91
+ 2027-04-30).
92
+ - **Breaking:** `mistral/mistral-small-latest` and `mistral/mistral-small-2603`
93
+ no longer set `none` as their default reasoning effort, which is also La
94
+ Plateforme's: with no effort chosen, none is sent. A settings effort
95
+ (`DOTI_GENERATION__REASONING_EFFORT`) now applies to them, and `low` or
96
+ `medium` raises `ValueError`: Mistral Small accepts only `none` and `high`.
97
+ Mistral Large 4 (and `mistral/mistral-large-latest`) keeps `medium`, for
98
+ cost: La Plateforme thinks at `high` when no effort is sent. It is now the
99
+ only model of the registry that sets a default.
100
+ - `mistral/mistral-large-4`: $0.70/M input and $2.10/M output (the launch
101
+ prices $0.68/M and $2.09/M before) and a 1048576-token window (524288
102
+ before), from Mistral's model card and model list.
103
+ - `mistral/mistral-small-latest` has a context window of 262144 (256000
104
+ before), and `mistral/mistral-small-2603` gets the same, from Mistral's model
105
+ list.
106
+ - **Breaking:** a registry entry whose `default_reasoning_effort` is not one of
107
+ its `reasoning_effort_options` raises `ValueError`, in a `DOTI_CUSTOM_MODELS`
108
+ file and in `ModelConfig`. A reasoning model's was refused only when a client
109
+ was built for it. Add the effort to the options, or change the default.
110
+ - **Breaking:** `nvidia/nemotron-3-super-120b-a12b` has a context window of
111
+ 262144, no longer 1000000: the one OpenRouter, its only provider here, serves
112
+ it with.
113
+ - Context windows given as rounded figures are now the exact ones of
114
+ OpenRouter's model list: 131072 for `openai/gpt-oss-20b`,
115
+ `openai/gpt-oss-120b` and their `-local` aliases (128000 before).
116
+ - The registry's `context_window` is documented as the figure the provider, or
117
+ the model card, declares: indicative for a self-hosted model, whose server is
118
+ started with a window of its own, smaller or larger.
119
+
11
120
  ## [4.2.0] - 2026-11-12
12
121
 
13
122
  ### Added
@@ -295,7 +404,9 @@ this release.
295
404
  - `LLMCallable` and `EmbeddingCallable` return a `Coroutine` rather than the
296
405
  looser `Awaitable`, matching what `asyncio.run_coroutine_threadsafe` accepts.
297
406
 
298
- [Unreleased]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/compare/v4.2.0...main
407
+ [Unreleased]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/compare/v4.4.0...main
408
+ [4.4.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.4.0
409
+ [4.3.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.3.0
299
410
  [4.2.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.2.0
300
411
  [4.1.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.1.0
301
412
  [4.0.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.0.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: dot-inference
3
- Version: 4.2.0
3
+ Version: 4.4.0
4
4
  Summary: Unified async Python library for LLM inference and embeddings across multiple providers
5
5
  Project-URL: Homepage, https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference
6
6
  Project-URL: Repository, https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference
@@ -93,11 +93,11 @@ nesting delimiter — or from an env file, modelled on `.env.template`:
93
93
 
94
94
  ```bash
95
95
  DOTI_GENERATION__PROVIDER=openai
96
- DOTI_GENERATION__OPENAI__MODEL_NAME=openai/gpt-5-mini
96
+ DOTI_GENERATION__OPENAI__MODEL_NAME=openai/gpt-6-luna
97
97
  DOTI_GENERATION__OPENAI__API_KEY=sk-...
98
98
  ```
99
99
 
100
- Model names are registry ids (`openai/gpt-5-mini`, whatever the provider); each
100
+ Model names are registry ids (`openai/gpt-6-luna`, whatever the provider); each
101
101
  provider is sent its own API name. A name missing from the registry is sent as
102
102
  is, with a warning, and without the registry's capabilities and prices.
103
103
 
@@ -128,13 +128,13 @@ print(response.content)
128
128
  from dot_inference import InferenceSettings, Message, Provider, Role, get_llm_client
129
129
 
130
130
  settings = InferenceSettings()
131
- client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-5-mini")
131
+ client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-6-luna")
132
132
  response = asyncio.run(client.call([Message(role=Role.USER, content="Hello!")]))
133
133
  ```
134
134
 
135
135
  ### Reasoning models
136
136
 
137
- Use `ReasoningEffort` to control thinking budget on reasoning models (e.g. `gpt-5*`, `o-series`):
137
+ Use `ReasoningEffort` to control thinking budget on reasoning models (e.g. the GPT-6 series):
138
138
 
139
139
  ```python
140
140
  from dot_inference import (
@@ -150,7 +150,7 @@ settings = InferenceSettings()
150
150
  client = get_llm_client(
151
151
  settings,
152
152
  provider=Provider.OPENAI,
153
- model="openai/gpt-5-mini",
153
+ model="openai/gpt-6-luna",
154
154
  reasoning_effort=ReasoningEffort.HIGH,
155
155
  )
156
156
  response = asyncio.run(client.call([Message(role=Role.USER, content="Solve this step by step...")]))
@@ -163,6 +163,19 @@ applies its own default. A model's registry entry may set one
163
163
  model to the next: `allowed_reasoning_efforts(model)` returns those a model
164
164
  accepts, and another one raises a `ValueError`.
165
165
 
166
+ `effective_reasoning_effort(model, settings)` returns the effort a client sends
167
+ for a model, resolved as `get_llm_client` resolves it (it takes the same
168
+ `provider=` and `reasoning_effort=`): the call's effort, else the model's
169
+ default, else the settings'. `None` means that no effort is sent, either because
170
+ none is set or because the model takes none on that provider:
171
+
172
+ ```python
173
+ from dot_inference import effective_reasoning_effort
174
+
175
+ effective_reasoning_effort("mistral/mistral-large-4", settings) # "medium", its default
176
+ effective_reasoning_effort("openai/gpt-6-luna", settings) # None, unless the settings set one
177
+ ```
178
+
166
179
  ### Structured output
167
180
 
168
181
  ```python
@@ -176,7 +189,7 @@ class Answer(BaseModel):
176
189
 
177
190
 
178
191
  settings = InferenceSettings()
179
- client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-5-mini")
192
+ client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-6-luna")
180
193
  response = asyncio.run(
181
194
  client.call(
182
195
  [Message(role=Role.USER, content="What is 2+2?")],
@@ -301,7 +314,7 @@ from dot_inference import CostTracker, InferenceSettings, Message, Provider, Rol
301
314
 
302
315
  settings = InferenceSettings()
303
316
  tracker = CostTracker()
304
- client = get_llm_client(settings, provider=Provider.OPENROUTER, model="openai/gpt-5-mini")
317
+ client = get_llm_client(settings, provider=Provider.OPENROUTER, model="openai/gpt-6-luna")
305
318
 
306
319
  response = asyncio.run(client.call([Message(role=Role.USER, content="Hi")]))
307
320
  tracker.record(response)
@@ -348,7 +361,7 @@ args = tools[0].parse_arguments(response.tool_calls[0].arguments) # WeatherArgs
348
361
 
349
362
  `parameters` is a JSON schema dict, sent as written, or a Pydantic model. A model's schema is sent, rewritten to OpenAI's strict rules when `strict=True` (for every provider: OpenAI and Claude both reject a strict tool with an open object). A call's `arguments` stays the JSON string the provider sent; `ToolDef.parse_arguments()` validates it into the model, raising `ValidationError` when it does not match.
350
363
 
351
- `strict=True` asks the server to constrain the arguments to the schema exactly; it is only sent when set, and OpenAI then imposes its own schema rules ([strict-schemas.md](docs/provider-quirks/strict-schemas.md)). Some models cannot be forced to call a tool (Claude Opus 5.5 and Sonnet 5.5): `"required"` or a tool name raises `ValueError` there ([tool-choice.md](docs/provider-quirks/tool-choice.md)). `extra_body` fields win over those the client adds itself (OpenRouter routing, `cache_control`); the Mistral client rejects `extra_body`.
364
+ `strict=True` asks the server to constrain the arguments to the schema exactly; it is only sent when set, and OpenAI then imposes its own schema rules ([strict-schemas.md](docs/provider-quirks/strict-schemas.md)). Some models cannot be forced to call a tool (Claude Opus 5.5 and Sonnet 5.5, which reject it, and Mistral Large 4, which accepts `"required"` but does not honour it): `"required"` or a tool name raises `ValueError` there ([tool-choice.md](docs/provider-quirks/tool-choice.md)). `extra_body` fields win over those the client adds itself (OpenRouter routing, `cache_control`); the Mistral client rejects `extra_body`.
352
365
 
353
366
  ## On-premise inference (vLLM, SGLang, Ollama)
354
367
 
@@ -428,16 +441,24 @@ await client.call(messages, reasoning_effort="none") # sends enable_thinking: f
428
441
  `chat_template_kwargs` passed in `extra_body` win over those of the effort, one
429
442
  variable at a time.
430
443
 
431
- The registry's `context_window` is the model's limit
432
- (`get_max_context_window(model)`). A self-hosted server is started with the
433
- window its hardware holds, often a smaller one, and vLLM and SGLang report it:
434
- `check_local_endpoint(model)` returns it as `.context_window` (`None` when the
435
- server does not say). Size prompts from that one:
444
+ The registry's `context_window` is the window the provider, or the model card,
445
+ declares for a model (`get_max_context_window(model)`). A self-hosted server is
446
+ started with a window of its own, smaller or larger, and vLLM and SGLang report
447
+ it (`max_model_len` in `GET /models`): `check_local_endpoint(model)` returns it
448
+ as `.context_window`, `None` when the server does not say.
449
+
450
+ `resolve_context_window(model)` returns the window to size prompts from: the one
451
+ the server serves for a model routed to `local`, the registry's for any other.
452
+ It raises a `ValueError` when that window is not known, and never falls back on
453
+ the registry's for a local model: the registry declares none, the server does
454
+ not serve the model, or it does not report its window. The window is read from
455
+ vLLM and SGLang servers only. It queries the local server at each call: read it
456
+ once at startup and keep it.
436
457
 
437
458
  ```python
438
- model = "nvidia/nemotron-3.5-super-vl-120b-a12b-local"
439
- check = await check_local_endpoint(model)
440
- window = (check and check.context_window) or get_max_context_window(model)
459
+ from dot_inference import resolve_context_window
460
+
461
+ window = await resolve_context_window("nvidia/nemotron-3.5-super-vl-120b-a12b-local")
441
462
  ```
442
463
 
443
464
  ## Testing without API calls
@@ -66,11 +66,11 @@ nesting delimiter — or from an env file, modelled on `.env.template`:
66
66
 
67
67
  ```bash
68
68
  DOTI_GENERATION__PROVIDER=openai
69
- DOTI_GENERATION__OPENAI__MODEL_NAME=openai/gpt-5-mini
69
+ DOTI_GENERATION__OPENAI__MODEL_NAME=openai/gpt-6-luna
70
70
  DOTI_GENERATION__OPENAI__API_KEY=sk-...
71
71
  ```
72
72
 
73
- Model names are registry ids (`openai/gpt-5-mini`, whatever the provider); each
73
+ Model names are registry ids (`openai/gpt-6-luna`, whatever the provider); each
74
74
  provider is sent its own API name. A name missing from the registry is sent as
75
75
  is, with a warning, and without the registry's capabilities and prices.
76
76
 
@@ -101,13 +101,13 @@ print(response.content)
101
101
  from dot_inference import InferenceSettings, Message, Provider, Role, get_llm_client
102
102
 
103
103
  settings = InferenceSettings()
104
- client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-5-mini")
104
+ client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-6-luna")
105
105
  response = asyncio.run(client.call([Message(role=Role.USER, content="Hello!")]))
106
106
  ```
107
107
 
108
108
  ### Reasoning models
109
109
 
110
- Use `ReasoningEffort` to control thinking budget on reasoning models (e.g. `gpt-5*`, `o-series`):
110
+ Use `ReasoningEffort` to control thinking budget on reasoning models (e.g. the GPT-6 series):
111
111
 
112
112
  ```python
113
113
  from dot_inference import (
@@ -123,7 +123,7 @@ settings = InferenceSettings()
123
123
  client = get_llm_client(
124
124
  settings,
125
125
  provider=Provider.OPENAI,
126
- model="openai/gpt-5-mini",
126
+ model="openai/gpt-6-luna",
127
127
  reasoning_effort=ReasoningEffort.HIGH,
128
128
  )
129
129
  response = asyncio.run(client.call([Message(role=Role.USER, content="Solve this step by step...")]))
@@ -136,6 +136,19 @@ applies its own default. A model's registry entry may set one
136
136
  model to the next: `allowed_reasoning_efforts(model)` returns those a model
137
137
  accepts, and another one raises a `ValueError`.
138
138
 
139
+ `effective_reasoning_effort(model, settings)` returns the effort a client sends
140
+ for a model, resolved as `get_llm_client` resolves it (it takes the same
141
+ `provider=` and `reasoning_effort=`): the call's effort, else the model's
142
+ default, else the settings'. `None` means that no effort is sent, either because
143
+ none is set or because the model takes none on that provider:
144
+
145
+ ```python
146
+ from dot_inference import effective_reasoning_effort
147
+
148
+ effective_reasoning_effort("mistral/mistral-large-4", settings) # "medium", its default
149
+ effective_reasoning_effort("openai/gpt-6-luna", settings) # None, unless the settings set one
150
+ ```
151
+
139
152
  ### Structured output
140
153
 
141
154
  ```python
@@ -149,7 +162,7 @@ class Answer(BaseModel):
149
162
 
150
163
 
151
164
  settings = InferenceSettings()
152
- client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-5-mini")
165
+ client = get_llm_client(settings, provider=Provider.OPENAI, model="openai/gpt-6-luna")
153
166
  response = asyncio.run(
154
167
  client.call(
155
168
  [Message(role=Role.USER, content="What is 2+2?")],
@@ -274,7 +287,7 @@ from dot_inference import CostTracker, InferenceSettings, Message, Provider, Rol
274
287
 
275
288
  settings = InferenceSettings()
276
289
  tracker = CostTracker()
277
- client = get_llm_client(settings, provider=Provider.OPENROUTER, model="openai/gpt-5-mini")
290
+ client = get_llm_client(settings, provider=Provider.OPENROUTER, model="openai/gpt-6-luna")
278
291
 
279
292
  response = asyncio.run(client.call([Message(role=Role.USER, content="Hi")]))
280
293
  tracker.record(response)
@@ -321,7 +334,7 @@ args = tools[0].parse_arguments(response.tool_calls[0].arguments) # WeatherArgs
321
334
 
322
335
  `parameters` is a JSON schema dict, sent as written, or a Pydantic model. A model's schema is sent, rewritten to OpenAI's strict rules when `strict=True` (for every provider: OpenAI and Claude both reject a strict tool with an open object). A call's `arguments` stays the JSON string the provider sent; `ToolDef.parse_arguments()` validates it into the model, raising `ValidationError` when it does not match.
323
336
 
324
- `strict=True` asks the server to constrain the arguments to the schema exactly; it is only sent when set, and OpenAI then imposes its own schema rules ([strict-schemas.md](docs/provider-quirks/strict-schemas.md)). Some models cannot be forced to call a tool (Claude Opus 5.5 and Sonnet 5.5): `"required"` or a tool name raises `ValueError` there ([tool-choice.md](docs/provider-quirks/tool-choice.md)). `extra_body` fields win over those the client adds itself (OpenRouter routing, `cache_control`); the Mistral client rejects `extra_body`.
337
+ `strict=True` asks the server to constrain the arguments to the schema exactly; it is only sent when set, and OpenAI then imposes its own schema rules ([strict-schemas.md](docs/provider-quirks/strict-schemas.md)). Some models cannot be forced to call a tool (Claude Opus 5.5 and Sonnet 5.5, which reject it, and Mistral Large 4, which accepts `"required"` but does not honour it): `"required"` or a tool name raises `ValueError` there ([tool-choice.md](docs/provider-quirks/tool-choice.md)). `extra_body` fields win over those the client adds itself (OpenRouter routing, `cache_control`); the Mistral client rejects `extra_body`.
325
338
 
326
339
  ## On-premise inference (vLLM, SGLang, Ollama)
327
340
 
@@ -401,16 +414,24 @@ await client.call(messages, reasoning_effort="none") # sends enable_thinking: f
401
414
  `chat_template_kwargs` passed in `extra_body` win over those of the effort, one
402
415
  variable at a time.
403
416
 
404
- The registry's `context_window` is the model's limit
405
- (`get_max_context_window(model)`). A self-hosted server is started with the
406
- window its hardware holds, often a smaller one, and vLLM and SGLang report it:
407
- `check_local_endpoint(model)` returns it as `.context_window` (`None` when the
408
- server does not say). Size prompts from that one:
417
+ The registry's `context_window` is the window the provider, or the model card,
418
+ declares for a model (`get_max_context_window(model)`). A self-hosted server is
419
+ started with a window of its own, smaller or larger, and vLLM and SGLang report
420
+ it (`max_model_len` in `GET /models`): `check_local_endpoint(model)` returns it
421
+ as `.context_window`, `None` when the server does not say.
422
+
423
+ `resolve_context_window(model)` returns the window to size prompts from: the one
424
+ the server serves for a model routed to `local`, the registry's for any other.
425
+ It raises a `ValueError` when that window is not known, and never falls back on
426
+ the registry's for a local model: the registry declares none, the server does
427
+ not serve the model, or it does not report its window. The window is read from
428
+ vLLM and SGLang servers only. It queries the local server at each call: read it
429
+ once at startup and keep it.
409
430
 
410
431
  ```python
411
- model = "nvidia/nemotron-3.5-super-vl-120b-a12b-local"
412
- check = await check_local_endpoint(model)
413
- window = (check and check.context_window) or get_max_context_window(model)
432
+ from dot_inference import resolve_context_window
433
+
434
+ window = await resolve_context_window("nvidia/nemotron-3.5-super-vl-120b-a12b-local")
414
435
  ```
415
436
 
416
437
  ## Testing without API calls
@@ -74,7 +74,7 @@ How environment variables, settings, and the model registry connect to produce a
74
74
  flowchart TB
75
75
  subgraph CONFIG ["Configuration (one-time setup)"]
76
76
  direction TB
77
- ENV[".env file or environment variables<br/>─────────────────────────<br/>DOTI_GENERATION__PROVIDER=openrouter<br/>DOTI_GENERATION__OPENROUTER__API_KEY=sk-or-...<br/>DOTI_GENERATION__OPENROUTER__MODEL_NAME=openai/gpt-5-mini<br/>DOTI_EMBEDDING__PROVIDER=openai<br/>DOTI_EMBEDDING__OPENAI__API_KEY=sk-..."]
77
+ ENV[".env file or environment variables<br/>─────────────────────────<br/>DOTI_GENERATION__PROVIDER=openrouter<br/>DOTI_GENERATION__OPENROUTER__API_KEY=sk-or-...<br/>DOTI_GENERATION__OPENROUTER__MODEL_NAME=openai/gpt-6-luna<br/>DOTI_EMBEDDING__PROVIDER=openai<br/>DOTI_EMBEDDING__OPENAI__API_KEY=sk-..."]
78
78
  SETTINGS["InferenceSettings()<br/>─────────────────────────<br/>pydantic-settings reads DOTI_* env vars<br/>and populates nested config objects<br/>(GenerationSettings + EmbeddingsSettings)"]
79
79
  ENV -->|"parsed by pydantic-settings<br/>(prefix=DOTI_, delimiter=__)"| SETTINGS
80
80
  end
@@ -135,7 +135,7 @@ sequenceDiagram
135
135
  App->>Factory: get_llm_client(settings)
136
136
  Factory->>Settings: Read generation.provider → "openrouter"
137
137
  Factory->>Settings: Read generation.openrouter → api_key, model_name
138
- Factory->>Registry: resolve_model_config("openai/gpt-5-mini", "openrouter")
138
+ Factory->>Registry: resolve_model_config("openai/gpt-6-luna", "openrouter")
139
139
  Registry->>Registry: Load models.yaml (+ custom YAML if set)
140
140
  Registry->>Registry: Find model → resolve for provider
141
141
  Registry-->>Factory: ResolvedModelConfig (api name, costs, capabilities)
@@ -55,7 +55,9 @@ What do you call a fake noodle? An impasta. 🍝😄 … Want another one? 😄
55
55
  `mistral-medium-3.1`, `mistral-medium-3.5`, `mistral-large-4`, with or without
56
56
  `reasoning_effort`, on the Mistral API (and through OpenRouter for the three
57
57
  that could be checked there: Medium 3.1, Medium 3.5, Large 4).
58
- `mistral-large-latest` (Large 3) is not. Also reported for the Magistral models
58
+ Large 3 (`mistral-large-2512`), which `mistral-large-latest` resolved to when
59
+ measured, is not; the alias now resolves to Large 4 (Mistral's model list,
60
+ 2026-11-14), which is. Also reported for the Magistral models
59
61
  in [mistralai/client-python#419](https://github.com/mistralai/client-python/issues/419)
60
62
  (open since 2026-03-11, no answer from Mistral).
61
63
 
@@ -94,13 +96,22 @@ calls for a tool is fine. It fails where forcing is the point:
94
96
 
95
97
  - a user message unrelated to the tools (a greeting, a thank-you, a general
96
98
  question);
97
- - an agent loop that keeps `"required"` after tool results, when the model
98
- would rather answer (not tested);
99
+ - an agent loop that keeps `"required"` after tool results, once the model
100
+ would rather answer (seen on Large 4, below);
99
101
  - a "final answer" tool forced to get a structured reply.
100
102
 
101
103
  A failed call costs the whole `max_tokens` (dot-inference sets no default) and
102
104
  comes back with no `tool_calls` and `finish_reason` `"length"` or `"error"`.
103
105
 
106
+ **In an agent loop.** Seen in production on Large 4 (Mistral API, 2026-11-16
107
+ and 17), in an agent that sends `"required"` at every step and no
108
+ `max_tokens`: once its tool calls were done, the model wrote its conclusion as
109
+ text instead of calling the tool that concludes, and kept writing. About 2.5%
110
+ of the calls ran away, for minutes up to most of an hour each, and ended with
111
+ `finish_reason` `"length"` (262,144 tokens), `"error"`, or a stream closed
112
+ with no finish reason. The same agent sending `"auto"`, and taking a text
113
+ reply as its answer, made 193 calls to Large 4 with none over 75 s.
114
+
104
115
  **A tool name stops working with `strict`.** Without `strict`, naming the tool
105
116
  forced a call every time on every model. With `ToolDef(strict=True)`, it fails
106
117
  the same way on Medium 3.1 (3/5), Medium 3.5 (4/5) and Large 4 (1/5, and 2/3
@@ -108,12 +119,19 @@ in an earlier run); Small 4 and Large 3 still call 5/5. Tokyo prompt, five runs
108
119
  each, 2026-10-27. On those three models, a forced call and strict arguments
109
120
  cannot be had together.
110
121
 
122
+ **What dot-inference does.** The registry marks Large 4 and
123
+ `mistral-large-latest` `supports_forced_tool_choice: false`, as it does Claude
124
+ Opus 5.5 and Sonnet 5.5: `"required"` or a tool name raises `ValueError`
125
+ before the call. A tool name without `strict` would still hold on Large 4, but
126
+ the flag does not tell the two apart. Small 4 stays forceable: a tool name
127
+ holds there, `strict` or not.
128
+
111
129
  **What to do on these models:**
112
130
 
113
- 1. One tool: pass its name, not `"required"`, and leave `strict` off on Medium
114
- 3.1, Medium 3.5 and Large 4.
115
- 2. Several tools: `"auto"` with a clear instruction in the prompt is as
116
- reliable, without the runaway reply.
131
+ 1. One tool, on Small 4: pass its name, not `"required"`.
132
+ 2. Several tools, or Large 4: `"auto"` with a clear instruction in the prompt
133
+ is as reliable, without the runaway reply. In an agent loop, take a text
134
+ reply as the answer.
117
135
  3. Always set `max_tokens`, to cap the cost of a miss.
118
136
 
119
137
  Two runs per cell and four prompts show a trend, not a rate: test the requests
@@ -87,12 +87,12 @@ async def demo_openrouter_basic():
87
87
  client = get_llm_client(
88
88
  settings,
89
89
  provider=Provider.OPENROUTER,
90
- model="openai/gpt-5-mini",
90
+ model="openai/gpt-6-luna",
91
91
  reasoning_effort=effort,
92
92
  )
93
93
  response = await client.call(prompt)
94
94
  print(
95
- f"[gpt-5-mini {effort:>6}] {response.completion_tokens:>4} tokens, ${response.cost:.6f} | {response.content}"
95
+ f"[gpt-6-luna {effort:>6}] {response.completion_tokens:>4} tokens, ${response.cost:.6f} | {response.content}"
96
96
  )
97
97
 
98
98
 
@@ -164,7 +164,7 @@ async def demo_openrouter_streaming():
164
164
  client = get_llm_client(
165
165
  settings,
166
166
  provider=Provider.OPENROUTER,
167
- model="openai/gpt-5-mini",
167
+ model="openai/gpt-6-luna",
168
168
  reasoning_effort="low",
169
169
  )
170
170
 
@@ -319,7 +319,7 @@ def demo_model_registry():
319
319
  for m in models:
320
320
  print(f" - {m}")
321
321
 
322
- config = get_model_config("openai/gpt-5-mini", "openrouter")
322
+ config = get_model_config("openai/gpt-6-luna", "openrouter")
323
323
  print(f"\nModel ID: {config.model_id}")
324
324
  print(f"API model: {config.api_model_name}")
325
325
  print(f"Provider: {config.provider}")
@@ -328,7 +328,7 @@ def demo_model_registry():
328
328
  print(f"Strict JSON: {config.supports_strict_json}")
329
329
  print(f"Reasoning: {config.supports_reasoning}")
330
330
 
331
- config = get_model_config("openai/gpt-5-mini", "openai")
331
+ config = get_model_config("openai/gpt-6-luna", "openai")
332
332
  print(f"\nModel ID: {config.model_id}")
333
333
  print(f"API model: {config.api_model_name}")
334
334
  print(f"Provider: {config.provider}")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dot-inference"
3
- version = "4.2.0"
3
+ version = "4.4.0"
4
4
  description = "Unified async Python library for LLM inference and embeddings across multiple providers"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Kannon For Deep Tech", email = "louis.letarnec@deepika.ai" }]
@@ -31,7 +31,7 @@ Configuration is driven by `pydantic-settings` and environment variables prefixe
31
31
 
32
32
  ```bash
33
33
  DOTI_GENERATION__PROVIDER=openrouter
34
- DOTI_GENERATION__OPENROUTER__MODEL_NAME=openai/gpt-5-mini
34
+ DOTI_GENERATION__OPENROUTER__MODEL_NAME=openai/gpt-6-luna
35
35
  DOTI_GENERATION__OPENROUTER__API_KEY=sk-or-...
36
36
  DOTI_GENERATION__MISTRAL__MODEL_NAME=mistral-small-latest
37
37
  DOTI_GENERATION__MISTRAL__API_KEY=...
@@ -78,6 +78,6 @@ For explicit provider selection:
78
78
  from dot_inference import InferenceSettings, Provider, get_llm_client
79
79
 
80
80
  settings = InferenceSettings()
81
- client = get_llm_client(settings, provider=Provider.OPENROUTER, model="openai/gpt-5-mini")
81
+ client = get_llm_client(settings, provider=Provider.OPENROUTER, model="openai/gpt-6-luna")
82
82
  response = await client.call([{"role": "user", "content": "Hello!"}])
83
83
  ```
@@ -1,9 +1,11 @@
1
1
  from dot_inference._client import (
2
2
  EmbeddingClient,
3
3
  LLMClient,
4
+ effective_reasoning_effort,
4
5
  get_embedding_client,
5
6
  get_llm_client,
6
7
  )
8
+ from dot_inference._context_window import resolve_context_window
7
9
  from dot_inference._cost_tracker import CostTracker, compute_cost
8
10
  from dot_inference._llm_registry import (
9
11
  ModelConfig,
@@ -88,6 +90,7 @@ __all__ = [
88
90
  "check_local_endpoint",
89
91
  "compute_cost",
90
92
  "default_reasoning_effort",
93
+ "effective_reasoning_effort",
91
94
  "get_context_window",
92
95
  "get_embedding_client",
93
96
  "get_llm_client",
@@ -99,6 +102,7 @@ __all__ = [
99
102
  "list_served_models",
100
103
  "make_sync",
101
104
  "register_model",
105
+ "resolve_context_window",
102
106
  "resolve_embedding_route",
103
107
  "resolve_llm_route",
104
108
  "resolve_model_config",