Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
275 commits
Select commit Hold shift + click to select a range
601451a
fix: Save generated images to persistent storage
luuquangvu Dec 4, 2025
893eb6d
fix: Remove unused `output_image` type from `ResponseOutputContent` a…
luuquangvu Dec 4, 2025
80462b5
fix: Update image URL generation in chat response to use Markdown for…
luuquangvu Dec 4, 2025
af91c4f
Merge branch 'Nativu5:main' into main
luuquangvu Dec 4, 2025
f088b5f
Merge branch 'Nativu5:main' into main
luuquangvu Dec 6, 2025
8d49a72
fix: Enhance error handling for full-size image saving and add fallba…
luuquangvu Dec 8, 2025
d37eae0
fix: Use filename as image ID to ensure consistency in generated imag…
luuquangvu Dec 9, 2025
b9f776d
fix: Enhance tempfile saving by adding custom headers, content-type h…
luuquangvu Dec 16, 2025
4b5fe07
feat: Add support for custom Gemini models and model loading strategies
luuquangvu Dec 30, 2025
5cb29e8
feat: Improve Gemini model environment variable parsing and nested fi…
luuquangvu Dec 30, 2025
f25f16d
refactor: Consolidate utility functions and clean up unused code
luuquangvu Dec 31, 2025
a1bc8e2
fix: Handle None input in `estimate_tokens` and return 0 for empty text
luuquangvu Dec 31, 2025
a7e15d9
refactor: Simplify model configuration and add JSON parsing validators
luuquangvu Dec 31, 2025
61c5f3b
refactor: Simplify Gemini model environment variable parsing with JSO…
luuquangvu Dec 31, 2025
efd056c
fix: Enhance Gemini model environment variable parsing with fallback …
luuquangvu Dec 31, 2025
476b9dd
fix: Improve regex patterns in helper module
luuquangvu Dec 31, 2025
35c1e99
docs: Update README files to include custom model configuration and e…
luuquangvu Jan 13, 2026
9b81621
fix: Remove unused headers from HTTP client in helper module
luuquangvu Jan 13, 2026
32a48dc
fix: Update README and README.zh to clarify model configuration via e…
luuquangvu Jan 15, 2026
0c00b08
Update README and README.zh to clarify model configuration via JSON s…
luuquangvu Jan 15, 2026
e2233f4
Merge branch 'Nativu5:main' into main
luuquangvu Jan 22, 2026
b599d99
Refactor: compress JSON content to save tokens and streamline sending…
luuquangvu Jan 23, 2026
186b844
Refactor: Modify the LMDB store to fix issues where no conversation i…
luuquangvu Jan 23, 2026
6dd1fec
Refactor: Modify the LMDB store to fix issues where no conversation i…
luuquangvu Jan 24, 2026
20ed245
Refactor: Update all functions to use orjson for better performance
luuquangvu Jan 24, 2026
f67fe63
Update project dependencies
luuquangvu Jan 24, 2026
889f2d2
Fix IDE warnings
luuquangvu Jan 24, 2026
66b6202
Incorrect IDE warnings
luuquangvu Jan 24, 2026
3297f53
Refactor: Modify the LMDB store to fix issues where no conversation i…
luuquangvu Jan 24, 2026
5399b26
Refactor: Centralized the mapping of the 'developer' role to 'system'…
luuquangvu Jan 24, 2026
de01c78
Refactor: Modify the LMDB store to fix issues where no conversation i…
luuquangvu Jan 24, 2026
1964147
Refactor: Modify the LMDB store to fix issues where no conversation i…
luuquangvu Jan 24, 2026
8c5c749
Refactor: Modify the LMDB store to fix issues where no conversation i…
luuquangvu Jan 24, 2026
ce67d66
Refactor: Avoid reusing an existing chat session if its idle time exc…
luuquangvu Jan 24, 2026
3d32d12
Refactor: Update the LMDB store to resolve issues preventing conversa…
luuquangvu Jan 24, 2026
2eb9f05
Refactor: Update the _prepare_messages_for_model helper to omit the s…
luuquangvu Jan 24, 2026
ade61d6
Refactor: Modify the logic to convert a large prompt into a temporary…
luuquangvu Jan 26, 2026
bdd893f
Enable streaming responses and fully resolve the problem with reusabl…
luuquangvu Jan 28, 2026
a51f75c
Merge branch 'Nativu5:main' into main
luuquangvu Jan 28, 2026
767f0b3
Merge branch 'main' of https://github.com/luuquangvu/Gemini-FastAPI
luuquangvu Jan 28, 2026
52547a9
Enable real-time streaming responses and completely solve the issue w…
luuquangvu Jan 30, 2026
c0b32c6
Enable real-time streaming responses and completely solve the issue w…
luuquangvu Jan 30, 2026
4d51a5f
Enable real-time streaming responses and completely solve the issue w…
luuquangvu Feb 2, 2026
d69aaf0
Enable real-time streaming responses and completely solve the issue w…
luuquangvu Feb 2, 2026
8e15a86
Enable real-time streaming responses and completely solve the issue w…
luuquangvu Feb 2, 2026
7716c62
build: update dependencies
luuquangvu Feb 3, 2026
61672cc
Refactor: Use `strip_system_hints` to standardize the content.
luuquangvu Feb 3, 2026
cc0b13f
Refactor: Only inject code block hint if NOT a structured response re…
luuquangvu Feb 3, 2026
6b90e5d
Refactor: Remove the code block hint entirely
luuquangvu Feb 3, 2026
553bd94
Refactor: Remove the code block hint entirely
luuquangvu Feb 3, 2026
fd767da
Refactor: fix missing whitespace in the streaming response.
luuquangvu Feb 3, 2026
f6b60aa
Merge remote-tracking branch 'upstream/main'
luuquangvu Feb 3, 2026
4beb33b
Refactor: remove unnecessary code
luuquangvu Feb 4, 2026
6b8dd4e
Refactor: Update `StreamingOutputFilter` logic to improve handling of…
luuquangvu Feb 4, 2026
d86ae59
Refactor: Adjust function call format to prevent streaming issues
luuquangvu Feb 4, 2026
db39ad1
Refactor: Adjust function call format to prevent streaming issues
luuquangvu Feb 4, 2026
556a638
Refactor: Adjust function call format to prevent streaming issues
luuquangvu Feb 4, 2026
d5fec7a
Refactor: Adjust function call format to prevent streaming issues
luuquangvu Feb 5, 2026
dbc553d
Refactor: Enhance prompt to prevent issues with parsing tool call arg…
luuquangvu Feb 5, 2026
ca721cf
Refactor: Enhance prompt to prevent issues with parsing tool call arg…
luuquangvu Feb 5, 2026
d3b60c8
Merge branch 'Nativu5:main' into main
luuquangvu Feb 5, 2026
263158e
Refactor: enhance system prompts
luuquangvu Feb 6, 2026
68ce2df
Refactor: Enhance system prompts
luuquangvu Feb 6, 2026
77f7210
Refactor: Enhance system prompts
luuquangvu Feb 6, 2026
3addb2b
Refactor: Enhance system prompts
luuquangvu Feb 7, 2026
2a53eed
fix: missing image extension
luuquangvu Feb 8, 2026
26d39c7
fix: missing image extension
luuquangvu Feb 8, 2026
598b563
fix: missing or duplicate ChatML tags.
luuquangvu Feb 8, 2026
6d563c5
Refactor: Consistently use ChatML tags throughout.
luuquangvu Feb 8, 2026
58db419
Refactor: normalize text before calculating message hash
luuquangvu Feb 9, 2026
d5d1c5a
Refactor: remove unescape helpers to avoid side effects
luuquangvu Feb 9, 2026
a4a987c
Refactor: Implement fuzzy matching to better handle complex data form…
luuquangvu Feb 9, 2026
551eb87
Refactor: Implement fuzzy matching to better handle complex data form…
luuquangvu Feb 9, 2026
b2dbb08
Feat: Add watchdog_timeout parameter
luuquangvu Feb 10, 2026
969cd4a
Update required dependencies
luuquangvu Feb 10, 2026
c258d32
Move `maketrans` to global variable
luuquangvu Feb 10, 2026
157028f
Move `maketrans` to global variable
luuquangvu Feb 10, 2026
5f9a7ec
Refactor: Add a filter to catch orphaned tool calls.
luuquangvu Feb 10, 2026
c81c2ce
Update required dependencies
luuquangvu Feb 10, 2026
a170825
Add dependabot
luuquangvu Feb 10, 2026
a0136af
Refactor: Implement the logic changes recommended by Copilot
luuquangvu Feb 11, 2026
5eb9f50
Refactor: Optimize fuzzy matching logic
luuquangvu Feb 11, 2026
971f2c7
Update dependencies
luuquangvu Feb 11, 2026
cad2379
Refactor: Update Markdown unescape helpers to prevent impacting clien…
luuquangvu Feb 11, 2026
795b8d8
Refactor: Update Markdown unescape helpers to prevent impacting clien…
luuquangvu Feb 11, 2026
e85252a
Revert "Refactor: Update Markdown unescape helpers to prevent impacti…
luuquangvu Feb 12, 2026
4be4150
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 12, 2026
d86798b
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 12, 2026
0d18e9e
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 12, 2026
8fa4329
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 12, 2026
dcd7276
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 12, 2026
737aa3a
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 12, 2026
2c80895
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
9b0e1d5
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
95f87f6
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
4569689
Refactor: Update `unescape_llm_text` to standardize and repair LLM-ge…
luuquangvu Feb 13, 2026
5a65cb6
Refactor: Update `unescape_llm_text` to standardize and repair LLM-ge…
luuquangvu Feb 13, 2026
8a03c33
Refactor: Update `unescape_llm_text` to standardize and repair LLM-ge…
luuquangvu Feb 13, 2026
7ed2132
Refactor: Update `unescape_llm_text` to standardize and repair LLM-ge…
luuquangvu Feb 13, 2026
d92bc1c
Refactor: Update `unescape_llm_text` to standardize and repair LLM-ge…
luuquangvu Feb 13, 2026
4ecad56
Refactor: Update `unescape_llm_text` to standardize and repair LLM-ge…
luuquangvu Feb 13, 2026
28378b4
Update dependencies
luuquangvu Feb 13, 2026
3fcd01e
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
ef24704
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
4edf4cd
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
dcadabb
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
8390414
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
ce43d63
Refactor: Remove all escape logic handlers.
luuquangvu Feb 13, 2026
8792948
Refactor: Remove all escape logic handlers.
luuquangvu Feb 13, 2026
5482e0c
Refactor: Remove all escape logic handlers.
luuquangvu Feb 13, 2026
b324aef
Revert "Refactor: Remove all escape logic handlers."
luuquangvu Feb 13, 2026
8ef108d
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
30043e5
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
bc888d1
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
d5349a0
Refactor: Rewrite the function call format to match the client's comp…
luuquangvu Feb 13, 2026
7e217e9
Reattempt changing tool call tags to `snake_case`.
luuquangvu Feb 13, 2026
fe30a5d
Revert "Reattempt changing tool call tags to `snake_case`."
luuquangvu Feb 13, 2026
93e9ccd
Refactor: Handle all escape tags
luuquangvu Feb 13, 2026
30f6125
Refactor: Handle all escape tags
luuquangvu Feb 13, 2026
a355252
Refactor: Remove `_strip_google_search` as it's no longer needed
luuquangvu Feb 14, 2026
45af127
Update `TOOL_WRAP_HINT` to ensure Gemini strictly follows the instruc…
luuquangvu Feb 14, 2026
f144e14
Update required dependencies
luuquangvu Feb 14, 2026
4461ca3
Merge branch 'Nativu5:main' into main
luuquangvu Feb 18, 2026
808463f
Merge branch 'Nativu5:main' into main
luuquangvu Feb 18, 2026
9d014b0
Ignore github directory
luuquangvu Feb 18, 2026
3fab502
Upgrade to fully support Python 3.13
luuquangvu Feb 18, 2026
35864f6
Upgrade to fully support Python 3.13
luuquangvu Feb 18, 2026
a48c38d
Upgrade to fully support Python 3.13
luuquangvu Feb 18, 2026
0540c4f
Refactor regex patterns for tool and chat message processing in helpe…
luuquangvu Feb 22, 2026
084eda7
Update dependencies to latest versions
luuquangvu Feb 22, 2026
bdf8028
Refactor StreamingOutputFilter to use a stack-based state machine for…
luuquangvu Feb 22, 2026
2e4a97f
Refactor `StreamingOutputFilter` for improved handling of nested frag…
luuquangvu Feb 22, 2026
c4d9016
Refactor `StreamingOutputFilter` for improved handling of nested frag…
luuquangvu Feb 22, 2026
1da4dac
Fix fence stripping logic in _strip_param_fences function
luuquangvu Feb 22, 2026
ef058d4
Refactor think tag removal to use a precompiled regex pattern
luuquangvu Feb 22, 2026
906380f
Refactor HTTP client usage to utilize AsyncSession from curl-cffi for…
luuquangvu Feb 22, 2026
9ecb982
Revert "Refactor HTTP client usage to utilize AsyncSession from curl-…
luuquangvu Feb 22, 2026
6c5cabd
Update: Explicitly added httpx as a dependency to safeguard against p…
luuquangvu Feb 22, 2026
6b6e589
ORJSONResponse is deprecated
luuquangvu Feb 23, 2026
fbe19db
Refactor HTTP client usage to utilize AsyncSession from curl-cffi for…
luuquangvu Feb 23, 2026
b7a9ca5
Update dependencies to latest versions
luuquangvu Feb 24, 2026
c4aefbf
Add API endpoint documentation for OpenAI-compatible and advanced end…
luuquangvu Feb 24, 2026
e00a8fa
Add optional custom cookies parameter
luuquangvu Feb 25, 2026
eb3c286
Revert "Add optional custom cookies parameter"
luuquangvu Feb 26, 2026
29682fd
Update dependencies to latest versions
luuquangvu Feb 26, 2026
5fcd60b
Edit watchdog_timeout
luuquangvu Feb 26, 2026
2305e2d
Edit watchdog_timeout
luuquangvu Feb 26, 2026
c9693bd
Add optional custom cookies parameter
luuquangvu Feb 26, 2026
1c7f99a
Increase timeout settings for improved connection stability during pe…
luuquangvu Feb 27, 2026
78addce
Fix formatting of streaming response for thought and text deltas
luuquangvu Feb 28, 2026
0d7791a
Update dependencies to latest versions
luuquangvu Feb 28, 2026
0c34182
Refactor `<think>` tag to `reasoning_content` and `reasoning_text`
luuquangvu Feb 28, 2026
c73ebe2
Fix streaming response generation
luuquangvu Feb 28, 2026
ab706d8
Update image storage configuration to use dynamic path from settings
luuquangvu Feb 28, 2026
74badb6
Fix streaming response generation
luuquangvu Mar 1, 2026
2dec77c
Fix streaming response generation
luuquangvu Mar 1, 2026
a54989d
Merge remote-tracking branch 'upstream/main'
luuquangvu Mar 1, 2026
e4da69e
Remove optional custom cookies parameter
luuquangvu Mar 1, 2026
d5619c2
Merge branch 'Nativu5:main' into main
luuquangvu Mar 2, 2026
54dd826
Change `watchdog_timeout` to 90s
luuquangvu Mar 2, 2026
43f15c9
Merge remote-tracking branch 'origin/main'
luuquangvu Mar 2, 2026
91a64cd
Refactored Models to improving type safety.
luuquangvu Mar 3, 2026
1a9f7de
Add type check using `ty`
luuquangvu Mar 3, 2026
da54b73
Temporarily switch to the `move-httpx-to-curl_cffi` branch for testin…
luuquangvu Mar 3, 2026
22edc6b
Add workflow_dispatch trigger to Docker workflow
luuquangvu Mar 3, 2026
d2937d5
Revert "Temporarily switch to the `move-httpx-to-curl_cffi` branch fo…
luuquangvu Mar 3, 2026
ca4475a
Fix type checking
luuquangvu Mar 3, 2026
91105e8
Update dependencies to latest versions
luuquangvu Mar 4, 2026
d858c2b
Temporarily switch to the `move-httpx-to-curl_cffi` branch for testin…
luuquangvu Mar 4, 2026
592132f
Resolve HTTP 422 "Input should be a valid string"
luuquangvu Mar 4, 2026
80750ad
Move the content storage in LMDB to a separate `AppMessage`
luuquangvu Mar 4, 2026
d2ce6de
Merge remote-tracking branch 'upstream/main'
luuquangvu Mar 4, 2026
88c6d4d
Move the content storage in LMDB to a separate `AppMessage`
luuquangvu Mar 4, 2026
dec4b3c
Move the content storage in LMDB to a separate `AppMessage`
luuquangvu Mar 4, 2026
ece7e7a
Move the content storage in LMDB to a separate `AppMessage`
luuquangvu Mar 4, 2026
67632bf
Add support for retrieving dynamic models based on client accounts.
luuquangvu Mar 5, 2026
9b7d3eb
Update dependencies to latest versions
luuquangvu Mar 6, 2026
11a709a
Add support for music and video generation, and update the persistent…
luuquangvu Mar 6, 2026
9a96201
Refactor model retrieval logic to avoid duplicates and streamline pro…
luuquangvu Mar 6, 2026
391c31e
Update dependencies to latest versions
luuquangvu Mar 6, 2026
13d7983
Update dependencies to latest versions
luuquangvu Mar 6, 2026
eef2cbb
Update the Markdown link handling to include video and audio support …
luuquangvu Mar 6, 2026
d28b5a8
Update the Markdown link handling to include video and audio support …
luuquangvu Mar 6, 2026
af1b508
Update dependencies to latest versions
luuquangvu Mar 6, 2026
0d4fa4c
Update dependencies to latest versions
luuquangvu Mar 6, 2026
95889af
Update dependencies to latest versions
luuquangvu Mar 6, 2026
3d10fd5
Update dependencies to latest versions
luuquangvu Mar 6, 2026
d92fa8f
Update the Markdown link handling to correctly include thumbnails.
luuquangvu Mar 6, 2026
d6920ff
Update the Markdown link handling to correctly include thumbnails.
luuquangvu Mar 7, 2026
d85552d
Update the Markdown link handling to correctly include thumbnails.
luuquangvu Mar 7, 2026
9dfc866
Update the Markdown link handling to correctly include thumbnails.
luuquangvu Mar 7, 2026
1f11c95
Resolve mismatch of reusable sessions
luuquangvu Mar 8, 2026
bd24c53
Update dependencies to latest versions
luuquangvu Mar 8, 2026
cfd96d5
Resolve the issue where downloading media takes too long and results …
luuquangvu Mar 9, 2026
baf67b9
Update dependencies to latest versions
luuquangvu Mar 9, 2026
ddc2257
Update dependencies to latest versions
luuquangvu Mar 10, 2026
d05aa9d
Introduced cookies parameter and resolved text drift during video gen…
luuquangvu Mar 10, 2026
cb98703
Fixed configuration validation failed
luuquangvu Mar 10, 2026
219fc61
Using default configuration values from global settings
luuquangvu Mar 10, 2026
090bd00
Using default configuration values from global settings
luuquangvu Mar 10, 2026
7828a4a
Remove cookies parameter to avoid HTTP 401 error
luuquangvu Mar 11, 2026
bd2816b
Merge remote-tracking branch 'upstream/main'
luuquangvu Mar 11, 2026
f4b319c
Resolved content drift during streaming.
luuquangvu Mar 11, 2026
2d3cf20
Update dependencies to latest versions
luuquangvu Mar 11, 2026
00895cb
Update regex patterns to prevent exposing system tags
luuquangvu Mar 12, 2026
f1de210
Remove the unused <think> tag and clean up the redundant `extract_out…
luuquangvu Mar 12, 2026
370f104
Clean up the redundant code and update dependencies to latest versions
luuquangvu Mar 13, 2026
a596009
Include random delays to stagger the start times for clients in the p…
luuquangvu Mar 13, 2026
d038d65
Allow remembering and recovering conversation metadata during retenti…
luuquangvu Mar 14, 2026
b929c69
Implement a graceful shutdown to prevent losing cookies.
luuquangvu Mar 14, 2026
07811ac
Add healthcheck to Dockerfile
luuquangvu Mar 17, 2026
24fdb63
Fix a rare issue where whitespace leaks occur during a tool call whil…
luuquangvu Mar 17, 2026
aa4569e
Update dependencies to latest versions
luuquangvu Mar 18, 2026
3a68e96
Remove unused code
luuquangvu Mar 18, 2026
4c9f4bf
Update dependencies to latest versions
luuquangvu Mar 19, 2026
49f1144
Update dependencies to latest versions
luuquangvu Mar 19, 2026
db90659
Update dependencies to latest versions
luuquangvu Mar 19, 2026
d32ee02
Update dependencies to latest versions
luuquangvu Mar 19, 2026
08d5e1d
Update dependencies to latest versions
luuquangvu Mar 19, 2026
5041132
Temporarily downgrade lmdb to version 1.x
luuquangvu Mar 19, 2026
5829ac0
Update dependencies to latest versions
luuquangvu Mar 19, 2026
6a0f99b
Update dependencies to latest versions
luuquangvu Mar 19, 2026
7abc979
Update dependencies to latest versions
luuquangvu Mar 20, 2026
c3730ca
Update dependencies to latest versions
luuquangvu Mar 20, 2026
ccbd7bb
Enable the debug logging level to let users see warnings about cookie…
luuquangvu Mar 21, 2026
cd402d8
Update dependencies to latest versions
luuquangvu Mar 24, 2026
44968c9
Update dependencies to latest versions
luuquangvu Mar 26, 2026
cf0dffa
Update dependencies to latest versions
luuquangvu Apr 2, 2026
2ca6339
Pinning workflow actions to a full-length commit SHA to comply with s…
luuquangvu Apr 2, 2026
b1773c2
Update dependencies to latest versions
luuquangvu Apr 8, 2026
19739e9
Enable Guest mode
luuquangvu Apr 13, 2026
e3c0294
Continue updating Guest mode
luuquangvu Apr 14, 2026
37cd39b
Get account quotas, abuse status
luuquangvu Apr 14, 2026
1a57aeb
Update the account quotas logic to make it more display-friendly
luuquangvu Apr 14, 2026
f40e4e0
Update the account quotas logic to make it more display-friendly
luuquangvu Apr 14, 2026
86a8dde
Update the account quotas logic to make it more display-friendly
luuquangvu Apr 14, 2026
df512c3
Update the account quotas logic to make it more display-friendly
luuquangvu Apr 14, 2026
506c78f
Add a background task to send HTTP/2 PING frames
luuquangvu Apr 14, 2026
90aefdb
Explicitly use HTTP/2 and include SSRF protection
luuquangvu Apr 15, 2026
1156d22
Explicitly use HTTP/2 and include SSRF protection
luuquangvu Apr 15, 2026
e9c7ca7
Include the `impersonate` parameter
luuquangvu Apr 15, 2026
d6aef65
Periodically check for dead clients in the pool and revive them based…
luuquangvu Apr 16, 2026
b8cd546
Explicitly use HTTP/3 with fallback and update libraries
luuquangvu Apr 25, 2026
3230a81
Experiment with resolving the issue of cookies becoming inactive afte…
luuquangvu Apr 27, 2026
bf765bc
Experiment with resolving the issue of cookies becoming inactive afte…
luuquangvu Apr 27, 2026
2b605b4
Update health_check
luuquangvu Apr 27, 2026
7481322
Experiment with resolving the issue of cookies becoming inactive afte…
luuquangvu Apr 27, 2026
26f5ad4
Update README to avoid using chrome based
luuquangvu Apr 27, 2026
9d56d33
Workaround for new device-bound session mechanism
luuquangvu Apr 28, 2026
a2f1ebd
Stop background tasks when the account status is not available
luuquangvu May 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ on:
- main
tags:
- "v*"
paths-ignore:
- "**/*.md"
- ".github/*"
- "LICENSE"
- ".gitignore"
paths:
- "app/**"
- "config/**"
- "pyproject.toml"
- "uv.lock"
- "Dockerfile"
- "run.py"
- ".github/workflows/docker.yaml"
workflow_dispatch:

env:
REGISTRY: ghcr.io
Expand All @@ -25,24 +29,24 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up QEMU
uses: docker/setup-qemu-action@v4
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4

- name: Log in to Container Registry
uses: docker/login-action@v4
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -54,7 +58,7 @@ jobs:
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v7
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
context: .
push: true
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint and Type Check

on:
push:
paths:
- "**.py"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/lint.yaml"
pull_request:
paths:
- "**.py"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/lint.yaml"

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0

- name: Install dependencies
run: uv sync --all-groups

- name: Run Ruff
run: uv run ruff check .

- name: Run Ruff Format
run: uv run ruff format . --check

- name: Run Ty Check
run: uv run ty check
30 changes: 0 additions & 30 deletions .github/workflows/ruff.yaml

This file was deleted.

16 changes: 8 additions & 8 deletions .github/workflows/track.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Update gemini-webapi

on:
schedule:
- cron: "0 0 * * *" # Runs every day at midnight
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
Expand All @@ -11,13 +11,13 @@ jobs:
permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v6
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0

- name: Update gemini-webapi
id: update
Expand All @@ -33,8 +33,8 @@ jobs:
fi
echo "Current gemini-webapi version: $OLD_VERSION"

# Update the package using uv, which handles pyproject.toml and uv.lock
uv add --upgrade gemini-webapi
# Update gemini-webapi to the latest version
uv lock --upgrade-package gemini-webapi

# Get new version of gemini-webapi after upgrade
NEW_VERSION=$(uv pip show gemini-webapi | grep ^Version: | awk '{print $2}')
Expand All @@ -56,7 +56,7 @@ jobs:

- name: Create Pull Request
if: steps.update.outputs.updated == 'true'
uses: peter-evans/create-pull-request@v8
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: ":arrow_up: update gemini-webapi to ${{ steps.update.outputs.version }}"
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim
LABEL org.opencontainers.image.title="Gemini-FastAPI" \
org.opencontainers.image.description="Web-based Gemini models wrapped into an OpenAI-compatible API."

USER root

WORKDIR /app

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update && apt-get install -y --no-install-recommends \
tini \
tini curl ca-certificates git \
&& rm -rf /var/lib/apt/lists/*

ENV UV_COMPILE_BYTECODE=1 \
Expand All @@ -22,6 +26,9 @@ COPY run.py .

EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=10s --start-period=300s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1

ENTRYPOINT ["/usr/bin/tini", "--"]

CMD ["uv", "run", "--no-dev", "run.py"]
45 changes: 36 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Gemini-FastAPI

[![Python 3.13](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.115+-green.svg)](https://fastapi.tiangolo.com/)
[![FastAPI](https://img.shields.io/badge/FastAPI-green.svg)](https://fastapi.tiangolo.com/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

[ English | [中文](README.zh.md) ]

Web-based Gemini models wrapped into an OpenAI-compatible API. Powered by [HanaokaYuzu/Gemini-API](https://github.com/HanaokaYuzu/Gemini-API).

**Call Gemini's web-based models via API without an API Key, completely free!**
**Call Gemini's web-based models via API without an API Key, completely free!**

## Features

- **🔐 No Google API Key Required**: Use web cookies to freely access Gemini's models via API.
- **🔍 Google Search Included**: Get up-to-date answers using web-based Gemini's search capabilities.
- **💾 Conversation Persistence**: LMDB-based storage supporting multi-turn conversations.
- **🖼️ Multi-modal Support**: Support for handling text, images, and file uploads.
- **⚖️ Multi-account Load Balancing**: Distribute requests across multiple accounts with per-account proxy settings.
- **No Google API Key Required**: Use web cookies to freely access Gemini's models via API.
- **Google Search Included**: Get up-to-date answers using web-based Gemini's search capabilities.
- **Conversation Persistence**: LMDB-based storage supporting multi-turn conversations.
- **Multi-modal Support**: Support for handling text, images, and file uploads.
- **Multi-account Load Balancing**: Distribute requests across multiple accounts with per-account proxy settings.

## Quick Start

Expand All @@ -25,7 +25,7 @@ Web-based Gemini models wrapped into an OpenAI-compatible API. Powered by [Hanao
### Prerequisites

- Python 3.13
- Google account with Gemini access on web
- Google account with Gemini access on web (Enable **[Gemini Apps activity](https://myactivity.google.com/product/gemini)** for best conversation persistence)
- `secure_1psid` and `secure_1psidts` cookies from Gemini web interface

### Installation
Expand Down Expand Up @@ -57,6 +57,7 @@ gemini:
secure_1psid: "YOUR_SECURE_1PSID_HERE"
secure_1psidts: "YOUR_SECURE_1PSIDTS_HERE"
proxy: null # Optional proxy URL (null/empty keeps direct connection)
impersonate: null # Optional browser impersonation target (null uses library default)
```

