We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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:
Hi, can you provide more information and print out what the error details, if any, you see?
Sorry, something went wrong.
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?
No branches or pull requests
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: