Azure AI API Overview and Functionality

Author

Reads 533

AI Multimodal Model
Credit: pexels.com, AI Multimodal Model

Azure AI API is a powerful tool that allows developers to build intelligent applications. It provides a wide range of AI capabilities, including computer vision, natural language processing, and machine learning.

Azure AI API is built on top of Microsoft's Azure cloud platform, which provides a scalable and secure infrastructure for AI development. This allows developers to focus on building their applications without worrying about the underlying infrastructure.

Azure AI API offers a variety of services, including Cognitive Services, Bot Framework, and Machine Learning. These services can be used to build a range of applications, from chatbots and virtual assistants to image recognition and predictive analytics.

Developers can access Azure AI API through a range of programming languages, including Python, Java, and C#. This makes it easy to integrate AI capabilities into existing applications.

Azure AI API Basics

The Azure AI API is a unified service that offers innovative computer vision capabilities, including image tagging, text extraction, and facial recognition. You can use it to analyze images, read text, and detect faces with prebuilt image tagging, text extraction with OCR, and responsible facial recognition.

Azure AI API supports various components, including createChatCompletionRequest, which can be one of the following: createChatCompletionRequest. You can also use Azure AI Model Inference API, which is currently supported in certain models deployed as Serverless API endpoints and Managed Online Endpoints.

To get started with Azure AI API, you can explore the reference section of the Azure AI model inference API to see parameters and options to consume models, including chat completions models, deployed by Azure AI Foundry and Azure Machine Learning studio.

Getting Started

Computer server in data center room
Credit: pexels.com, Computer server in data center room

To get started with the Azure AI Model Inference API, you can deploy supported models as Serverless API endpoints or Managed Online Endpoints.

The client library azure-ai-inference is a great starting point, as it supports inference for AI models deployed by Azure AI Foundry and Azure Machine Learning studio.

You can use the azure-ai-inference client library to consume predictions from Serverless API endpoints and Managed Compute endpoints.

The @azure-rest/ai-inference client library is another option, which also supports inference for AI models deployed by Azure AI Foundry and Azure Machine Learning studio.

The Azure.Ai.Inference client library is also available, supporting inference for AI models deployed by Azure AI Foundry and Azure Machine Learning studio.

To explore the reference section of the Azure AI model inference API, you can see the parameters and options for consuming models, including chat completions models, deployed by Azure AI Foundry and Azure Machine Learning studio.

You can use the same code to consume predictions from supported models, regardless of whether they're deployed as Serverless API endpoints or Managed Online Endpoints.

Helpful AI assistant

Shot of Computer Screen with Multicoloured Code
Credit: pexels.com, Shot of Computer Screen with Multicoloured Code

You can use Azure AI Vision to enhance your apps with innovative computer vision capabilities, such as image analysis and facial recognition.

Azure AI Model Inference API is currently supported in certain models deployed as Serverless API endpoints and Managed Online Endpoints. This means you can deploy any of the supported models and use the exact same code to consume their predictions.

The Azure AI Model Inference API is available in the following models: Cohere Embed V3 family of models, Cohere Command R family of models, Meta Llama 2 chat family of models, and many others.

Here are some of the Azure AI services you can use to build AI applications: Azure AI Search, Azure OpenAI, Bot Service, Content Safety, Custom Vision, and many more.

To use the Azure AI Model Inference API, you can use the client library azure-ai-inference, which supports Serverless API endpoints and Managed Compute endpoints.

The Azure AI Model Inference API has a variety of components, including Assistant, Thread, Message, Run, and Run Step.

Computer server in data center room
Credit: pexels.com, Computer server in data center room

You can use the chatCompletionRequestUserMessage component to create a chat completion request with user message, which includes content, role, and name properties.

Here's an example of the chatCompletionRequestUserMessage properties:

By following these guidelines and using the Azure AI services and components, you can build a helpful AI assistant that can enhance your apps and provide a better user experience.

Authentication

Azure AI API offers two primary methods for authentication: API Keys and Microsoft Entra ID. API Keys require including the API Key in the api-key HTTP header for all API requests, as shown in the Quickstart guide.

You can authenticate API calls using a Microsoft Entra token, which must be preceded by Bearer in the Authorization header. For example, Bearer YOUR_AUTH_TOKEN.

Azure AI services provide a layered security model that includes authentication with Microsoft Entra credentials, a valid resource key, and Azure Virtual Networks.

Here are the authentication types supported with Azure OpenAI On Your Data:

API Functionality

Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.
Credit: pexels.com, Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.

The Azure AI API offers a range of functionality that enables developers to build sophisticated applications. You can specify a particular function to call via the "chatCompletionFunctionCallOption" component, which forces the model to call that function.

The API also supports various modalities, including text completions, chat completions, and image embeddings. Text completions create a completion for the provided prompt and parameters, while chat completions create a model response for the given chat conversation.

Here are some of the modalities supported by the API:

Development Options

Customizing Azure AI services is a breeze, and you can do it without writing a single line of code. Most Azure AI services allow you to send data and receive insights without any customization.

You can send an image to the Azure AI Vision service to detect words and phrases or count the number of people in the frame. Alternatively, you can send an audio file to the Speech service and get transcriptions and translate the speech to text at the same time.

A Red Switch for an Artificial Intelligence System
Credit: pexels.com, A Red Switch for an Artificial Intelligence System

Azure offers a wide range of tools that are designed for different types of users. Designer-driven tools are the easiest to use and are quick to set up and automate, but might have limitations when it comes to customization.

You can use REST APIs and client libraries to gain more control and flexibility, but it requires more effort, time, and expertise to build a solution. This means you'll need to be comfortable working with modern programming languages like C#, Java, Python, JavaScript, or another popular programming language.

Here's a breakdown of the different tools and their requirements:

Models with Disparate Capabilities

Models with disparate capabilities can return specific errors when a parameter is not supported.

Each model decides whether to implement a general set of capabilities, as indicated by the Azure AI Model Inference API.

A specific error code, 422, is returned when a model can't support a specific parameter.

You can inspect the property details.loc to understand the location of the offending parameter.

The details.input property shows the value that was passed in the request, helping you identify the issue.

This allows you to adjust your request accordingly and try again, which I've found to be a helpful approach when working with models that have disparate capabilities.

Modalities

An artist’s illustration of artificial intelligence (AI). This image was inspired by neural networks used in deep learning. It was created by Novoto Studio as part of the Visualising AI pr...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image was inspired by neural networks used in deep learning. It was created by Novoto Studio as part of the Visualising AI pr...

The API provides various modalities that allow developers to consume predictions for different tasks. These modalities include getting information about the model deployed under the endpoint.

You can get info about the model, which returns the information about the model deployed under the endpoint. This is useful for understanding the capabilities and limitations of the model.

Text embeddings create an embedding vector representing the input text, which can be easily consumed by machine learning models and algorithms. This is achieved through the "Embeddings" API, which takes an input text and returns a vector representation of it.

Text embeddings are created through the "Embeddings" API, which takes an input text and returns a vector representation of it. The input text must not exceed the max input tokens for the model, which is 8,192 tokens for text-embedding-ada-002.

Text completions create a completion for the provided prompt and parameters. This modality is also part of the "Embeddings" API, which takes an input text and returns a vector representation of it.

An artist’s illustration of artificial intelligence (AI). This image depicts the potential of AI for society through 3D visualisations. It was created by Novoto Studio as part of the Visua...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image depicts the potential of AI for society through 3D visualisations. It was created by Novoto Studio as part of the Visua...

Chat completions create a model response for the given chat conversation. This modality is also part of the "Embeddings" API, which takes an input text and returns a vector representation of it.

Image embeddings create an embedding vector representing the input text and image. This modality is part of the "Modalities" API, which provides various ways to consume predictions for different tasks.

