Create an AI API¶
AI APIs enable seamless integration of artificial intelligence services into applications through the WSO2 API Manager. By using the AI API feature, users can select specific AI vendors that best suit their needs. WSO2 API Manager provides built-in support for leading AI vendors like OpenAI, Mistral, and Azure AI, while also allowing configuration of custom AI vendors to create AI APIs.
Follow the instructions below to create an AI API using the basic flow:
Step 1: Create an AI API¶
-
Sign in to the API Publisher Portal.
https://<hostname>:9443/publisher
Example:
https://localhost:9443/publisher
Note
The Create API button will only appear for a user who has the
creator
role permission. -
Click Create API and then click AI API.
-
Select the desired AI Provider and the relevant AI Provider API Version and click Next.
Note
The available AI service providers and versions will appear on relevant dropdowns. In adition to inbuild AI service vendors, you can also configure custom AI service vendors.
-
Configure AI API details.
Field Sample value Name MistralAIAPI Version 0.0.2 Context mistralaiapi
The API context is used by the Gateway to identify the API. Therefore, the API context must be unique. This context is the API's root context when invoking the API through the Gateway.
You can define the API's version as a parameter of its context by adding the
{version}
into the context. For example,{version}/mistralaiapi
. The API Manager assigns the actual version of the API to the{version}
parameter internally. For example,https://localhost:8243/0.0.2/mistralaiapi
. Note that the version appears before the context, allowing you to group your APIs based on the versions.Endpoint https://api.mistral.ai
The endpoint of the AI service vendor is automatically added as the production and sandbox endpoints.
-
Click Create to create the API.
The overview page of the newly created API appears.
Step 2: Obtain API Key from AI Service Vendor¶
Example: Mistral AI
Login to Mistral AI and go to Mistral AI Console.
Click API Keys and create new key.
Step 3: Configure Sandbox and Production Endpoint¶
-
Go to API Configurations, and click Endpoints.
-
Fill API Key for Production and Sandbox Endpoints using the key which was obtained from Step 2.
Note
APIM supports three AI/LLM vendors by default. The supported authorization approach for each is mentioned below:
- MistralAI:
Authorization
header - AzureOpenAI:
api-key
header - OpenAI:
Authorization
header
Note that we prepend "Bearer " to the header value that you provide when it comes to MistralAI and OpenAI since they are expecting an Authorization header.
- MistralAI:
-
Click Save.
Now, you have successfully created an AI API. Next, deploy the API, test the API, and finally publish the API.
See Also¶
Learn more on the concepts that you need to know when creating a REST API: