aifree 0.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.
@@ -0,0 +1,6 @@
1
+ .venv
2
+ __pycache__/
3
+ *.egg-info/
4
+ dist/
5
+ .pytest_cache/
6
+ .mypy_cache/
aifree-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.5
2
+ Name: aifree
3
+ Version: 0.3.0
4
+ Summary: Python client for the aifree.dev API: verified free AI offers, free LLM API tiers and where each model is free.
5
+ Project-URL: Homepage, https://aifree.dev/developers
6
+ Project-URL: Documentation, https://aifree.dev/developers
7
+ Project-URL: Source, https://github.com/aifree4dev/aifree.dev
8
+ Project-URL: Issues, https://github.com/aifree4dev/aifree.dev/issues
9
+ License-Expression: MIT
10
+ Keywords: ai credits,aifree,free ai,free tier,llm api
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.9
16
+ Requires-Dist: httpx<1,>=0.25
17
+ Requires-Dist: typing-extensions>=4.7; python_version < '3.11'
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest>=7; extra == 'test'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # aifree (Python)
23
+
24
+ Python client for the [aifree.dev](https://aifree.dev) API v1: verified free
25
+ AI offers, free LLM API tiers and credits, and where each model is free with
26
+ its rate limits. Sync and async, typed, built on [httpx](https://www.python-httpx.org).
27
+ Data is CC BY 4.0: link to `https://aifree.dev` when you reuse it (every
28
+ record carries its `url`).
29
+
30
+ ```sh
31
+ pip install aifree
32
+ ```
33
+
34
+ Python 3.9+.
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ from aifree import Client
40
+
41
+ with Client() as aifree:
42
+ page = aifree.offers(category="api-credits", card_required=False, limit=5)
43
+ print(page["meta"]["total"], "offers")
44
+ for offer in page["data"]:
45
+ print(offer["name"], "-", offer["url"])
46
+
47
+ # Where can I call gpt-oss-120b for free, and at what RPM?
48
+ found = aifree.where("gpt-oss-120b")
49
+ if found["model"]:
50
+ for source in found["model"]["sources"]:
51
+ print(source["provider"], source["rateLimit"]["rpm"], "RPM")
52
+
53
+ # Which free offers end in the next two weeks?
54
+ for deadline in aifree.deadlines(within_days=14)["data"]:
55
+ print(deadline["expiryDate"], deadline["name"], deadline["url"])
56
+ ```
57
+
58
+ Async, same methods:
59
+
60
+ ```python
61
+ import asyncio
62
+ from aifree import AsyncClient
63
+
64
+ async def main() -> None:
65
+ async with AsyncClient() as aifree:
66
+ result = await aifree.eligibility(student=True, country="VN", card=False)
67
+ print(result["data"]["total"], "offers,", result["data"]["totalUsd"], "USD")
68
+
69
+ asyncio.run(main())
70
+ ```
71
+
72
+ | Method | Endpoint |
73
+ | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
74
+ | `offers(q, category, audience, free_type, card_required, region, commercial_use, refill, status, changed_since, fields, page, limit)` | `GET /offers`: the catalog, filtered, one page |
75
+ | `offer(slug)` | `GET /offers/{slug}` |
76
+ | `models(q, family, provider, changed_since, page, limit)` | `GET /models`: every model served free somewhere |
77
+ | `where(model)` | `GET /models/{model}` by slug or alias, else a name search |
78
+ | `eligibility(student, startup, country, card, building, limit)` | `GET /eligibility`: what a profile can claim (the `/unlock` quiz) |
79
+ | `changes(since, kind, hub, page, limit)` | `GET /changes`: changelog events, newest first |
80
+ | `deadlines(hub, provider, within_days, page, limit)` | `GET /deadlines`: offers ending soon, soonest first |
81
+ | `providers()` | `GET /providers` |
82
+ | `best_lists()`, `best_list(slug)` | `GET /best`, `GET /best/{slug}`: the curated "best free X" lists |
83
+
84
+ Responses are the API's JSON as plain dicts (`{"data": ..., "meta": ...}`),
85
+ typed with the `TypedDict`s in `aifree.types`, so field names are the API's
86
+ own (`cardRequired`, `rateLimit`). List parameters take a string or a list
87
+ (`category=["audio", "image"]`); dates take a `date`, a time-zone-aware
88
+ `datetime` or a string. `where()` returns `{"model": ..., "matches": [...]}`:
89
+ `model` is set when one model matched, otherwise `matches` lists the
90
+ candidates. Parameters and fields: [API v1 docs](https://aifree.dev/developers)
91
+ and the OpenAPI document at `https://aifree.dev/api/v1/openapi.json`.
92
+
93
+ ## Keys, limits and errors
94
+
95
+ Without a key: 600 requests per 15 minutes per IP. A free key from
96
+ [aifree.dev/developers](https://aifree.dev/developers) raises that to 6,000:
97
+ `Client("afk_...")` or the `AIFREE_API_KEY` environment variable.
98
+ `AIFREE_API_URL` (or `base_url=`) points the client at another server.
99
+
100
+ A non-2xx answer raises `aifree.AifreeError` with `status`, the API's stable
101
+ `code` (`not_found`, `rate_limited`, `invalid_request`...), `details` (the
102
+ problems of a 400) and `retry_after` (seconds to wait on a 429 or 5xx). The
103
+ client does not retry by itself:
104
+
105
+ ```python
106
+ import time
107
+ from aifree import AifreeError, Client
108
+
109
+ with Client() as aifree:
110
+ try:
111
+ changes = aifree.changes(since="2026-10-01", kind="expired")
112
+ except AifreeError as err:
113
+ if err.retry_after:
114
+ time.sleep(err.retry_after)
115
+ ```
116
+
117
+ Pass `user_agent="my-app/1.0"` to name your app in the `User-Agent`, or
118
+ `http_client=` to reuse your own `httpx.Client` / `httpx.AsyncClient`
119
+ (proxies, transports, timeouts).
120
+
121
+ ## Development
122
+
123
+ ```sh
124
+ cd packages/python
125
+ python3 -m venv .venv && .venv/bin/pip install -e '.[test]'
126
+ .venv/bin/python -m pytest
127
+ ```
128
+
129
+ The tests start a local HTTP server that answers with the API's recorded
130
+ responses (`app/lib/openapi-examples.json`), so they run from the
131
+ repository. From the repository root, `bun test tests/python-client.test.ts`
132
+ also runs the client against the real query parsers of the API (it uses
133
+ `packages/python/.venv` when present and skips without httpx).
134
+
135
+ ## License
136
+
137
+ MIT. The data is CC BY 4.0 (aifree.dev).
aifree-0.3.0/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # aifree (Python)
2
+
3
+ Python client for the [aifree.dev](https://aifree.dev) API v1: verified free
4
+ AI offers, free LLM API tiers and credits, and where each model is free with
5
+ its rate limits. Sync and async, typed, built on [httpx](https://www.python-httpx.org).
6
+ Data is CC BY 4.0: link to `https://aifree.dev` when you reuse it (every
7
+ record carries its `url`).
8
+
9
+ ```sh
10
+ pip install aifree
11
+ ```
12
+
13
+ Python 3.9+.
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ from aifree import Client
19
+
20
+ with Client() as aifree:
21
+ page = aifree.offers(category="api-credits", card_required=False, limit=5)
22
+ print(page["meta"]["total"], "offers")
23
+ for offer in page["data"]:
24
+ print(offer["name"], "-", offer["url"])
25
+
26
+ # Where can I call gpt-oss-120b for free, and at what RPM?
27
+ found = aifree.where("gpt-oss-120b")
28
+ if found["model"]:
29
+ for source in found["model"]["sources"]:
30
+ print(source["provider"], source["rateLimit"]["rpm"], "RPM")
31
+
32
+ # Which free offers end in the next two weeks?
33
+ for deadline in aifree.deadlines(within_days=14)["data"]:
34
+ print(deadline["expiryDate"], deadline["name"], deadline["url"])
35
+ ```
36
+
37
+ Async, same methods:
38
+
39
+ ```python
40
+ import asyncio
41
+ from aifree import AsyncClient
42
+
43
+ async def main() -> None:
44
+ async with AsyncClient() as aifree:
45
+ result = await aifree.eligibility(student=True, country="VN", card=False)
46
+ print(result["data"]["total"], "offers,", result["data"]["totalUsd"], "USD")
47
+
48
+ asyncio.run(main())
49
+ ```
50
+
51
+ | Method | Endpoint |
52
+ | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
53
+ | `offers(q, category, audience, free_type, card_required, region, commercial_use, refill, status, changed_since, fields, page, limit)` | `GET /offers`: the catalog, filtered, one page |
54
+ | `offer(slug)` | `GET /offers/{slug}` |
55
+ | `models(q, family, provider, changed_since, page, limit)` | `GET /models`: every model served free somewhere |
56
+ | `where(model)` | `GET /models/{model}` by slug or alias, else a name search |
57
+ | `eligibility(student, startup, country, card, building, limit)` | `GET /eligibility`: what a profile can claim (the `/unlock` quiz) |
58
+ | `changes(since, kind, hub, page, limit)` | `GET /changes`: changelog events, newest first |
59
+ | `deadlines(hub, provider, within_days, page, limit)` | `GET /deadlines`: offers ending soon, soonest first |
60
+ | `providers()` | `GET /providers` |
61
+ | `best_lists()`, `best_list(slug)` | `GET /best`, `GET /best/{slug}`: the curated "best free X" lists |
62
+
63
+ Responses are the API's JSON as plain dicts (`{"data": ..., "meta": ...}`),
64
+ typed with the `TypedDict`s in `aifree.types`, so field names are the API's
65
+ own (`cardRequired`, `rateLimit`). List parameters take a string or a list
66
+ (`category=["audio", "image"]`); dates take a `date`, a time-zone-aware
67
+ `datetime` or a string. `where()` returns `{"model": ..., "matches": [...]}`:
68
+ `model` is set when one model matched, otherwise `matches` lists the
69
+ candidates. Parameters and fields: [API v1 docs](https://aifree.dev/developers)
70
+ and the OpenAPI document at `https://aifree.dev/api/v1/openapi.json`.
71
+
72
+ ## Keys, limits and errors
73
+
74
+ Without a key: 600 requests per 15 minutes per IP. A free key from
75
+ [aifree.dev/developers](https://aifree.dev/developers) raises that to 6,000:
76
+ `Client("afk_...")` or the `AIFREE_API_KEY` environment variable.
77
+ `AIFREE_API_URL` (or `base_url=`) points the client at another server.
78
+
79
+ A non-2xx answer raises `aifree.AifreeError` with `status`, the API's stable
80
+ `code` (`not_found`, `rate_limited`, `invalid_request`...), `details` (the
81
+ problems of a 400) and `retry_after` (seconds to wait on a 429 or 5xx). The
82
+ client does not retry by itself:
83
+
84
+ ```python
85
+ import time
86
+ from aifree import AifreeError, Client
87
+
88
+ with Client() as aifree:
89
+ try:
90
+ changes = aifree.changes(since="2026-10-01", kind="expired")
91
+ except AifreeError as err:
92
+ if err.retry_after:
93
+ time.sleep(err.retry_after)
94
+ ```
95
+
96
+ Pass `user_agent="my-app/1.0"` to name your app in the `User-Agent`, or
97
+ `http_client=` to reuse your own `httpx.Client` / `httpx.AsyncClient`
98
+ (proxies, transports, timeouts).
99
+
100
+ ## Development
101
+
102
+ ```sh
103
+ cd packages/python
104
+ python3 -m venv .venv && .venv/bin/pip install -e '.[test]'
105
+ .venv/bin/python -m pytest
106
+ ```
107
+
108
+ The tests start a local HTTP server that answers with the API's recorded
109
+ responses (`app/lib/openapi-examples.json`), so they run from the
110
+ repository. From the repository root, `bun test tests/python-client.test.ts`
111
+ also runs the client against the real query parsers of the API (it uses
112
+ `packages/python/.venv` when present and skips without httpx).
113
+
114
+ ## License
115
+
116
+ MIT. The data is CC BY 4.0 (aifree.dev).
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "aifree"
7
+ dynamic = ["version"]
8
+ description = "Python client for the aifree.dev API: verified free AI offers, free LLM API tiers and where each model is free."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ dependencies = [
13
+ "httpx>=0.25,<1",
14
+ "typing_extensions>=4.7; python_version < '3.11'",
15
+ ]
16
+ keywords = ["free ai", "free tier", "llm api", "ai credits", "aifree"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Typing :: Typed",
22
+ ]
23
+
24
+ [project.optional-dependencies]
25
+ test = ["pytest>=7"]
26
+
27
+ [project.urls]
28
+ Homepage = "https://aifree.dev/developers"
29
+ Documentation = "https://aifree.dev/developers"
30
+ Source = "https://github.com/aifree4dev/aifree.dev"
31
+ Issues = "https://github.com/aifree4dev/aifree.dev/issues"
32
+
33
+ [tool.hatch.version]
34
+ path = "src/aifree/_version.py"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/aifree"]
38
+
39
+ [tool.hatch.build.targets.sdist]
40
+ include = ["src/aifree", "tests", "README.md"]
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
44
+ # No .pytest_cache: the repository lints every *.md file it finds.
45
+ addopts = "-p no:cacheprovider"
@@ -0,0 +1,7 @@
1
+ """Python client for the aifree.dev API v1: verified free AI offers,
2
+ free LLM API tiers and the models they serve (data CC BY 4.0)."""
3
+
4
+ from ._client import DEFAULT_BASE_URL, AifreeError, AsyncClient, Client
5
+ from ._version import __version__
6
+
7
+ __all__ = ["DEFAULT_BASE_URL", "AifreeError", "AsyncClient", "Client", "__version__"]