Here are the modalities provided by the API:

  • Get info: Returns the information about the model deployed under the endpoint.
  • Text embeddings: Creates an embedding vector representing the input text.
  • Text completions: Creates a completion for the provided prompt and parameters.
  • Chat completions: Creates a model response for the given chat conversation.
  • Image embeddings: Creates an embedding vector representing the input text and image.

Completions

Completions are a crucial part of the API functionality, allowing developers to generate responses to user input.

The API provides different types of completions, including text completions and chat completions. Text completions create a completion for the provided prompt and parameters, while chat completions create a model response for the given chat conversation.

To get started with completions, you'll need to understand the usage statistics. The completionUsage component provides information on the number of tokens used in the request, including prompt tokens, completion tokens, and total tokens.

An artist’s illustration of artificial intelligence (AI). This image depicts how AI could adapt to an infinite amount of uses. It was created by Nidia Dias as part of the Visualising AI pr...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image depicts how AI could adapt to an infinite amount of uses. It was created by Nidia Dias as part of the Visualising AI pr...

Here's a breakdown of the usage statistics:

Understanding these usage statistics will help you optimize your API requests and improve the overall performance of your application.

Translation

Translation is a powerful tool that can break language barriers and open up new possibilities for communication. You can use the Azure OpenAI API to transcribe and translate input audio into English text.

The API supports various formats for the output, including text, vtt, and srt. The response can be in the format of application/json or text/plain.

To create a translation request, you'll need to provide an audio file to translate, which is a required parameter. You can also provide an optional prompt in English to guide the model's style or continue a previous audio segment.

Here are the required parameters for creating a translation request:

The API also supports various options for customizing the translation process, including the response format and temperature. The temperature parameter controls the sampling temperature, which can affect the output's randomness and determinism.

To get the translated or transcribed text, you can use the createTranslationRequest object, which contains the translated or transcribed text as a string.

API Functionality

An artist's illustration of artificial intelligence (AI). This image represents storage of collected data in AI. It was created by Wes Cockx as part of the Visualising AI project launched ...
Credit: pexels.com, An artist's illustration of artificial intelligence (AI). This image represents storage of collected data in AI. It was created by Wes Cockx as part of the Visualising AI project launched ...

API Functionality is a crucial aspect of any application, and Azure AI Vision's API offers a wide range of functionalities that can enhance your apps with innovative computer vision capabilities. You can generate a batch of images from a text caption on a given DALL-E model deployment.

The API allows you to customize the image generation process by specifying the size of the generated images, which can be either 1024x1024, 1792x1024, or 1024x1792 pixels. You can also choose the number of images to generate, with a default value of 1.

The API returns the generated images in the format you specify, which can be either a URL that provides temporary access to download the images or a base64 encoded string. You can also get information about the content filtering results, including the category, severity level, and whether the content was filtered or not.

One of the key features of Azure AI Vision's API is its ability to automatically caption images with natural language, use smart crop, and classify images. This can be done using the image analysis feature, which is available in Vision Studio.

An artist’s illustration of artificial intelligence (AI). This image represents how machine learning is inspired by neuroscience and the human brain. It was created by Novoto Studio as par...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image represents how machine learning is inspired by neuroscience and the human brain. It was created by Novoto Studio as par...

Here's a summary of the API's image generation functionality:

You can also get information about the image generation process, including the prompt that was used to generate the image, the content filtering results, and the revised prompt if there was any revision.

Functions

Functions are an essential part of the API, allowing you to perform specific actions and tasks.

A function is defined by its name, description, and parameters, which are described as a JSON Schema object. You can specify a function via {"name": "my_function"} to force the model to call that function.

Functions can have parameters, which are defined as a JSON Schema object, and omitting parameters defines a function with an empty parameter list. The parameters can be of type json, text, srt, verbose_json, or vtt.

The API provides several types of functions, including chat completion functions, which can be called using the chatCompletionFunctionCallOption. This option specifies a particular function via {"name": "my_function"}.

An artist’s illustration of artificial intelligence (AI). This image depicts the potential of AI for society through 3D visualisations. It was created by Novoto Studio as part of the Visua...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image depicts the potential of AI for society through 3D visualisations. It was created by Novoto Studio as part of the Visua...

