-
Notifications
You must be signed in to change notification settings - Fork 429
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
Failed to retrieve data. HTTP Status: 403 #64
Labels
status:awaiting response
Awaiting a response from the author
Comments
Hi, can you provide more information and print out what the error details, if any, you see? |
Hi, there's nothing wrong with your code, it works fine for me. Are you sure your API key is good and that you're in an available region? |
MarkDaoust
added
the
status:awaiting response
Awaiting a response from the author
label
Apr 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import requests
import json
google_api_key = 'my api key'
url = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=' + google_api_key
data = {
"contents": [{
"parts": [{
"text": "Write a story about a magic backpack."
}]
}]
}
headers = {
'Content-Type': 'application/json',
"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print("Response from server:", response.json())
else:
print("Failed to retrieve data. HTTP Status:", response.status_code)
What should i do to solve my problem with HTTP Status: 403?
The text was updated successfully, but these errors were encountered: