ERROR API text analysis

Benjamin Scemama 0 Reputation points

Hello. I would like to use the text analysis api of microsoft azure to extract keywords from a text and also to make a summary of the same text. However I have an error. Could someone help me to solve it? (my text document is called 'subtitles_text')


# Utilisation de l'API Analyse de Texte de Microsoft Azure pour générer des phrases clés
subscription_key = "MYAPIKEY"
endpoint = ""
headers = {"Ocp-Apim-Subscription-Key": subscription_key}

data = {"documents": [{"id": "1", "language": "fr", "text": subtitles_text}]}
response =, headers=headers, json=data)
key_phrases = json.loads(response.text)["documents"][0]["key_phrases"]
summary = json.loads(response.text)["documents"][0]["summary"]

# Enregistrement des phrases clés dans un fichier .txt
with open("phrases_cles.txt", "w") as f:

# Enregistrement du résumer dans un fichier .txt
with open("resumer.txt", "w") as f:

KeyError                                  Traceback (most recent call last)
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,217 questions
{count} votes