@Shivang Pandey Which QuickStart are you following in this case? Is it this one for python from the documentation.
This error indicates that you are passing the incorrect subscription key or key of your translator resource. Here is a screen shot of the response if you pass the correct details.
The endpoint in the above request should be
key = "your_key"
endpoint = "https://api.cognitive.microsofttranslator.com"
The key is the key available on your translator resource that is available from the keys and endpoints page from azure portal.
If you are using a multi service cognitive resource, you should pass the location header else it will not be required with the above endpoint. I hope this helps!!
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.