2023-05-16 12:06:21 +02:00
|
|
|
import requests
|
|
|
|
|
|
2023-07-18 17:51:13 +02:00
|
|
|
proxy_url = "http://64.225.4.12:9991" # Replace with your actual proxy URL and port
|
2023-05-16 12:06:21 +02:00
|
|
|
|
2023-07-18 17:51:13 +02:00
|
|
|
api_key = "S"
|
|
|
|
|
model_name = "chat-bison-001"
|
|
|
|
|
api_url = f"https://autopush-generativelanguage.sandbox.googleapis.com/v1beta2/models/{model_name}:generateMessage?key={api_key}"
|
2023-05-16 12:06:21 +02:00
|
|
|
|
2023-07-18 17:51:13 +02:00
|
|
|
headers = {"Content-Type": "application/json"}
|
2023-05-16 12:06:21 +02:00
|
|
|
|
|
|
|
|
data = {
|
2023-07-18 17:51:13 +02:00
|
|
|
"prompt": {"messages": [{"content": "hi"}]},
|
|
|
|
|
"temperature": 0.1,
|
|
|
|
|
"candidateCount": 1,
|
2023-05-16 12:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-18 17:51:13 +02:00
|
|
|
proxies = {"http": proxy_url, "https": proxy_url}
|
2023-05-16 12:06:21 +02:00
|
|
|
|
|
|
|
|
response = requests.post(api_url, headers=headers, json=data, proxies=proxies)
|
|
|
|
|
|
|
|
|
|
if response.status_code == 200:
|
|
|
|
|
result = response.json()
|
|
|
|
|
print(result)
|
|
|
|
|
else:
|
2023-07-18 17:51:13 +02:00
|
|
|
print(f"Request failed with status code {response.status_code}")
|