To access the HUAWEI CLOUD Pangu model, the core process includes four steps: registering an account, applying for permissions, configuring the environment, and calling APIs. 1. Register a HUAWEI CLOUD account and complete real-name authentication, enter the modelarts service page to apply for the use of the Pangu model, and some advanced models need to submit a description of use and pass the review. 2. Log in to the console to obtain the API key in the IAM service and record the project ID as the request credential. 3. Construct HTTP requests containing authentication information and input content, passing the standard RESTFUL API callsmodel, the return result is in JSON format; 4. Pay attention to issues such as token validity period, QPS limit, input length and cost, and reasonably design input and output logic to meet business needs. The preliminary preparation of the whole process is more critical, and the actual call is relatively simple, so it is recommended to start with the basic model to test and familiarize yourself with it before expanding the complex tasks.
As one of the leading AI models in China, HUAWEI CLOUD’s Pangu model provides a wealth of API interfaces for developers to call. If you want to access the Pangu model, the core process is actually not complicated, mainly the steps of registering an account, applying for permissions, configuring the environment, and calling APIs.
1. Register a HUAWEI CLOUD account and activate the service
To use the Pangu model, you first need to have oneHUAWEI CLOUD account。 You can go throughHUAWEI CLOUD official websiteSign up for an account.
The key points for activating the service are:
- Complete real-name authentication (for individuals or businesses)
- Go to the “ModelArts” service page and find Pangu Model related products
- Request permission to use the corresponding model (some models may need to be reviewed)
Note: Some advanced models, such as NLP hyperscale versions, may require a description of use and manual review.
2. Obtain the API key and project ID
Before officially calling the API, you need to obtain two key parameters:API Key and Project ID。
The operation path is as follows:
- Log in to the HUAWEI CLOUD console
- Go to Unified Identity Authentication Service (IAM)
- View or create an API key in My Credentials
- Also record your Project ID (available in the username drop-down menu in the top right corner)
These two parameters are the basis for subsequent requests for authentication and must be kept properly.
3. The basic process of calling the Pangu model API
HUAWEI CLOUD provides a standard RESTful API interface, which is relatively common and is mainly divided into the following steps:
-
Constructing a request header
Include X-Auth-Token (temporary token) or use X-Api-Key directly for authentication. -
Constructing a Body
Depending on the model type, the corresponding input is passed. For example, a text generation task is typically a JSON object containing a prompt field. -
Send HTTP requests
Use the POST method to send to the specified API address, for example:1
POST https:
//api.pangu.cloud/v1/models/pangu-alpha:predict
Copy after logging in
-
Parsing the returned results
The interface typically returns results in JSON format, containing generated content or other model output information.
Sample code (Python pseudocode):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Copy after logging in
4. Frequently asked questions and precautions
There are a few error-prone areas to be aware of during the actual call:
- Token expiration issue: If you are using a temporary token, pay attention to the validity period, and it is recommended to encapsulate the automatic refresh logic.
- Request frequency limits: HUAWEI CLOUD has a QPS limit for API calls, and an error code will be returned after it is exceeded.
- Enter the length limit: Each model has an upper limit on the length of the input text, and it will be truncated or error if it exceeds it.
- Cost issues: Although there is a free quota in the early stage, long-term use needs to pay attention to the billing rules to avoid unexpected costs.
That’s basically all. As long as the preliminary preparation is completed, the calling process is actually not difficult, but the difficulty lies in how to reasonably design the input and output according to the business requirements and handle the exception well. You can start with a small model at the beginning, and then try more complex tasks after getting familiar with it.
The above is how to access HUAWEI CLOUD’s Pangu model Pangu model API call process analysis, for more information, please pay attention to other related articles on the PHP Chinese website!