Language and Vision APIs in Practice
Call the Computer Vision API to analyse an image and the Text Analytics API to extract sentiment and key phrases from customer reviews using REST requests.
Language and Vision APIs in Practice is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Calling the Computer Vision API
The Computer Vision API (/vision/v3.2/analyze) analyses an image URL or binary stream and returns a rich JSON response containing detected objects, a scene description in natural language, dominant colours, and whether the image contains adult content. You specify which visual features you want — Categories, Description, Objects, Tags, Faces, Color, Adult — to control what the API computes and pay only for what you use.
# Analyse an image URL with Computer Vision
curl -X POST 'https://myVision.cognitiveservices.azure.com/vision/v3.2/analyze?visualFeatures=Description,Objects,Tags' \
-H 'Ocp-Apim-Subscription-Key: <key>' \
-H 'Content-Type: application/json' \
-d '{"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}'OCR: Reading Text from Images
The Read API (/vision/v3.2/read/analyze) is the recommended OCR endpoint for extracting text from images and PDFs. Unlike the older /ocr endpoint, the Read API is asynchronous — you submit the image, get back an operation URL, poll it until complete, and then retrieve the result. It supports printed and handwritten text in 164 languages, preserves the reading order of text blocks, and handles rotated or low-resolution images better than the synchronous OCR endpoint.
# Step 1: Submit image for reading
curl -X POST 'https://myVision.cognitiveservices.azure.com/vision/v3.2/read/analyze' \
-H 'Ocp-Apim-Subscription-Key: <key>' \
-H 'Content-Type: application/json' \
-d '{"url": "https://example.com/invoice.jpg"}'
# Returns: Operation-Location header with result URL
# Step 2: Poll for result
curl 'https://myVision.cognitiveservices.azure.com/vision/v3.2/read/analyzeResults/<operation-id>' \
-H 'Ocp-Apim-Subscription-Key: <key>'Sentiment Analysis with Text Analytics
The Sentiment Analysis endpoint (/text/analytics/v3.1/sentiment) returns a sentiment label (positive, negative, neutral, or mixed) and a confidence score between 0 and 1 for each document submitted. It also provides opinion mining (aspect-based sentiment) that identifies which specific aspects of a product or service a reviewer is commenting on and the sentiment towards each aspect — for example, detecting that a restaurant review is positive about food but negative about service.
# Sentiment analysis request
curl -X POST 'https://myLanguage.cognitiveservices.azure.com/text/analytics/v3.1/sentiment?opinionMining=true' \
-H 'Ocp-Apim-Subscription-Key: <key>' \
-H 'Content-Type: application/json' \
-d '{
"documents": [
{"id": "1", "language": "en", "text": "The food was great but the service was terrible."}
]
}'Key Phrase Extraction
Key phrase extraction identifies the main topics and concepts in a body of text, returning them as a list of phrases. For a customer support email, it might return phrases like delivery delay, order confirmation, and refund request. This is useful for automatically tagging support tickets, summarising documents for search indexing, or prioritising content in a knowledge base. The API processes up to 1,000 documents per request and supports 10+ languages.
# Key phrase extraction
curl -X POST 'https://myLanguage.cognitiveservices.azure.com/text/analytics/v3.1/keyPhrases' \
-H 'Ocp-Apim-Subscription-Key: <key>' \
-H 'Content-Type: application/json' \
-d '{
"documents": [
{"id": "1", "language": "en",
"text": "Azure offers scalable storage, compute, and AI services for enterprises."}
]
}'Named Entity Recognition
Named Entity Recognition (NER) identifies and categorises mentions of entities in text — such as Person, Organisation, Location, DateTime, Quantity, URL, and Email. The PII detection variant (Personal Identifiable Information) specifically finds and can redact sensitive data like credit card numbers, social security numbers, and phone numbers. PII detection is useful for automatically anonymising data before storing or processing it for analytics.
# PII entity recognition
curl -X POST 'https://myLanguage.cognitiveservices.azure.com/text/analytics/v3.1/entities/recognition/pii' \
-H 'Ocp-Apim-Subscription-Key: <key>' \
-H 'Content-Type: application/json' \
-d '{
"documents": [
{"id": "1", "language": "en",
"text": "Please contact John Smith at john@example.com for refund."}
]
}'Azure AI Translator in Practice
The Translator API (/translate) converts text between 100+ languages in a single REST call. You pass the source text, specify one or more target language codes, and receive the translated text with detected source language. The API also provides transliteration (converting script, e.g. Arabic to Latin characters) and dictionary lookup for word-level translation alternatives. Translator supports batching up to 100 documents per request, making it efficient for large-scale content localisation.
# Translate English text to French and Spanish
curl -X POST 'https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=fr&to=es' \
-H 'Ocp-Apim-Subscription-Key: <key>' \
-H 'Ocp-Apim-Subscription-Region: eastus' \
-H 'Content-Type: application/json' \
-d '[{"text": "Hello, how are you?"}]'Custom Vision: Training Your Own Model
Azure AI Custom Vision allows you to train an image classification or object detection model using your own labelled images without writing ML code. In the Custom Vision portal, you upload images, tag them, and click Train. The service trains a model and returns performance metrics (Precision, Recall, AP). You then test the model with new images and publish it as a prediction endpoint. Models can also be exported as ONNX or CoreML for on-device inference.
# Create a Custom Vision project via CLI
az cognitiveservices account create \
--name myCustomVision \
--resource-group myRG \
--kind CustomVision.Training \
--sku S0 \
--location eastusLanguage Understanding (CLU)
Conversational Language Understanding (CLU) is the successor to LUIS. You define intents (what the user wants, e.g. BookFlight, GetWeather) and entities (data to extract, e.g. destination city, travel date), provide example utterances for each intent, train the model, and deploy it. Applications call the CLU prediction endpoint to classify user input into the correct intent and extract entities. CLU powers the understanding layer of virtual assistants and chatbots.
Handling API Errors and Throttling
Azure AI Services APIs return standard HTTP status codes. 400 Bad Request means malformed input (e.g. document too long — Text Analytics supports up to 5,120 characters per document). 401 Unauthorized means an invalid or missing API key. 429 Too Many Requests means you have exceeded your service quota — implement exponential backoff with jitter and retry. For production, consider a dedicated resource (not the free tier) and request quota increases via the Azure portal if you need higher throughput.
Integrating AI Services with Logic Apps
Azure AI Services can be integrated with Azure Logic Apps using built-in connectors, enabling no-code AI workflows. For example: when a new email arrives → extract attachments → call the Computer Vision Read API to OCR text from attachments → call Text Analytics to extract key phrases → write results to a SharePoint list. Logic Apps includes connectors for Cognitive Services (Language, Vision, Translator) that manage authentication and API calls without writing REST request code.
Using AI Services with Python SDK
Microsoft publishes official Python packages for each AI Service. Install azure-ai-textanalytics for Language APIs or azure-cognitiveservices-vision-computervision for Vision. The SDK handles authentication, serialisation, and retry logic automatically. Authenticate using an AzureKeyCredential or a DefaultAzureCredential (managed identity aware). Using the SDK is preferred over raw HTTP requests in production code as it provides type safety and easier upgrades when API versions change.
# Python — Text Analytics sentiment analysis
from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential
client = TextAnalyticsClient(
endpoint='https://myLanguage.cognitiveservices.azure.com/',
credential=AzureKeyCredential('<key>')
)
docs = ['The product quality exceeded my expectations.']
result = client.analyze_sentiment(docs)
for doc in result:
print(doc.sentiment, doc.confidence_scores)Quick Check
Test your understanding of Microsoft Azure Fundamentals (AZ-900) concepts from this lesson.
Lesson Recap
In this lesson you learned: the Computer Vision API analyses images for objects, descriptions, and OCR text (using the async Read API), Text Analytics APIs extract sentiment, key phrases, and PII from text, and Translator API converts text between 100+ languages in a single call. Next up we explore Azure Machine Learning Studio for training and deploying custom ML models.
Frequently asked questions
Is the “Language and Vision APIs in Practice” lesson free?
Yes — the full text of “Language and Vision APIs in Practice” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.
What will I learn in “Language and Vision APIs in Practice”?
Call the Computer Vision API to analyse an image and the Text Analytics API to extract sentiment and key phrases from customer reviews using REST requests. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cloud & IT Cert Prep?
No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Language and Vision APIs in Practice” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cloud & IT Cert Prep lesson?
Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Azure Cognitive Services Overview
- Language and Vision APIs in Practice
- Azure Machine Learning Studio
- Azure OpenAI Service