ctxlen 2026.10.11.dev1__py3-none-any.whl

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.
ctxlen/__init__.py ADDED
@@ -0,0 +1,35 @@
1
+ """max_input and max_output for any litellm model id, from bundled data, with no network."""
2
+
3
+ import typing as _typing
4
+
5
+ from ctxlen import _resolve
6
+
7
+ __all__ = ["max_input", "max_output"]
8
+
9
+
10
+ def max_input(model: str) -> _typing.Optional[int]: # noqa: FA100 (help() shows Optional[int] on 3.9)
11
+ """The most input tokens `model` accepts, or None if no source knows it.
12
+
13
+ `model` is any id you would pass to litellm.completion ("gpt-4o",
14
+ "anthropic/claude-sonnet-4-5", "bedrock/us.anthropic..."), resolved as
15
+ litellm resolves it. The number is litellm's; where litellm has none,
16
+ models.dev's for the same provider's model.
17
+
18
+ The sources store what each provider publishes: for some models the input
19
+ cap (gpt-5: 272,000 of a 400,000 window), for others the whole window,
20
+ the reply included (Claude). ctxlen does not reconcile them: leave room
21
+ for the reply.
22
+ """
23
+ return _resolve.limits(model, "max_input")[0]
24
+
25
+
26
+ def max_output(model: str) -> _typing.Optional[int]: # noqa: FA100
27
+ """The most tokens `model` can generate in one reply, or None if no source knows it.
28
+
29
+ `model` is any id you would pass to litellm.completion ("gpt-4o",
30
+ "anthropic/claude-sonnet-4-5", "bedrock/us.anthropic..."), resolved as
31
+ litellm resolves it. The number is litellm's max_output_tokens for that
32
+ model; where litellm has none, models.dev's for the same provider's model.
33
+ An embedding model has no output limit, so it gives None.
34
+ """
35
+ return _resolve.limits(model, "max_output")[1]