File size: 1,313 Bytes
71e7552
fc97dd8
71e7552
 
 
 
 
 
 
 
62de77b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54db0a4
62de77b
 
 
 
 
 
 
 
 
 
 
 
 
 
fc98c52
62de77b
 
54db0a4
62de77b
 
 
 
8444542
 
 
 
 
 
 
 
 
 
54db0a4
8444542
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: stream-chatapi
emoji: 🔥
colorFrom: purple
colorTo: purple
sdk: docker
pinned: false
license: apache-2.0
---

## How to Use the API using python

### Create a Token
```
import requests

headers = {
    'accept': 'application/json',
    'Content-Type': 'application/json',
}

json_data = {
    "ref_key": "F0eeQ419wvoCSPH7KBmsd9OiVkF0W0DxK1XE9T3BlbkFJ0",
    "expiry_date": "2023-06-15"
}

response = requests.post('https://subhrajit-katonic-stream-chatapi.hf.space/create', headers=headers, json=json_data)
token = response.json()
```
### calling open API (text-davinci-002/gpt-3.5-turbo)
```
import requests

headers = {
    'accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': 'Bearer TOKEN',
}

json_data = {
    'message': 'write a joke for me',
    "openAI_token": OPENAI_KEY
}

response = requests.post('https://subhrajit-katonic-stream-chatapi.hf.space/chat', headers=headers, json=json_data)
if response.status_code == 200:
    print(response.json())
```

### Check list of tokens
```
import requests

headers = {
    'accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': 'Bearer TOKEN
}

response = requests.get('https://subhrajit-katonic-stream-chatapi.hf.space/list', headers=headers)
print(response.json())

```