File size: 984 Bytes
71e7552
 
 
 
 
 
 
 
 
 
62de77b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: 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('http://0.0.0.0:8000/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,
    "model_name" : "gpt-3.5-turbo"
}

response = requests.post('http://0.0.0.0:8000/chat', headers=headers, json=json_data)
if response.status_code == 200:
    print(response.json())
```