--- 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()) ```