The chatCompletionFunctionCallOption has a single required field: name, which is a string that specifies the name of the function to call. The function name can be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Here is a list of the possible types of chat completion functions:

  • chatCompletionFunctionCallOption
  • chatCompletionFunctionCall
  • chatCompletionMessageToolCall
  • FunctionParameters

These functions can be used to perform various tasks, such as creating chat completions, text embeddings, and image embeddings. They can also be used to get information about the model deployed under the endpoint.

The chatCompletionFunctionCallOption and chatCompletionFunctionCall are deprecated and replaced by tool_calls, which have the same functionality but with a different name and structure.

Tool

The "Tool" functionality in API is quite fascinating. You can use streamlined inference clients in the language of your choice to consume predictions from models running the Azure AI model inference API.

One of the ways to work with the Azure AI services is by using designer-driven tools, which are the easiest to use and quick to set up and automate, but might have limitations when it comes to customization.

An artist’s illustration of artificial intelligence (AI). This image represents how machine learning is inspired by neuroscience and the human brain. It was created by Novoto Studio as par...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This image represents how machine learning is inspired by neuroscience and the human brain. It was created by Novoto Studio as par...

You can send an image to the Azure AI Vision service to detect words and phrases or count the number of people in the frame. This can be done using the Vision Studio.

The Azure AI services offer a wide range of tools that are designed for different types of users, many of which can be used with Azure AI services.

Here are some of the tools you can use to customize and configure models:

You can install the package azure-ai-inference using your package manager, like pip, to use the Azure AI inference library.

The Azure AI services also offer a tool called Vision Studio, which allows you to try out features like image analysis and facial recognition.

Context Window Management

Context Window Management is a crucial aspect of API functionality, particularly when it comes to handling large amounts of text data. Assistants automatically truncate text to ensure it stays within the model's maximum context length.

An artist’s illustration of artificial intelligence (AI). This illustration depicts language models which generate text. It was created by Wes Cockx as part of the Visualising AI project l...
Credit: pexels.com, An artist’s illustration of artificial intelligence (AI). This illustration depicts language models which generate text. It was created by Wes Cockx as part of the Visualising AI project l...

This means that you don't have to worry about overwhelming the model with too much information, but you can still customize this behavior to suit your needs. By specifying the maximum tokens you'd like a run to utilize, you can control the amount of text data that's processed.

The maximum number of recent messages you'd like to include in a run is another important factor to consider. This setting allows you to tailor the context window to your specific use case.

Here's a breakdown of the key settings:

By adjusting these settings, you can fine-tune the context window to meet the needs of your specific application or use case.

Frequently Asked Questions

What is the difference between Azure AI and Azure OpenAI?

Azure AI Studio and Azure OpenAI serve different purposes, with Azure AI Studio providing a platform for building and managing AI projects, while Azure OpenAI offers access to OpenAI models for use within those projects. By combining the two, you can unlock advanced AI capabilities and create more sophisticated projects.

What is the Azure AI?

Azure AI is a suite of cloud-based services that enables developers to build intelligent applications with prebuilt and customizable AI models and APIs. It helps create cutting-edge, market-ready solutions quickly and responsibly.

What is AI API?

An AI API is a set of rules and tools that enables developers to add artificial intelligence capabilities to their applications without building AI algorithms from scratch. It's a shortcut to integrating AI into your projects, making development faster and more efficient.

How to get OpenAI api key in Azure?

To get your OpenAI API key in Azure, navigate to the "Create a resource" section and follow the deployment process to access your API keys and endpoints. After deployment, find your API keys in the "Keys and Endpoint" section of your resource.

Thomas Goodwin

Lead Writer

Thomas Goodwin is a seasoned writer with a passion for exploring the intersection of technology and business. With a keen eye for detail and a knack for simplifying complex concepts, he has established himself as a trusted voice in the tech industry. Thomas's writing portfolio spans a range of topics, including Azure Virtual Desktop and Cloud Computing Costs.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.