dot-inference 4.2.0__tar.gz → 4.3.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.3.0}/CHANGELOG.md +96 -1
  2. {dot_inference-4.2.0 → dot_inference-4.3.0}/PKG-INFO +37 -16
  3. {dot_inference-4.2.0 → dot_inference-4.3.0}/README.md +36 -15
  4. {dot_inference-4.2.0 → dot_inference-4.3.0}/docs/ARCHITECTURE.md +2 -2
  5. {dot_inference-4.2.0 → dot_inference-4.3.0}/docs/provider-quirks/tool-choice.md +3 -1
  6. {dot_inference-4.2.0 → dot_inference-4.3.0}/examples/demo.py +5 -5
  7. {dot_inference-4.2.0 → dot_inference-4.3.0}/pyproject.toml +1 -1
  8. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/README.md +2 -2
  9. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/__init__.py +4 -0
  10. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_client.py +49 -26
  11. dot_inference-4.3.0/src/dot_inference/_context_window.py +58 -0
  12. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_llm_registry.py +18 -10
  13. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_local_check.py +50 -3
  14. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_mistral_compat.py +2 -2
  15. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/models.yaml +116 -284
  16. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/settings.py +3 -3
  17. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_factories.py +104 -12
  18. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_images.py +1 -1
  19. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_llm_registry.py +58 -34
  20. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_local_check.py +68 -0
  21. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_mistral_compat.py +3 -3
  22. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_openai_compat.py +10 -10
  23. {dot_inference-4.2.0 → dot_inference-4.3.0}/uv.lock +1 -1
  24. {dot_inference-4.2.0 → dot_inference-4.3.0}/.env.template +0 -0
  25. {dot_inference-4.2.0 → dot_inference-4.3.0}/.gitignore +0 -0
  26. {dot_inference-4.2.0 → dot_inference-4.3.0}/.gitlab-ci.yml +0 -0
  27. {dot_inference-4.2.0 → dot_inference-4.3.0}/.pre-commit-config.yaml +0 -0
  28. {dot_inference-4.2.0 → dot_inference-4.3.0}/.python-version +0 -0
  29. {dot_inference-4.2.0 → dot_inference-4.3.0}/AUTHORS.md +0 -0
  30. {dot_inference-4.2.0 → dot_inference-4.3.0}/CONTRIBUTING.md +0 -0
  31. {dot_inference-4.2.0 → dot_inference-4.3.0}/LICENSE.md +0 -0
  32. {dot_inference-4.2.0 → dot_inference-4.3.0}/docs/DEVELOPMENT.md +0 -0
  33. {dot_inference-4.2.0 → dot_inference-4.3.0}/docs/PUBLISHING.md +0 -0
  34. {dot_inference-4.2.0 → dot_inference-4.3.0}/docs/VERSIONING.md +0 -0
  35. {dot_inference-4.2.0 → dot_inference-4.3.0}/docs/provider-quirks/openrouter-errors.md +0 -0
  36. {dot_inference-4.2.0 → dot_inference-4.3.0}/docs/provider-quirks/strict-schemas.md +0 -0
  37. {dot_inference-4.2.0 → dot_inference-4.3.0}/examples/demo_streaming.py +0 -0
  38. {dot_inference-4.2.0 → dot_inference-4.3.0}/examples/doc_stream.md +0 -0
  39. {dot_inference-4.2.0 → dot_inference-4.3.0}/scripts/provider-quirks/tool-choice/mistral_compare.sh +0 -0
  40. {dot_inference-4.2.0 → dot_inference-4.3.0}/scripts/provider-quirks/tool-choice/mistral_runaway.sh +0 -0
  41. {dot_inference-4.2.0 → dot_inference-4.3.0}/scripts/provider-quirks/tool-choice/openrouter_compare.sh +0 -0
  42. {dot_inference-4.2.0 → dot_inference-4.3.0}/scripts/provider-quirks/tool-choice/openrouter_runaway.sh +0 -0
  43. {dot_inference-4.2.0 → dot_inference-4.3.0}/scripts/test_all_models.py +0 -0
  44. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_cost_tracker.py +0 -0
  45. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_openai_compat.py +0 -0
  46. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_rate_limit.py +0 -0
  47. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_retry.py +0 -0
  48. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_routes.py +0 -0
  49. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_strict_schema.py +0 -0
  50. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_sync.py +0 -0
  51. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/_types.py +0 -0
  52. {dot_inference-4.2.0 → dot_inference-4.3.0}/src/dot_inference/mock.py +0 -0
  53. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/__init__.py +0 -0
  54. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_constrained_live.py +0 -0
  55. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_cost_tracker.py +0 -0
  56. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_mistral_live.py +0 -0
  57. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_rate_limit.py +0 -0
  58. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_retry.py +0 -0
  59. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_routes.py +0 -0
  60. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_settings.py +0 -0
  61. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_strict_schema.py +0 -0
  62. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_sync.py +0 -0
  63. {dot_inference-4.2.0 → dot_inference-4.3.0}/tests/test_types.py +0 -0
@@ -8,6 +8,100 @@ in alpha, a minor release may contain breaking changes, each marked **Breaking**
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [4.3.0] - 2026-11-14
12
+
13
+ ### Added
14
+
15
+ - `resolve_context_window(model)`: the context window to size a model's prompts
16
+ from. For a model routed to `local`, the one its server serves
17
+ (`max_model_len`, read from vLLM and SGLang servers only); for any other, the
18
+ registry's. It raises `ValueError` when that window is not known, and does not
19
+ fall back on the registry's for a local model: the registry declares none, no
20
+ local `base_url` is set, the server does not serve the model, or it does not
21
+ report its window. `check_local_endpoint` is unchanged: its `.context_window`
22
+ stays `None` in the last two cases.
23
+ - `effective_reasoning_effort(model, settings)`: the reasoning effort a client
24
+ from `get_llm_client` sends for a model, in the same order (the call's
25
+ `reasoning_effort=`, the model's default, the settings'). `None` when no
26
+ effort is sent: none is set, or the model takes none on the provider it is
27
+ routed to. `get_llm_client` resolves the effort through it.
28
+ - Context window for `qwen/qwen3.5-9b` (262144), from OpenRouter's model list.
29
+ - Registry entries `openai/gpt-6.1-terra`, `google/gemini-4-carbon`,
30
+ `google/gemini-4-hydrogen`, `minimax/minimax-m3.1-flash` and
31
+ `qwen/qwen3.8-27b`, from OpenRouter's model list and the providers' model
32
+ pages (2026-11-14).
33
+
34
+ ### Removed
35
+
36
+ - **Breaking:** registry entries whose model is deprecated, retired, a
37
+ preview, or superseded by a newer one of the same provider. Such a name is
38
+ still sent as is, with a warning, without the registry's capabilities and
39
+ prices; a `DOTI_CUSTOM_MODELS` file can declare it again.
40
+
41
+ Prices are OpenRouter's (its model list, $ per million input / output
42
+ tokens); lifecycle dates are the providers' (2026-11-14). A small model is
43
+ replaced by the lowest-priced model of the new generation.
44
+
45
+ | Removed | $/M | Why | Instead | $/M |
46
+ | --- | --- | --- | --- | --- |
47
+ | `openai/gpt-5` | 1.25 / 10 | OpenAI shuts it down on 2026-12-11 | `openai/gpt-6.1-sol` | 2 / 10 |
48
+ | `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 |
49
+ | `openai/gpt-5.1` | 1.25 / 10 | OpenAI shuts it down on 2027-04-01 | `openai/gpt-6.1-sol` | 2 / 10 |
50
+ | `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 |
51
+ | `openai/gpt-5.2` | 1.75 / 14 | not deprecated; previous generation | `openai/gpt-6.1-sol` | 2 / 10 |
52
+ | `openai/gpt-5.4` | 2.50 / 15 | not deprecated; previous generation | `openai/gpt-6.1-sol` | 2 / 10 |
53
+ | `openai/gpt-5.4-mini` | 0.75 / 4.50 | not deprecated; previous generation | `openai/gpt-6-luna` | 0.10 / 0.50 |
54
+ | `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 |
55
+ | `anthropic/claude-sonnet-4.6` | 3 / 15 | not deprecated; previous generation | `anthropic/claude-sonnet-5.5` | 2 / 10 |
56
+ | `anthropic/claude-opus-4.6` | 5 / 25 | not deprecated; previous generation | `anthropic/claude-opus-5.5` | 4 / 20 |
57
+ | `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 |
58
+ | `google/gemini-3-pro` | 2 / 12 | a preview; previous generation | `google/gemini-4-carbon` | 2 / 10 (4 / 20 from 2026-12-01) |
59
+ | `mistral/mistral-medium-3.1` | 0.40 / 2 | Mistral retired it on 2026-08-31 | `mistral/mistral-large-4` | 0.70 / 2.10 |
60
+ | `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 |
61
+ | `minimax/minimax-m2.7` | 0.21 / 0.84 | previous generation | `minimax/minimax-m3.1-flash` | 0.15 / 0.60 |
62
+ | `qwen/qwen3.5-27b` | 0.26 / 2.60 | previous generation | `qwen/qwen3.8-27b` | 0.15 / 1.875 |
63
+
64
+ Claude Sonnet 5.5 and Opus 5.5 reject a forced `tool_choice`, which Sonnet
65
+ 4.6 and Opus 4.6 accepted (see
66
+ [tool-choice.md](docs/provider-quirks/tool-choice.md)).
67
+
68
+ ### Changed
69
+
70
+ - **Breaking:** `mistral/mistral-large-latest` describes Mistral Large 4,
71
+ which La Plateforme now resolves it to (its model list, 2026-11-14), and no
72
+ longer Large 3: reasoning with the efforts of `mistral/mistral-large-4`,
73
+ $0.70/M input and $2.10/M output, a 1048576-token window. Its OpenRouter
74
+ route goes to `mistralai/mistral-large-4-0` in place of
75
+ `mistralai/mistral-large-2512` (Large 3, which Mistral retires on
76
+ 2027-04-30).
77
+ - **Breaking:** `mistral/mistral-small-latest` and `mistral/mistral-small-2603`
78
+ no longer set `none` as their default reasoning effort, which is also La
79
+ Plateforme's: with no effort chosen, none is sent. A settings effort
80
+ (`DOTI_GENERATION__REASONING_EFFORT`) now applies to them, and `low` or
81
+ `medium` raises `ValueError`: Mistral Small accepts only `none` and `high`.
82
+ Mistral Large 4 (and `mistral/mistral-large-latest`) keeps `medium`, for
83
+ cost: La Plateforme thinks at `high` when no effort is sent. It is now the
84
+ only model of the registry that sets a default.
85
+ - `mistral/mistral-large-4`: $0.70/M input and $2.10/M output (the launch
86
+ prices $0.68/M and $2.09/M before) and a 1048576-token window (524288
87
+ before), from Mistral's model card and model list.
88
+ - `mistral/mistral-small-latest` has a context window of 262144 (256000
89
+ before), and `mistral/mistral-small-2603` gets the same, from Mistral's model
90
+ list.
91
+ - **Breaking:** a registry entry whose `default_reasoning_effort` is not one of
92
+ its `reasoning_effort_options` raises `ValueError`, in a `DOTI_CUSTOM_MODELS`
93
+ file and in `ModelConfig`. A reasoning model's was refused only when a client
94
+ was built for it. Add the effort to the options, or change the default.
95
+ - **Breaking:** `nvidia/nemotron-3-super-120b-a12b` has a context window of
96
+ 262144, no longer 1000000: the one OpenRouter, its only provider here, serves
97
+ it with.
98
+ - Context windows given as rounded figures are now the exact ones of
99
+ OpenRouter's model list: 131072 for `openai/gpt-oss-20b`,
100
+ `openai/gpt-oss-120b` and their `-local` aliases (128000 before).
101
+ - The registry's `context_window` is documented as the figure the provider, or
102
+ the model card, declares: indicative for a self-hosted model, whose server is
103
+ started with a window of its own, smaller or larger.
104
+
11
105
  ## [4.2.0] - 2026-11-12
12
106
 
13
107
  ### Added
@@ -295,7 +389,8 @@ this release.
295
389
  - `LLMCallable` and `EmbeddingCallable` return a `Coroutine` rather than the
296
390
  looser `Awaitable`, matching what `asyncio.run_coroutine_threadsafe` accepts.
297
391
 
298
- [Unreleased]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/compare/v4.2.0...main
392
+ [Unreleased]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/compare/v4.3.0...main
393
+ [4.3.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.3.0
299
394
  [4.2.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.2.0
300
395
  [4.1.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.1.0
301
396
  [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.3.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)
@@ -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)
@@ -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
 
@@ -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.3.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",
@@ -336,7 +336,7 @@ class LLMClient(ABC):
336
336
  """Return per-call override or instance default, validated for the model.
337
337
 
338
338
  Covers the per-call path (``call``/``stream`` with ``reasoning_effort=``)
339
- that bypasses the construction-time check in ``_warn_compatibility``.
339
+ that bypasses the construction-time check in ``effective_reasoning_effort``.
340
340
  """
341
341
  resolved = self._reasoning_effort if reasoning_effort is None else reasoning_effort
342
342
  if self._model_config is not None:
@@ -429,22 +429,59 @@ def _validate_reasoning_effort_for_model(
429
429
  )
430
430
 
431
431
 
432
+ def effective_reasoning_effort(
433
+ model: str,
434
+ settings: InferenceSettings | None = None,
435
+ *,
436
+ provider: Provider | None = None,
437
+ reasoning_effort: str | None = None,
438
+ ) -> str | None:
439
+ """The reasoning effort a client from :func:`get_llm_client` sends for *model*.
440
+
441
+ In order: *reasoning_effort* (the one passed to :func:`get_llm_client`),
442
+ the model's ``default_reasoning_effort``, then
443
+ ``GenerationSettings.reasoning_effort``. ``None`` means that no effort is
444
+ sent, and that the provider, or the local server, applies its own: none of
445
+ the three is set, or the model takes no effort on the provider it is routed
446
+ to (*provider* winning, as in :func:`get_llm_client`), because it is not a
447
+ reasoning model there or because the registry does not know it.
448
+
449
+ Raises ``ValueError`` for an effort the model does not accept, and for a
450
+ route pinned by another registry entry (:func:`resolve_llm_route`).
451
+ """
452
+ settings = settings or InferenceSettings()
453
+ route = resolve_llm_route(model, settings, provider=provider)
454
+ effort: str | None = reasoning_effort
455
+ if effort is None:
456
+ effort = default_reasoning_effort(model) or settings.generation.reasoning_effort
457
+ if effort is None:
458
+ return None
459
+ valid_efforts = {e.value for e in ReasoningEffort}
460
+ if effort not in valid_efforts:
461
+ raise ValueError(
462
+ f"Invalid reasoning_effort '{effort}'. "
463
+ f"Valid values: {', '.join(sorted(valid_efforts))}."
464
+ )
465
+ config = resolve_model_config(model, route.provider.value)
466
+ if config is None or not config.supports_reasoning:
467
+ return None
468
+ # A reasoning model may accept only a subset of the global ladder (Mistral
469
+ # Small 4 takes only [none, high]). Reject an out-of-range value with
470
+ # the choices valid for *this* model rather than letting the provider API
471
+ # fail opaquely. The per-call path is covered separately in
472
+ # LLMClient._resolve_reasoning_effort.
473
+ _validate_reasoning_effort_for_model(model, effort, config.supports_reasoning)
474
+ return str(effort)
475
+
476
+
432
477
  def _warn_compatibility(
433
478
  *,
434
479
  model: str,
435
480
  provider: Provider,
436
481
  temperature: float | None,
437
- reasoning_effort: str | None,
438
482
  ) -> None:
439
483
  """Emit warnings when user settings are incompatible with the chosen model."""
440
484
 
441
- _valid_efforts = {e.value for e in ReasoningEffort}
442
- if reasoning_effort is not None and reasoning_effort not in _valid_efforts:
443
- raise ValueError(
444
- f"Invalid reasoning_effort '{reasoning_effort}'. "
445
- f"Valid values: {', '.join(sorted(_valid_efforts))}."
446
- )
447
-
448
485
  config = resolve_model_config(model, provider.value)
449
486
 
450
487
  if config is None:
@@ -458,13 +495,6 @@ def _warn_compatibility(
458
495
  )
459
496
  return # Can't check further without registry info.
460
497
 
461
- # Per-model effort validation: a reasoning model may accept only a subset
462
- # of the global ladder (Mistral Medium 3.5 takes only [none, high]). Reject
463
- # an out-of-range value with the choices valid for *this* model rather than
464
- # letting the provider API fail opaquely. The per-call path is covered
465
- # separately in LLMClient._resolve_reasoning_effort.
466
- _validate_reasoning_effort_for_model(model, reasoning_effort, config.supports_reasoning)
467
-
468
498
  if not config.supports_temperature and temperature is not None:
469
499
  logger.warning(
470
500
  "Model '%s' does not accept a temperature — the temperature setting "
@@ -514,15 +544,9 @@ def get_llm_client(
514
544
  # request (see _routes.py for why).
515
545
  resolve_llm_route(resolved_model, settings, provider=resolved_provider)
516
546
  resolved_temperature = gen_settings.temperature if temperature is None else temperature
517
- # Precedence: explicit call arg > the model's declared default > global
518
- # default (none unless the settings give one). With none of the three, no
519
- # effort is sent: the provider, or the local server, applies its own.
520
- if reasoning_effort is not None:
521
- resolved_reasoning_effort = reasoning_effort
522
- else:
523
- resolved_reasoning_effort = (
524
- default_reasoning_effort(resolved_model) or gen_settings.reasoning_effort
525
- )
547
+ resolved_reasoning_effort = effective_reasoning_effort(
548
+ resolved_model, settings, provider=resolved_provider, reasoning_effort=reasoning_effort
549
+ )
526
550
  resolved_max_tokens = gen_settings.max_tokens if max_tokens is None else max_tokens
527
551
  resolved_timeout = gen_settings.timeout
528
552
  retry_kwargs: dict[str, Any] = {} if max_attempts is None else {"max_attempts": max_attempts}
@@ -531,7 +555,6 @@ def get_llm_client(
531
555
  model=resolved_model,
532
556
  provider=resolved_provider,
533
557
  temperature=resolved_temperature,
534
- reasoning_effort=resolved_reasoning_effort,
535
558
  )
536
559
 
537
560
  match resolved_provider:
@@ -0,0 +1,58 @@
1
+ """The context window to size a model's prompts from.
2
+
3
+ Two sources, by the route of the model: the server, for a model routed to the
4
+ ``local`` provider (``_local_check.py``); the registry, for any other
5
+ (``_llm_registry.py``).
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import httpx
11
+
12
+ from dot_inference._llm_registry import get_max_context_window
13
+ from dot_inference._local_check import _served_context_window
14
+ from dot_inference._routes import resolve_llm_route
15
+ from dot_inference.settings import InferenceSettings, Provider
16
+
17
+
18
+ async def resolve_context_window(
19
+ model_id: str,
20
+ *,
21
+ provider: Provider | None = None,
22
+ settings: InferenceSettings | None = None,
23
+ timeout: float = 3.0,
24
+ transport: httpx.AsyncBaseTransport | None = None,
25
+ ) -> int:
26
+ """The context window to size the prompts of *model_id* from, in tokens.
27
+
28
+ For a model routed to the ``local`` provider (the route resolved as
29
+ :func:`get_llm_client` resolves it, *provider* winning as there), the
30
+ window its server serves it with, read as :func:`check_local_endpoint`
31
+ reads it. For any other, the one the registry declares
32
+ (:func:`get_max_context_window`).
33
+
34
+ Raises ``ValueError`` when the window is not known, rather than falling
35
+ back on another: the registry declares none for the model, no local
36
+ ``base_url`` is configured, the local server does not serve the model, or
37
+ it serves it without reporting its window. Network failures propagate as
38
+ ``httpx`` exceptions.
39
+
40
+ The local server is queried at each call: read the window once, when the
41
+ application starts, and keep it.
42
+
43
+ *transport* is a test seam (``httpx.MockTransport``).
44
+ """
45
+ settings = settings or InferenceSettings()
46
+ route = resolve_llm_route(model_id, settings, provider=provider)
47
+ if route.provider is Provider.LOCAL:
48
+ return await _served_context_window(
49
+ route, settings.generation.local.base_url, timeout, transport
50
+ )
51
+ window = get_max_context_window(model_id)
52
+ if window is None:
53
+ raise ValueError(
54
+ f"No context window is known for model '{model_id}': the registry "
55
+ "declares none (context_window). Declare it in a custom models file "
56
+ "(DOTI_CUSTOM_MODELS) or with register_model()."
57
+ )
58
+ return window