Common FAQs

APIs

1. How to register for the PolyU API Management Services?

To register for the PolyU API Management Services, please follow these steps:

  1. Submit your registration through the designated registration form for student or staff respective to applicant's role.

  2. Your request will be forwarded to your approver (Principal Investigator, Head of Department, or their delegate) for deposit approval.

  3. Once approved, transfer your deposit to the account code provided by ITS: 1.15.0M.6403.

  4. After ITS verifies the deposit, your API service will be activated, granting you access to the endpoints and keys.

  5. We assume the entire process can be completed within a week. If you have any questions, please send your request ID and email to ITS Azure Operation support at itsazure@polyu.edu.hk.

2. Where can I find my API endpoint and keys?

To locate your API endpoint and keys, follow these instructions:

  1. API Endpoint: Visit your APIs page to find the specific endpoint details:

    • To POST with an HTTP request, use the endpoint:

      https://hkpolyu-api.azure-api.net/.../openai/deployments/{deployment-id}/chat/completions?api-version={api-version}
    • For using the API with coding libraries like OpenAI and Langchain, use the endpoint path before /openai:

      https://hkpolyu-api.azure-api.net/...
  2. API Keys: Two API keys should also be available on the profile page. If you accidentally expose your keys or suspect they have been compromised, you may also regenerate them. This will invalidate the old keys and provide you with new ones for secure access.

3. How long will be API endpoint and keys be activated for?

Your API service will remain active for up to two years, unless your account balance is exhausted earlier. At the end of this period, your API endpoint and keys will be deactivated immediately. To continue using the service, you can extend or renew it by completing the designated renewal form.

4. How can I view my API details and tokens usage?

To access detailed information about your API and tokens usage, please visit the following link:

https://portal.azure.com/#@polyuit.onmicrosoft.com/resource/subscriptions/fc0854b0-1438-48b1-a1d4-3c0ae313744a/resourceGroups/rg-[DEPT]-AI-[PROJECT]/providers/Microsoft.CognitiveServices/accounts/rs-[DEPT]-AI-[PROJECT]-OpenAI/metrics

Be sure to replace [DEPT] and [PROJECT] in the URL with the appropriate values. You can find these values in your APIs page. For instance, if your APIs page lists "ITS-TEST: Azure OpenAI Service API", then [DEPT] should be "ITS" and [PROJECT] should be "TEST".

Note that the page is restricted to users with the registered NetID. If you still failed to reach the page, please submit a request to ITS Azure Operation support at itsazure@polyu.edu.hk. Be sure to include your request ID and detailed information about your preferences.

You may choose different metrics such as Azure OpenAI Requests, Processed Prompt Tokens and Generated Completion Tokens for further monitoring.

5. What are API versions, and which versions are supported?

API versions define the specific iterations of an API that are available for use, reflecting changes, improvements, and new features over time.

Supported API versions in the PolyU API Services can be found on the API page. Newer API versions will be made available to you when you are granted access to a new model that is not compatible with the previous API version.

If you used an unsupported API version, you will receive a 404 Resource not found response status code.

Deposit

1. What will happen if I reached my deposited budget limit?

Once you used up your deposits, you API key(s) will be disabled immediately and you will NOT be able to use the PolyU API Management Services.

2. Will I receive notifications regarding my deposit usage?

Yes. By default, you will receive alert emails once you have used up 80% and 100% of your deposit. If you wish to receive other alerts, please submit a request to ITS Azure Operation support at itsazure@polyu.edu.hk. Be sure to include your request ID and detailed information about your preferences.

3. Can I add new deposits or reactivate my API key(s) after I used up my deposits?

Yes, you can reactivate or continue using the API service by adding a new deposit to your account within six months after your initial deposit is depleted. To proceed, please make a deposit to the ITS Account Code: 1.15.0M.6403. For any inquiries, please submit a request to ITS Azure Operation at email: itsazure@polyu.edu.hk. Be sure to include your request ID and detailed information about your new deposit.

4. How will my deposit be consumed?

Your deposit will be deducted based on the tokens you used and the token fee of the particular model. For the pricing of models provided by Azure OpenAI, you may refer to Azure OpenAI Service Pricing or OpenAI Pricing for more details.

5. How can I view my deposit usage?

To access detailed information about your deposit usage, please visit the following link:

https://portal.azure.com/#@polyuit.onmicrosoft.com/resource/subscriptions/fc0854b0-1438-48b1-a1d4-3c0ae313744a/resourceGroups/rg-[DEPT]-AI-[PROJECT]/providers/Microsoft.CognitiveServices/accounts/rs-[DEPT]-AI-[PROJECT]-OpenAI/billing

