gemini-webapi 1.17.3__tar.gz → 1.18.1__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 (49) hide show
  1. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/.github/workflows/pypi-publish.yml +2 -2
  2. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/PKG-INFO +52 -10
  3. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/README.md +48 -6
  4. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/pyproject.toml +3 -3
  5. gemini_webapi-1.18.1/src/gemini_webapi/client.py +1151 -0
  6. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/components/gem_mixin.py +46 -23
  7. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/constants.py +12 -8
  8. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/types/candidate.py +2 -0
  9. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/types/image.py +8 -7
  10. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/types/modeloutput.py +8 -0
  11. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/__init__.py +1 -6
  12. gemini_webapi-1.18.1/src/gemini_webapi/utils/decorators.py +98 -0
  13. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/get_access_token.py +55 -34
  14. gemini_webapi-1.18.1/src/gemini_webapi/utils/parsing.py +250 -0
  15. gemini_webapi-1.18.1/src/gemini_webapi/utils/rotate_1psidts.py +78 -0
  16. gemini_webapi-1.18.1/src/gemini_webapi/utils/upload_file.py +99 -0
  17. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/PKG-INFO +52 -10
  18. gemini_webapi-1.18.1/src/gemini_webapi.egg-info/requires.txt +4 -0
  19. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/tests/test_client_features.py +26 -3
  20. gemini_webapi-1.17.3/src/gemini_webapi/client.py +0 -794
  21. gemini_webapi-1.17.3/src/gemini_webapi/utils/decorators.py +0 -53
  22. gemini_webapi-1.17.3/src/gemini_webapi/utils/parsing.py +0 -80
  23. gemini_webapi-1.17.3/src/gemini_webapi/utils/rotate_1psidts.py +0 -59
  24. gemini_webapi-1.17.3/src/gemini_webapi/utils/upload_file.py +0 -66
  25. gemini_webapi-1.17.3/src/gemini_webapi.egg-info/requires.txt +0 -4
  26. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/.github/dependabot.yml +0 -0
  27. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/.github/workflows/github-release.yml +0 -0
  28. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/.gitignore +0 -0
  29. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/.vscode/launch.json +0 -0
  30. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/.vscode/settings.json +0 -0
  31. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/LICENSE +0 -0
  32. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/assets/banner.png +0 -0
  33. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/assets/favicon.png +0 -0
  34. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/assets/logo.svg +0 -0
  35. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/assets/sample.pdf +0 -0
  36. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/setup.cfg +0 -0
  37. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/__init__.py +0 -0
  38. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/components/__init__.py +0 -0
  39. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/exceptions.py +0 -0
  40. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/types/__init__.py +0 -0
  41. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/types/gem.py +0 -0
  42. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/types/grpc.py +0 -0
  43. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/load_browser_cookies.py +0 -0
  44. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi/utils/logger.py +0 -0
  45. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/SOURCES.txt +0 -0
  46. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/dependency_links.txt +0 -0
  47. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/src/gemini_webapi.egg-info/top_level.txt +0 -0
  48. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/tests/test_gem_mixin.py +0 -0
  49. {gemini_webapi-1.17.3 → gemini_webapi-1.18.1}/tests/test_save_image.py +0 -0
@@ -36,7 +36,7 @@ jobs:
36
36
  - name: Build package
37
37
  run: python -m build
38
38
  - name: Archive production artifacts
39
- uses: actions/upload-artifact@v5.0.0
39
+ uses: actions/upload-artifact@v6.0.0
40
40
  with:
41
41
  name: dist
42
42
  path: dist
@@ -52,7 +52,7 @@ jobs:
52
52
  id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
53
53
  steps:
54
54
  - name: Retrieve built artifacts
55
- uses: actions/download-artifact@v6.0.0
55
+ uses: actions/download-artifact@v7.0.0
56
56
  with:
57
57
  name: dist
58
58
  path: dist
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gemini-webapi
3
- Version: 1.17.3
3
+ Version: 1.18.1
4
4
  Summary: ✨ An elegant async Python wrapper for Google Gemini web app
