-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use proxy-based proxy clients on google.generativeai #188
Comments
It is for llamaindex, but I made it. |
没有找到prox的方法 |
There are a couple of ways you can proxy with the SDK. You can force the SDK to use HTTP traffic (it's gRPC by default) with If you have a fake endpoint or want to send the traffic to a different host directly, you can use |
Are you saying that I can now use |
It's not built specifically for reverse proxying, we use it for staging/preprod endpoints internally, but you do you :) |
This only works for |
see #610 (comment) |
Just give two OOTB sample of using proxy import os
import google.generativeai as gai
os.environ["GRPC_PROXY"] = "http://127.0.0.1:10809" #10809 is the default proxy port of v2rayN :p, clash verge should be different
gai.configure(api_key='YOUR GOOGLE API KEY')
flash = gai.GenerativeModel("gemini-1.5-flash")
resp = flash.generate_content("Explain Gemini to me like I am a kid")
Markdown(resp.text) This is the most convenient one (default grpc). Another is to use additional proxy accordingly import os
import google.generativeai as gai
os.environ["ALL_PROXY"] = "http://127.0.0.1:10809" #I have tested 'HTTP_PROXY' but it doesnt work 我试了HTTP_PROXY但没效果
gai.configure(api_key='YOUR GOOGLE API KEY')
flash = gai.GenerativeModel("gemini-1.5-flash", transport='rest')
resp = flash.generate_content("Explain Gemini to me like I am a kid")
Markdown(resp.text) |
Description of the feature request:
In OpenAI's Python SDK, you can implement client-side proxying through the following operation
https://github.com/openai/openai-python#configuring-the-http-client
I am very curious about how I should implement the above operation in google.generativeai sdk?
What problem are you trying to solve with this feature?
I want to avoid using the system-wide global proxy as much as possible to achieve the above functionality
Any other information you'd like to share?
No response
The text was updated successfully, but these errors were encountered: