File size: 1,533 Bytes
c7b3e89
 
 
b4b4823
 
c7b3e89
b4b4823
c7b3e89
b4b4823
c7b3e89
 
b4b4823
c7b3e89
b4b4823
c7b3e89
 
 
 
 
b4b4823
c7b3e89
b4b4823
c7b3e89
 
b4b4823
 
 
 
 
 
 
a725254
b4b4823
 
 
c7b3e89
b4b4823
 
c7b3e89
b4b4823
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
import json

# Define the URL for the API
url = 'https://ap-northeast-2.apistage.ai/v1/web/demo/chat/completions'

# Define the headers (the same ones from the curl command)
headers = {
    'accept': '*/*',
    'accept-language': 'en-US,en;q=0.9,ru;q=0.8',
    'content-type': 'application/json',
    'origin': 'https://console.upstage.ai',
    'priority': 'u=1, i',
    'referer': 'https://console.upstage.ai/',
    'sec-ch-ua': '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'cross-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
    'x-csrf-token': 'MTczMjAyMjY0MzI4OS5hMjM5OTFmZGRiYmQ1Yjk4ODFjY2Q0NDhlYTk0YTdiODg5OWYzZWY1NWFlOWQ2ZjEzOWU3ODkwNmMzM2I4MjM0'
}

# Define the data (payload) to be sent in the POST request
data = {
    'stream': True,
    'messages': [
        {
            'role': 'user',
            'content': 'Hi'
        }
    ],
    'model': 'solar-pro'
}

# Send the POST request
response = requests.post(url, headers=headers, json=data)

# Check the status of the response and print the result
if response.status_code == 200:
    print('Response received successfully:')
    print(json.dumps(response.json(), indent=2))
else:
    print(f'Failed to get a response. Status code: {response.status_code}')
    print(response.text)