Simulate the Google Gemini API
This sample contains mock responses that allow you to simulate the Google Gemini API using Dev Proxy. Simulating the Gemini API is useful when you're working on parts of your app that don't require a real response from Gemini and don't want to incur unnecessary API costs.
Simulate the Google Gemini API
Summary
This sample contains mock responses that allow you to simulate the Google Gemini API using Dev Proxy. Simulating the Gemini API is useful when you’re working on parts of your app that don’t require a real response from Gemini and don’t want to incur unnecessary API costs.

Compatibility
Contributors
Version history
| Version | Date | Comments |
|---|---|---|
| 1.0 | February 22, 2026 | Initial release |
Minimal path to awesome
- Get the sample:
-
Download just this sample:
npx gitload-cli https://github.com/pnp/proxy-samples/tree/main/samples/simulate-google-geminior
-
Download as a .ZIP file and unzip it, or
-
Clone this repository
-
- Start Dev Proxy by running
devproxy - Test with:
curl -ikx http://127.0.0.1:8000 "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=test-api-key" -d '{"contents":[{"parts":[{"text":"Hello"}]}]}' -H "content-type: application/json"
Features
Using this sample you can:
- Simulate responses from the Google Gemini
generateContentendpoint without needing an API key - Simulate responses from the
countTokensendpoint - Simulate responses from the
embedContentendpoint - Simulate listing and retrieving model information
- Avoid incurring API costs during development and testing
- Develop and test your app’s UI and integration logic with realistic Gemini response shapes
The mock responses follow the official Google Gemini API response format, including usageMetadata with token counts and safetyRatings.
To customize the mock responses, edit the .devproxy/mocks.json file. You can add additional mock responses for different scenarios, such as function calling, thinking, or multi-turn conversations.
Help
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
You can try looking at issues related to this sample to see if anybody else is having the same issues.
If you encounter any issues using this sample, create a new issue.
Finally, if you have an idea for improvement, make a suggestion.
Disclaimer
THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.