Skip to content
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

I need to use proxy because api doesnt support in my region #29

Open
byjameson opened this issue Mar 9, 2024 · 2 comments
Open

I need to use proxy because api doesnt support in my region #29

byjameson opened this issue Mar 9, 2024 · 2 comments

Comments

@byjameson
Copy link

I need to use proxy because api doesnt support in my region, where should i fix it ? i couldnt find it? where is curl?

@erdemkose
Copy link
Collaborator

erdemkose commented Mar 9, 2024

You need a proxy server in one of the supported countries. Then you can specify the proxy server address while building your Gemini API client. You can find the configuration in the Readme file.

https://github.com/gemini-api-php/client#using-your-own-http-client

@nalbantferhat
Copy link

I have tested proxy with curl command below

curl -H 'Content-Type: application/json' -d '{"contents":[{"parts":[{"text":"Explain how AI works"}]}]}' -x 'http://proxy_username:[email protected]:2333' 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=api_key' --verbose

and it has been given me the verbose response below

  • Trying 82.163.224.186:2333...
  • Connected to (nil) (82.163.224.186) port 2333 (#0)
  • allocate connect buffer!
  • Establish HTTP proxy tunnel to generativelanguage.googleapis.com:443
  • Proxy auth using Basic with user 'proxy_username'

CONNECT generativelanguage.googleapis.com:443 HTTP/1.1
Host: generativelanguage.googleapis.com:443
Proxy-Authorization: Basic ZmVyaGF0bmFsYmFudDIwMjQ6U2VyaGFuOTY0MzEzNkM=
User-Agent: curl/7.81.0
Proxy-Connection: Keep-Alive

< HTTP/1.1 200 Connection established
<

  • Proxy replied 200 to CONNECT request
  • CONNECT phase completed!
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • CAfile: /etc/ssl/certs/ca-certificates.crt
  • CApath: /etc/ssl/certs
  • TLSv1.0 (OUT), TLS header, Certificate Status (22):
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • TLSv1.2 (IN), TLS header, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Server hello (2):
  • TLSv1.2 (IN), TLS header, Finished (20):
  • TLSv1.2 (IN), TLS header, Supplemental data (23):
  • TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
  • TLSv1.3 (IN), TLS handshake, Certificate (11):
  • TLSv1.3 (IN), TLS handshake, CERT verify (15):
  • TLSv1.3 (IN), TLS handshake, Finished (20):
  • TLSv1.2 (OUT), TLS header, Finished (20):
  • TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
  • TLSv1.2 (OUT), TLS header, Supplemental data (23):
  • TLSv1.3 (OUT), TLS handshake, Finished (20):
  • SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
  • ALPN, server accepted to use h2
  • Server certificate:
  • subject: CN=upload.video.google.com
  • start date: Jul 30 12:49:45 2024 GMT
  • expire date: Oct 22 12:49:44 2024 GMT
  • subjectAltName: host "generativelanguage.googleapis.com" matched cert's "*.googleapis.com"
  • issuer: C=US; O=Google Trust Services; CN=WR2
  • SSL certificate verify ok.
  • Using HTTP2, server supports multiplexing
  • Connection state changed (HTTP/2 confirmed)
  • Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
  • TLSv1.2 (OUT), TLS header, Supplemental data (23):
  • TLSv1.2 (OUT), TLS header, Supplemental data (23):
  • TLSv1.2 (OUT), TLS header, Supplemental data (23):
  • Using Stream ID: 1 (easy handle 0x5d6043d85eb0)
  • TLSv1.2 (OUT), TLS header, Supplemental data (23):

POST /v1beta/models/gemini-1.5-flash-latest:generateContent?key=api_key HTTP/2
Host: generativelanguage.googleapis.com
user-agent: curl/7.81.0
accept: /
content-type: application/json
content-length: 58

  • TLSv1.2 (OUT), TLS header, Supplemental data (23):
  • We are completely uploaded and fine
  • TLSv1.2 (IN), TLS header, Supplemental data (23):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • old SSL session ID is stale, removing
  • TLSv1.2 (IN), TLS header, Supplemental data (23):
  • TLSv1.2 (OUT), TLS header, Supplemental data (23):
  • TLSv1.2 (IN), TLS header, Supplemental data (23):
  • TLSv1.2 (IN), TLS header, Supplemental data (23):
    < HTTP/2 400
    < vary: X-Origin
    < vary: Referer
    < vary: Origin,Accept-Encoding
    < content-type: application/json; charset=UTF-8
    < date: Thu, 01 Aug 2024 07:48:05 GMT
    < server: scaffolding on HTTPServer2
    < cache-control: private
    < x-xss-protection: 0
    < x-frame-options: SAMEORIGIN
    < x-content-type-options: nosniff
    < server-timing: gfet4t7; dur=1223
    < alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
    < accept-ranges: none
    <
  • TLSv1.2 (IN), TLS header, Supplemental data (23):
    {
    "error": {
    "code": 400,
    "message": "Gemini API free tier is not available in your country. Please enable billing on your project in Google AI Studio.",
    "status": "FAILED_PRECONDITION"
    }
    }
  • TLSv1.2 (IN), TLS header, Supplemental data (23):
  • TLSv1.2 (OUT), TLS header, Supplemental data (23):
  • Connection #0 to host (nil) left intact

Do you know any idea about what is going wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants