ctxlen 2026.10.11.dev3__tar.gz → 2026.10.12.dev1__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.
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: ctxlen
3
+ Version: 2026.10.12.dev1
4
+ Summary: The context limits of any LLM: always fresh, works offline, three functions
5
+ Keywords: llm,litellm,context window,tokens,models.dev
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Typing :: Typed
10
+ Requires-Dist: httpx>=0.28,<1
11
+ Requires-Dist: certifi
12
+ Requires-Python: >=3.9
13
+ Project-URL: Repository, https://github.com/michaeltheologitis/ctxlen
14
+ Description-Content-Type: text/markdown
15
+
16
+ # ctxlen 📏
17
+
18
+ A super minimal, always-fresh, project to look up the context limits (input and output tokens) of LLMs. 🤔
19
+
20
+ - 🔄 New models checked every 6 hours, and your install picks them up within the hour: no upgrade needed.
21
+ - 🪶 Just httpx and certifi as dependencies, and it still works offline, with the numbers it shipped with.
22
+ - 🧰 Just three functions.
23
+
24
+ ## Install
25
+
26
+ ```shell
27
+ uv add ctxlen
28
+ ```
29
+
30
+ Or with pip:
31
+
32
+ ```shell
33
+ pip install ctxlen
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ Ask for a model's whole context window:
39
+
40
+ ```python
41
+ import ctxlen
42
+
43
+ ctxlen.ctxlen("claude-opus-5-5") # 1_000_000
44
+ ctxlen.ctxlen("gpt-6-sol") # 1_050_000
45
+ ```
46
+
47
+ You can also put the provider in front, like litellm does:
48
+
49
+ ```python
50
+ ctxlen.ctxlen("anthropic/claude-sonnet-5-5") # 1_000_000
51
+ ctxlen.ctxlen("openai/gpt-6-luna") # 1_050_000
52
+ ```
53
+
54
+ Or ask for the input and output limits on their own:
55
+
56
+ ```python
57
+ ctxlen.max_input("gpt-6-sol") # 922_000
58
+ ctxlen.max_output("gpt-6-sol") # 128_000
59
+ ```
60
+
61
+ The numbers come from litellm and models.dev; their notices are in [LICENSE](https://github.com/michaeltheologitis/ctxlen/blob/main/LICENSE).
62
+
63
+ ## Offline
64
+
65
+ `ctxlen.ctxlen("gpt-6-sol", live=False)` uses only the numbers that came with your version, and `CTXLEN_OFFLINE=1` does that for the whole process. ctxlen asks GitHub for fresh numbers at most once an hour and keeps them in `~/.cache/ctxlen/`.
@@ -0,0 +1,50 @@
1
+ # ctxlen 📏
2
+
3
+ A super minimal, always-fresh, project to look up the context limits (input and output tokens) of LLMs. 🤔
4
+
5
+ - 🔄 New models checked every 6 hours, and your install picks them up within the hour: no upgrade needed.
6
+ - 🪶 Just httpx and certifi as dependencies, and it still works offline, with the numbers it shipped with.
7
+ - 🧰 Just three functions.
8
+
9
+ ## Install
10
+
11
+ ```shell
12
+ uv add ctxlen
13
+ ```
14
+
15
+ Or with pip:
16
+
17
+ ```shell
18
+ pip install ctxlen
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Ask for a model's whole context window:
24
+
25
+ ```python
26
+ import ctxlen
27
+
28
+ ctxlen.ctxlen("claude-opus-5-5") # 1_000_000
29
+ ctxlen.ctxlen("gpt-6-sol") # 1_050_000
30
+ ```
31
+
32
+ You can also put the provider in front, like litellm does:
33
+
34
+ ```python
35
+ ctxlen.ctxlen("anthropic/claude-sonnet-5-5") # 1_000_000
36
+ ctxlen.ctxlen("openai/gpt-6-luna") # 1_050_000
37
+ ```
38
+
39
+ Or ask for the input and output limits on their own:
40
+
41
+ ```python
42
+ ctxlen.max_input("gpt-6-sol") # 922_000
43
+ ctxlen.max_output("gpt-6-sol") # 128_000
44
+ ```
45
+
46
+ The numbers come from litellm and models.dev; their notices are in [LICENSE](https://github.com/michaeltheologitis/ctxlen/blob/main/LICENSE).
47
+
48
+ ## Offline
49
+
50
+ `ctxlen.ctxlen("gpt-6-sol", live=False)` uses only the numbers that came with your version, and `CTXLEN_OFFLINE=1` does that for the whole process. ctxlen asks GitHub for fresh numbers at most once an hour and keeps them in `~/.cache/ctxlen/`.
@@ -1,9 +1,12 @@
1
1
  [project]
2
2
  name = "ctxlen"
3
- version = "2026.10.11.dev3"
4
- description = "max_input and max_output for any litellm model id, with no dependencies and no network"
3
+ version = "2026.10.12.dev1"
4
+ description = "The context limits of any LLM: always fresh, works offline, three functions"
5
5
  requires-python = ">=3.9"
6
- dependencies = []
6
+ dependencies = [
7
+ "httpx>=0.28,<1",
8
+ "certifi",
9
+ ]
7
10
  license = "MIT"
8
11
  license-files = ["LICENSE"]
9
12
  readme = "README.md"
@@ -1,9 +1,9 @@
1
1
  [project]
2
2
  name = "ctxlen"
3
- version = "2026.10.11.dev3"
4
- description = "max_input and max_output for any litellm model id, with no dependencies and no network"
3
+ version = "2026.10.12.dev1"
4
+ description = "The context limits of any LLM: always fresh, works offline, three functions"
5
5
  requires-python = ">=3.9"
6
- dependencies = []
6
+ dependencies = ["httpx>=0.28,<1", "certifi"]
7
7
  license = "MIT"
8
8
  license-files = ["LICENSE"]
9
9
  readme = "README.md"
@@ -0,0 +1,64 @@
1
+ """The context limits of any litellm model id: the latest release's numbers, fetched from GitHub
2
+ at most once an hour, else the ones installed with this version."""
3
+
4
+ import typing as _typing
5
+
6
+ from ctxlen import _resolve
7
+
8
+ __all__ = ["ctxlen", "max_input", "max_output"]
9
+
10
+
11
+ def ctxlen(model: str, *, live: bool = True) -> _typing.Optional[int]: # noqa: FA100
12
+ """The total context window, input and output tokens together, or None.
13
+
14
+ `model` is any id you would pass to litellm.completion ("gpt-4o",
15
+ "anthropic/claude-sonnet-4-5", "bedrock/us.anthropic..."), resolved as
16
+ litellm resolves it. The number is models.dev's for the same provider's
17
+ model; where models.dev has none, or one below this model's limits, it is
18
+ max_input(model), raised to max_output(model) where that is larger,
19
+ which is never larger than the true total.
20
+
21
+ With live=True, the default, the numbers are the latest release's, fetched
22
+ from GitHub at most once an hour and cached in ~/.cache/ctxlen/. Offline,
23
+ with live=False, or with CTXLEN_OFFLINE=1 set, they are the ones installed
24
+ with this version.
25
+ """
26
+ return _resolve.limits(model, "ctxlen", live)[2]
27
+
28
+
29
+ def max_input(model: str, *, live: bool = True) -> _typing.Optional[int]: # noqa: FA100 (help() shows Optional[int] on 3.9)
30
+ """The most input tokens `model` accepts, or None if no source knows it.
31
+
32
+ `model` is any id you would pass to litellm.completion ("gpt-4o",
33
+ "anthropic/claude-sonnet-4-5", "bedrock/us.anthropic..."), resolved as
34
+ litellm resolves it. The number is litellm's; where litellm has none,
35
+ models.dev's for the same provider's model.
36
+
37
+ The sources store what each provider publishes: for some models the input
38
+ cap (gpt-5: 272,000 of a 400,000 window), for others the whole window,
39
+ the reply included (Claude). ctxlen does not reconcile them: leave room
40
+ for the reply.
41
+
42
+ With live=True, the default, the numbers are the latest release's, fetched
43
+ from GitHub at most once an hour and cached in ~/.cache/ctxlen/. Offline,
44
+ with live=False, or with CTXLEN_OFFLINE=1 set, they are the ones installed
45
+ with this version.
46
+ """
47
+ return _resolve.limits(model, "max_input", live)[0]
48
+
49
+
50
+ def max_output(model: str, *, live: bool = True) -> _typing.Optional[int]: # noqa: FA100
51
+ """The most tokens `model` can generate in one reply, or None if no source knows it.
52
+
53
+ `model` is any id you would pass to litellm.completion ("gpt-4o",
54
+ "anthropic/claude-sonnet-4-5", "bedrock/us.anthropic..."), resolved as
55
+ litellm resolves it. The number is litellm's max_output_tokens for that
56
+ model; where litellm has none, models.dev's for the same provider's model.
57
+ An embedding model has no output limit, so it gives None.
58
+
59
+ With live=True, the default, the numbers are the latest release's, fetched
60
+ from GitHub at most once an hour and cached in ~/.cache/ctxlen/. Offline,
61
+ with live=False, or with CTXLEN_OFFLINE=1 set, they are the ones installed
62
+ with this version.
63
+ """
64
+ return _resolve.limits(model, "max_output", live)[1]