5
5
  Author: UZQueen
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -676,10 +676,10 @@ Classifier: Programming Language :: Python :: 3.12
676
676
  Requires-Python: >=3.10
677
677
  Description-Content-Type: text/markdown
678
678
  License-File: LICENSE
679
- Requires-Dist: httpx~=0.28.1
679
+ Requires-Dist: httpx[http2]~=0.28.1
680
680
  Requires-Dist: loguru~=0.7.3
681
- Requires-Dist: orjson~=3.11.1
682
- Requires-Dist: pydantic~=2.12.2
681
+ Requires-Dist: orjson~=3.11.7
682
+ Requires-Dist: pydantic~=2.12.5
683
683
  Dynamic: license-file
684
684
 
685
685
  <p align="center">
@@ -717,6 +717,7 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
717
717
  - **System Prompt** - Supports customizing model's system prompt with [Gemini Gems](https://gemini.google.com/gems/view).
718
718
  - **Extension Support** - Supports generating contents with [Gemini extensions](https://gemini.google.com/extensions) on, like YouTube and Gmail.
719
719
  - **Classified Outputs** - Categorizes texts, thoughts, web images and AI generated images in the response.
720
+ - **Streaming Mode** - Supports stream generation, yielding partial outputs as they are generated.
720
721
  - **Official Flavor** - Provides a simple and elegant interface inspired by [Google Generative AI](https://ai.google.dev/tutorials/python_quickstart)'s official API.
721
722
  - **Asynchronous** - Utilizes `asyncio` to run generating tasks and return outputs efficiently.
722
723
 
@@ -732,6 +733,8 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
732
733
  - [Generate contents with files](#generate-contents-with-files)
733
734
  - [Conversations across multiple turns](#conversations-across-multiple-turns)
734
735
  - [Continue previous conversations](#continue-previous-conversations)
736
+ - [Delete previous conversations from Gemini history](#delete-previous-conversations-from-gemini-history)
737
+ - [Streaming mode](#streaming-mode)
735
738
  - [Select language model](#select-language-model)
736
739
  - [Apply system prompt with Gemini Gems](#apply-system-prompt-with-gemini-gems)
737
740
  - [Manage Custom Gems](#manage-custom-gems)
@@ -901,6 +904,45 @@ async def main():
901
904
  asyncio.run(main())
902
905
  ```
903
906
 
907
+ ### Delete previous conversations from Gemini history
908
+
909
+ You can delete a specific chat from Gemini history on the server by calling `GeminiClient.delete_chat` with the chat id.
910
+
911
+ ```python
912
+ async def main():
913
+ # Start a new chat session
914
+ chat = client.start_chat()
915
+ await chat.send_message("This is a temporary conversation.")
916
+
917
+ # Delete the chat
918
+ await client.delete_chat(chat.cid)
919
+ print(f"Chat deleted: {chat.cid}")
920
+
921
+ asyncio.run(main())
922
+ ```
923
+
924
+ ### Streaming mode
925
+
926
+ For longer responses, you can use streaming mode to receive partial outputs as they are generated. This provides a more responsive user experience, especially for real-time applications like chatbots.
927
+
928
+ The `generate_content_stream` method yields `ModelOutput` objects where the `text_delta` attribute contains only the **new characters** received since the last yield, making it easy to display incremental updates.
929
+
930
+ ```python
931
+ async def main():
932
+ async for chunk in client.generate_content_stream(
933
+ "What's the difference between 'await' and 'async for'?"
934
+ ):
935
+ print(chunk.text_delta, end="", flush=True)
936
+
937
+ print()
938
+
939
+ asyncio.run(main())
940
+ ```
941
+
942
+ > [!TIP]
943
+ >
944
+ > You can also use streaming mode in multi-turn conversations with `ChatSession.send_message_stream`.
945
+
904
946
  ### Select language model
905
947
 
906
948
  You can specify which language model to use by passing `model` argument to `GeminiClient.generate_content` or `GeminiClient.start_chat`. The default value is `unspecified`.
@@ -909,8 +951,8 @@ Currently available models (as of November 20, 2025):
909
951
 
910
952
  - `unspecified` - Default model
911
953
  - `gemini-3.0-pro` - Gemini 3.0 Pro
912
- - `gemini-2.5-pro` - Gemini 2.5 Pro
913
- - `gemini-2.5-flash` - Gemini 2.5 Flash
954
+ - `gemini-3.0-flash` - Gemini 3.0 Flash
955
+ - `gemini-3.0-flash-thinking` - Gemini 3.0 Flash Thinking
914
956
 
915
957
  ```python
916
958
  from gemini_webapi.constants import Model
@@ -918,9 +960,9 @@ from gemini_webapi.constants import Model
918
960
  async def main():
919
961
  response1 = await client.generate_content(
920
962
  "What's you language model version? Reply version number only.",
921
- model=Model.G_2_5_FLASH,
963
+ model=Model.G_3_0_FLASH,
922
964
  )
923
- print(f"Model version ({Model.G_2_5_FLASH.model_name}): {response1.text}")
965
+ print(f"Model version ({Model.G_3_0_FLASH.model_name}): {response1.text}")
924
966
 
925
967
  chat = client.start_chat(model="gemini-2.5-pro")
926
968
  response2 = await chat.send_message("What's you language model version? Reply version number only.")
@@ -957,7 +999,7 @@ System prompt can be applied to conversations via [Gemini Gems](https://gemini.g
957
999
  ```python
958
1000
  async def main():
959
1001
  # Fetch all gems for the current account, including both predefined and user-created ones
960
- await client.fetch_gems(include_hidden=False)
1002
+ await client.fetch_gems(include_hidden=False, language="en")
961
1003
 
962
1004
  # Once fetched, gems will be cached in `GeminiClient.gems`
963
1005
  gems = client.gems
@@ -968,7 +1010,7 @@ async def main():
968
1010
 
969
1011
  response1 = await client.generate_content(
970
1012
  "what's your system prompt?",
971
- model=Model.G_2_5_FLASH,
1013
+ model=Model.G_3_0_FLASH,
972
1014
  gem=coding_partner,
973
1015
  )
974
1016
  print(response1.text)
@@ -33,6 +33,7 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
33
33
  - **System Prompt** - Supports customizing model's system prompt with [Gemini Gems](https://gemini.google.com/gems/view).
34
34
  - **Extension Support** - Supports generating contents with [Gemini extensions](https://gemini.google.com/extensions) on, like YouTube and Gmail.
35
35
  - **Classified Outputs** - Categorizes texts, thoughts, web images and AI generated images in the response.
36
+ - **Streaming Mode** - Supports stream generation, yielding partial outputs as they are generated.
36
37
  - **Official Flavor** - Provides a simple and elegant interface inspired by [Google Generative AI](https://ai.google.dev/tutorials/python_quickstart)'s official API.
37
38
  - **Asynchronous** - Utilizes `asyncio` to run generating tasks and return outputs efficiently.
38
39
 
@@ -48,6 +49,8 @@ A reverse-engineered asynchronous python wrapper for [Google Gemini](https://gem
48
49
  - [Generate contents with files](#generate-contents-with-files)
49
50
  - [Conversations across multiple turns](#conversations-across-multiple-turns)
50
51
  - [Continue previous conversations](#continue-previous-conversations)
52
+ - [Delete previous conversations from Gemini history](#delete-previous-conversations-from-gemini-history)
53
+ - [Streaming mode](#streaming-mode)
51
54
  - [Select language model](#select-language-model)
52
55
  - [Apply system prompt with Gemini Gems](#apply-system-prompt-with-gemini-gems)
53
56
  - [Manage Custom Gems](#manage-custom-gems)
@@ -217,6 +220,45 @@ async def main():
217
220
  asyncio.run(main())
218
221
  ```
219
222
 
223
+ ### Delete previous conversations from Gemini history
224
+
225
+ You can delete a specific chat from Gemini history on the server by calling `GeminiClient.delete_chat` with the chat id.
226
+
227
+ ```python
228
+ async def main():
229
+ # Start a new chat session
230
+ chat = client.start_chat()
231
+ await chat.send_message("This is a temporary conversation.")
232
+
233
+ # Delete the chat
234
+ await client.delete_chat(chat.cid)
235
+ print(f"Chat deleted: {chat.cid}")
236
+
237
+ asyncio.run(main())
238
+ ```
239
+
240
+ ### Streaming mode
241
+
242
+ For longer responses, you can use streaming mode to receive partial outputs as they are generated. This provides a more responsive user experience, especially for real-time applications like chatbots.
243
+
244
+ The `generate_content_stream` method yields `ModelOutput` objects where the `text_delta` attribute contains only the **new characters** received since the last yield, making it easy to display incremental updates.
245
+
246
+ ```python
247
+ async def main():
248
+ async for chunk in client.generate_content_stream(
249
+ "What's the difference between 'await' and 'async for'?"
250
+ ):
251
+ print(chunk.text_delta, end="", flush=True)
252
+
253
+ print()
254
+
255
+ asyncio.run(main())
256
+ ```
257
+
258
+ > [!TIP]
259
+ >
260
+ > You can also use streaming mode in multi-turn conversations with `ChatSession.send_message_stream`.
261
+
220
262
  ### Select language model
221
263
 
222
264
  You can specify which language model to use by passing `model` argument to `GeminiClient.generate_content` or `GeminiClient.start_chat`. The default value is `unspecified`.
@@ -225,8 +267,8 @@ Currently available models (as of November 20, 2025):
225
267
 
226
268
  - `unspecified` - Default model
227
269
  - `gemini-3.0-pro` - Gemini 3.0 Pro
228
- - `gemini-2.5-pro` - Gemini 2.5 Pro
229
- - `gemini-2.5-flash` - Gemini 2.5 Flash
270
+ - `gemini-3.0-flash` - Gemini 3.0 Flash
271
+ - `gemini-3.0-flash-thinking` - Gemini 3.0 Flash Thinking
230
272
 
231
273
  ```python
232
274
  from gemini_webapi.constants import Model
@@ -234,9 +276,9 @@ from gemini_webapi.constants import Model
234
276
  async def main():
235
277
  response1 = await client.generate_content(
236
278
  "What's you language model version? Reply version number only.",
237
- model=Model.G_2_5_FLASH,
279
+ model=Model.G_3_0_FLASH,
238
280
  )
239
- print(f"Model version ({Model.G_2_5_FLASH.model_name}): {response1.text}")
281
+ print(f"Model version ({Model.G_3_0_FLASH.model_name}): {response1.text}")
240
282
 
241
283
  chat = client.start_chat(model="gemini-2.5-pro")
242
284
  response2 = await chat.send_message("What's you language model version? Reply version number only.")
@@ -273,7 +315,7 @@ System prompt can be applied to conversations via [Gemini Gems](https://gemini.g
273
315
  ```python
274
316
  async def main():
275
317
  # Fetch all gems for the current account, including both predefined and user-created ones
276
- await client.fetch_gems(include_hidden=False)
318
+ await client.fetch_gems(include_hidden=False, language="en")
277
319
 
278
320
  # Once fetched, gems will be cached in `GeminiClient.gems`
279
321
  gems = client.gems
@@ -284,7 +326,7 @@ async def main():
284
326
 
285
327
  response1 = await client.generate_content(
286
328
  "what's your system prompt?",
287
- model=Model.G_2_5_FLASH,
329
+ model=Model.G_3_0_FLASH,
288
330
  gem=coding_partner,
289
331
  )
290
332
  print(response1.text)
@@ -20,10 +20,10 @@ classifiers = [
20
20
  ]
21
21
  requires-python = ">=3.10"
22
22
  dependencies = [
23
- "httpx~=0.28.1",
23
+ "httpx[http2]~=0.28.1",
24
24
  "loguru~=0.7.3",
25
- "orjson~=3.11.1",
26
- "pydantic~=2.12.2",
25
+ "orjson~=3.11.7",
26
+ "pydantic~=2.12.5",
27
27
  ]
28
28
  dynamic = ["version"]
29
29