404 error: resource not found when using text analytics client library

Shimmur 1 Reputation point

I've used the code from the quickstart guide on using text analytics client library.

    documents = ['It was a bleak experience attending this language school for the exam. It was very hard to find. ']
    response = client.analyze_sentiment(documents=documents)[0]
    print("Document Sentiment: {}".format(response.sentiment))
    print("Overall scores: positive={0:.2f}; neutral={1:.2f}; negative={2:.2f} \n".format(

And I've implemented authentication using the following:

key = "1234556"
base_url = "https://myresource.cognitiveservices.azure.com/"
path = "/text/analytics/v3.0/sentiment"
endpoint = base_url + path

from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential

def authenticate_client():
    ta_credential = AzureKeyCredential(key)
    text_analytics_client = TextAnalyticsClient(
    return text_analytics_client

client = authenticate_client()

However I get the error: 404 Resource not found.
Do I need to add a dependency in my project folder somehow or something else is amiss?
Greatly appreciate any and all help and pointers.

Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
387 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,615 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,656 Reputation points

    @Shimmur Thanks for the question. We are able to get the sentiment successfully using client library. Here is the sample code for single and multiple documents to analyze sentiment.

    You can set endpoint and apiKey based on an environment variable, a configuration setting, or any way that works for your application.

    var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

    0 comments No comments