have a problem with Api connection to my app, in py. turned off firewall, testet and nothing no respose, Someone know whats going on ?
import requests
import os
# my API
api_key = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxx”
# example “prompt” (zastąp swoim tekstem)
prompt = “Napisz krótki wiersz o wiośnie.”
url = “https://api.gemini.google.com/v1/generateText”
headers = {
** “Authorization”: f"Bearer {api_key}"**
}
data = {
** “prompt”: prompt,**
** # Dodaj inne parametry żądania, jeśli są wymagane (sprawdź dokumentację)**
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
** print(“Sukces! Odpowiedź od API Gemini:”)**
** print(response.json()[‘generated_text’])**
else:
** print(f"Błąd: {response.status_code}")**
** print(response.text)**
Terminal:
File “C:\Users\User\anaconda3\Lib\site-packages\requests\adapters.py”, line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘api.gemini.google.com’, port=443): Max retries exceeded with url: /v1/generateText (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x000001A0E87930D0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed’))
PS C:\Users\User\Desktop\Projekt-ARC>