turn this into a python post: curl --location 'https://api.pawan.krd/v1/embeddings' \…
- User
turn this into a python post:
curl --location 'https://api.pawan.krd/v1/embeddings'
--header 'Authorization: Bearer pk-ZCUGJGGHDKMdzhgioODLCCydrnyqHbNpWpCdHhyADRrFskcn'
--header 'Content-Type: application/json'
--data '{ "model": "text-embedding-ada-002", "input": "The food was delicious and the waiter..." } - Assistant
Certainly! Below is an example of how you could translate the given
curlcommand into a Python script using therequestslibrary to make a POST request to the API:pythonimport requests url = 'https://api.pawan.krd/v1/embeddings' headers = { 'Authorization': 'Bearer pk-ZCUGJGGHDKMdzhgioODLCCydrnyqHbNpWpCdHhyADRrFskcn', 'Content-Type': 'application/json' } data = { "model": "text-embedding-ada-002", "input": "The food was delicious and the waiter..." } response = requests.post(url, json=data, headers=headers) # Handle the response if response.status_code == 200: result = response.json() print(result) else: print(f"Failed to get response: {response.status_code}, {response.text}")