How can enable to cache for Gemini? #827

Closed
opened 2026-02-16 10:20:38 -05:00 by yindo · 4 comments
Owner

Originally created by @joneqian on GitHub (Nov 24, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

How can enable to cache for Gemini?

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @joneqian on GitHub (Nov 24, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. How can enable to cache for Gemini? ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the enhancementquestion labels 2026-02-16 10:20:38 -05:00
yindo closed this issue 2026-02-16 10:20:38 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 24, 2025):

There’s currently no user-facing setting or documented way to enable prompt/response caching for Gemini in Dify. The platform does implement automatic in-memory caching for model schemas—including Gemini—using a central cache key, but this only speeds up model metadata lookups and doesn’t cache actual prompt responses or completions see code reference.

For file uploads (like video/audio), Gemini models use Google’s upload file API, which does cache uploaded files for efficiency, but this is specific to file handling—not general LLM prompt caching details.

If you’re looking for prompt/response caching to reduce API usage or costs, this isn’t currently configurable or documented for Gemini in Dify. Users have requested more clarity and options, so it’s worth watching for future updates or contributing to the documentation if this feature is important discussion.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Nov 24, 2025): <!-- Answer --> There’s currently no user-facing setting or documented way to enable prompt/response caching for Gemini in Dify. The platform does implement automatic in-memory caching for model schemas—including Gemini—using a central cache key, but this only speeds up model metadata lookups and doesn’t cache actual prompt responses or completions [see code reference](https://github.com/langgenius/dify/blob/bcbd3de33647f308385ce998a92980dfb0d00e6b/api/core/model_runtime/model_providers/model_provider_factory.py#L24-L348). For file uploads (like video/audio), Gemini models use Google’s upload file API, which does cache uploaded files for efficiency, but this is specific to file handling—not general LLM prompt caching [details](https://github.com/langgenius/dify/pull/11497). If you’re looking for prompt/response caching to reduce API usage or costs, this isn’t currently configurable or documented for Gemini in Dify. Users have requested more clarity and options, so it’s worth watching for future updates or contributing to the documentation if this feature is important [discussion](https://github.com/langgenius/dify/issues/23886#issuecomment-3186596974). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/8dad324f-5341-4c93-8cd7-c861ad3e5ad9?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8dad324f-5341-4c93-8cd7-c861ad3e5ad9?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8dad324f-5341-4c93-8cd7-c861ad3e5ad9?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8dad324f-5341-4c93-8cd7-c861ad3e5ad9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8dad324f-5341-4c93-8cd7-c861ad3e5ad9?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8dad324f-5341-4c93-8cd7-c861ad3e5ad9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8dad324f-5341-4c93-8cd7-c861ad3e5ad9?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=There%E2%80%99s%20currently%20no%20user-facing%20setting%20or%20documented%20way%20to%20enable%20prompt/response%20caching%20for%20Gemini%20in%20Dify.%20The%20platform%20does%20implement%20automatic%20in-memory%20caching%20for%20model%20schemas%E2%80%94including%20Gemini%E2%80%94using%20a%20central%20cache%20key%2C%20but%20this%20only%20speeds%20up%20model%20metadata%20lookups%20and%20doesn%E2%80%99t%20cache%20actual%20prompt%20responses%20or%20completions%C2%A0%5Bsee%20code%20reference%5D%28https%3A//github.com/langgenius/dify/blob/bcbd3de33647f308385ce998a92980dfb0d00e6b/api/core/model_runtime/model_providers/model_provider_factory.py%23L24-L348%29.%0A%0AFor%20file%20uploads%20%28like%20video/audio%29%2C%20Gemini%20models%20use%20Google%E2%80%99s%20upload%20file%20API%2C%20which%20does%20cache%20uploaded%20files%20for%20efficiency%2C%20but%20this%20is%20specific%20to%20file%20handling%E2%80%94not%20general%20LLM%20prompt%20caching%C2%A0%5Bdetails%5D%28https%3A//github.com/langgenius/dify/pull/11497%29.%0A%0AIf%20you%E2%80%99re%20looking%20for%20prompt/response%20caching%20to%20reduce%20API%20usage%20or%20costs%2C%20this%20isn%E2%80%99t%20currently%20configurable%20or%20documented%20for%20Gemini%20in%20Dify.%20Users%20have%20requested%20more%20clarity%20and%20options%2C%20so%20it%E2%80%99s%20worth%20watching%20for%20future%20updates%20or%20contributing%20to%20the%20documentation%20if%20this%20feature%20is%20important%C2%A0%5Bdiscussion%5D%28https%3A//github.com/langgenius/dify/issues/23886%23issuecomment-3186596974%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2121)
Author
Owner

@joneqian commented on GitHub (Nov 24, 2025):

I think most people need this feature.

@joneqian commented on GitHub (Nov 24, 2025): I think most people need this feature.
Author
Owner

@nadazero commented on GitHub (Dec 1, 2025):

gemini 2.5以上的模型API自动支持隐式调用cache,所以相当于默认就开启了。
至于显示调用cache,看了下API,相当麻烦,需要调用API去主动存数据,我不认为用起来很方便。

@nadazero commented on GitHub (Dec 1, 2025): gemini 2.5以上的模型API自动支持隐式调用cache,所以相当于默认就开启了。 至于显示调用cache,看了下API,相当麻烦,需要调用API去主动存数据,我不认为用起来很方便。
Author
Owner

@dosubot[bot] commented on GitHub (Dec 17, 2025):

Hi, @joneqian. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You inquired about enabling caching for Gemini, noting a lack of documentation or settings.
  • It was clarified that Dify uses in-memory caching for model metadata but does not currently support user-configurable prompt/response caching.
  • Another user mentioned that Gemini 2.5+ APIs have implicit cache calls by default, but explicit cache control is complex and not very practical.
  • You highlighted that many users likely need better caching options, indicating demand for this feature.

What's Next:

  • Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open.
  • Otherwise, I will automatically close this issue in 5 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Dec 17, 2025): Hi, @joneqian. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. Issue Summary: - You inquired about enabling caching for Gemini, noting a lack of documentation or settings. - It was clarified that Dify uses in-memory caching for model metadata but does not currently support user-configurable prompt/response caching. - Another user mentioned that Gemini 2.5+ APIs have implicit cache calls by default, but explicit cache control is complex and not very practical. - You highlighted that many users likely need better caching options, indicating demand for this feature. What's Next: - Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open. - Otherwise, I will automatically close this issue in 5 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#827