Be sure to replace [DEPT] and [PROJECT] in the URL with the appropriate values. You can find these values in your APIs page. For instance, if your APIs page lists "ITS-TEST: Azure OpenAI Service API", then [DEPT] should be "ITS" and [PROJECT] should be "TEST".

Note that the page is restricted to users with the registered NetID. If you still failed to reach the page, please submit a request to ITS Azure Operation support at itsazure@polyu.edu.hk. Be sure to include your request ID and detailed information about your preferences.

Rate limit & Quota

1. What is rate limit?

Rate limit is the maximum number of API calls per minute set by PolyU API Management Service and the maximum tokens per minute set by Azure OpenAI Service to prevent API usage spikes on your resource. The default value is 100 requests per minute and 1 million tokens per minute. Once you have exceeded the rate limit, you will receive a 429 Rate Limit Error response status code.

2. What is quota?

Quota is the maximum number of API calls per month set by ITS API Management Service to prevent API usage spikes on your resource. The default value is 20,000 requests per month. Once you have exceeded the quota, you will receive a 403 Forbidden response status code.

3. What will happen if I reached the rate limit or quota?

Once you reached the rate limit or quota, you will NOT be able to call the APIs until the renewal-period is reached.

4. Can I request to increase my rate limit and quota?

Your ability to request an increase in rate limit and quota depends on the specific requirements of your project. We require a manual review and approval process for any special requests. To proceed, please submit your request to ITS Azure Operation support at itsazure@polyu.edu.hk and provide your request ID along with detailed information about your needs.

Supported Generative AI models

1. What models are provided by the PolyU API Management Service?

The PolyU API Management Service offers a selection of Generative AI models based on the state-of-the-art (SoTA) models available in Hong Kong. Currently, our service primarily focuses on the Generative AI models provided by Azure OpenAI.

2. What are the pricing of the models' APIs?

The pricing of the models depend on the model that you are using. For the pricing of models provided by Azure OpenAI, you may refer to Azure OpenAI Service Pricing or OpenAI Pricing for more details.

3. Is it possible to request additional models?

Your may submit your request to ITS Azure Operation support at itsazure@polyu.edu.hk. Be sure to include your request ID and detailed information about your preferences. We will consider your request based on public demand and the complexity of implementation.

pip install openai
import os
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key = os.getenv("AZURE_OPENAI_API_KEY"),
api_version = os.getenv("AZURE_OPENAI_API_VERSION")
)
response = client.chat.completions.create(
model=os.getenv("AZURE_OPENAI_API_DEPLOYMENT_NAME"),
messages=[
{"role": "user", "content": "Hi"}
]
)
print(response.choices[0].message.content)
Output:

Hello! How can I assist you today?

Use Azure OpenAI with Python

Assign the required values directly (NOT recommended) or set them as environment variables (recommended). For more information, please refer to Official Azure OpenAI documentations.

Use Azure OpenAI with JavaScript

Assign the required values directly (NOT recommended) or set them as environment variables (recommended). For more information, please refer to Official Azure OpenAI documentations.

npm install openai
import { AzureOpenAI } from "openai";
const endpoint = process.env.AZURE_OPENAI_ENDPOINT;
const apiKey = process.env.AZURE_OPENAI_API_KEY;
const apiVersion = process.env.AZURE_OPENAI_API_VERSION;
const options = { endpoint, apiKey, apiVersion }
const client = new AzureOpenAI(options);
const response = await client.chat.completions.create({
model: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME,
    messages: [
        {"role": "user", "content": "Hi"}
    ]
});
console.log(response.choices[0].message.content);
Output:

Hello! How can I assist you today?

pip install langchain-openai
import os
from langchain_openai import AzureChatOpenAI
llm = AzureChatOpenAI(
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    openai_api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    openai_api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
    deployment_name=os.getenv("AZURE_OPENAI_API_DEPLOYMENT_NAME")
)
response = llm.invoke([
["human", "Hi"]
])
print(response.content)
Output:

Hello! How can I assist you today?

Use Azure OpenAI with Langchain (Python)

Assign the required values directly (NOT recommended) or set them as environment variables (recommended). For more information, please refer to Langchain AzureChatOpenAI documentations.

npm install @langchain/openai
import { AzureChatOpenAI } from "@langchain/openai";
const llm = new AzureChatOpenAI({
    azureOpenAIEndpoint: process.env.AZURE_OPENAI_API_ENDPOINT,
    azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY,
    azureOpenAIApiVersion: process.env.AZURE_OPENAI_API_VERSION,
    azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
});
const response = await llm.invoke([
    ["human", "Hi"]
]);
console.log(response.content);
Output:

Hello! How can I assist you today?

Use Azure OpenAI with Langchain.js

Assign the required values directly (NOT recommended) or set them as environment variables (recommended). For more information, please refer to Langchain AzureChatOpenAI documentations.

How to use the APIs to access the Generative AI models?