> [!NOTE]
Expand Down Expand Up @@ -96,7 +97,7 @@ These endpoints are designed to be compatible with OpenAI's API structure, allow
### Utility Endpoints

- **`GET /health`**: Health check endpoint. Returns the status of the server, configured Gemini clients, and conversation storage.
- **`GET /images/{filename}`**: Internal endpoint to serve generated images. Requires a valid token (automatically included in image URLs returned by the API).
- **`GET /media/{filename}`**: Internal endpoint to serve generated media. Requires a valid token (automatically included in image URLs returned by the API).

## Docker Deployment

Expand Down Expand Up @@ -180,6 +181,10 @@ export CONFIG_GEMINI__CLIENTS__0__SECURE_1PSIDTS="your-secure-1psidts"
# Override optional proxy settings for client 0
export CONFIG_GEMINI__CLIENTS__0__PROXY="socks5://127.0.0.1:1080"

# Override browser impersonation for client 0
export CONFIG_GEMINI__CLIENTS__0__IMPERSONATE="chrome"


# Override conversation storage size limit
export CONFIG_STORAGE__MAX_SIZE=268435456 # 256 MB
```
Expand All @@ -204,13 +209,35 @@ To use Gemini-FastAPI, you need to extract your Gemini session cookies:
- `__Secure-1PSID`
- `__Secure-1PSIDTS`

> [!IMPORTANT]
> **Enable [Gemini Apps activity](https://myactivity.google.com/product/gemini)** to ensure stable conversation persistence.
>
> While active chat turns may work temporarily without it, any transient error, TLS session restart, or server reboot can cause Google to expire the conversation metadata. If this setting is disabled, the model will **completely lose the context of your multi-turn conversation**, making old threads unreachable even if they are stored in your local LMDB.

> [!TIP]
> For detailed instructions, refer to the [HanaokaYuzu/Gemini-API authentication guide](https://github.com/HanaokaYuzu/Gemini-API?tab=readme-ov-file#authentication).

### Proxy Settings

Each client entry can be configured with a different proxy to work around rate limits. Omit the `proxy` field or set it to `null` or an empty string to keep a direct connection.

### Browser Impersonation

Each client can optionally set an `impersonate` value to control the TLS/HTTP fingerprint used by `curl_cffi`.

- Set to `null` (default) to use the library's default.
- Set to any value supported by [`curl_cffi`'s `BrowserTypeLiteral`](https://github.com/lexiforest/curl_cffi).
- The value is validated at startup; an invalid value will prevent the server from starting.

```yaml
gemini:
clients:
- id: "client-a"
impersonate: "chrome" # Use Chrome fingerprint
- id: "client-b"
impersonate: null # Use library default
```

### Custom Models

You can define custom models in `config/config.yaml` or via environment variables.
Expand Down
Loading