Initialization
Initialize
Confirm Endpoint
Before configuring the Endpoint for SDK usage, please refer to the developer guide section on BLB Access Domain Name to understand Endpoint-related concepts. Baidu AI Cloud currently supports multiple regions. Please refer to Region Selection Guide.
Currently, supported regions include "Beijing," "Guangzhou," "Suzhou," "Hong Kong," "Wuhan," "Baoding," "Shanghai," and "Singapore.\
The corresponding information for the service domain name:
| Access region | Endpoint |
|---|---|
| bj | blb.bj.baidubce.com |
| gz | blb.gz.baidubce.com |
| su | blb.su.baidubce.com |
| hkg | blb.hkg.baidubce.com |
| fwh | blb.fwh.baidubce.com |
| bd | blb.bd.baidubce.com |
| fsh | blb.fsh.baidubce.com |
| sin | blb.sin.baidubce.com |
Create a BlbClient
Create a BlbClient with AK/SK
Users can refer to the following code to create a BosClient to access BOS with AK/SK:
1import (
2 "github.com/baidubce/bce-sdk-go/services/blb"
3 "github.com/baidubce/bce-sdk-go/services/appblb"
4)
5func main() {
6 // User’s Access Key ID and Secret Access Key
7 ACCESS_KEY_ID, SECRET_ACCESS_KEY := <ak>, <sk>
8 // User-specified Endpoint
9 ENDPOINT := <domain-name>
10 // Initialize a BlbClient
11 blbClient, err := blb.NewClient(AK, SK, ENDPOINT)
12 // Initialize a AppblbClient
13 appblbClient, err := appblb.NewClient(AK, SK, ENDPOINT)
14}
In the code above, ACCESS_KEY_ID corresponds to “Access Key ID” in the console. SECRET_ACCESS_KEY corresponds to “Access Key Secret” in the console. For the method to retrieve them, refer to the Guide - [Manage ACCESSKEY](Reference/Retrieve AK and SK/How to Obtain AKSK.md).
1>**Note:**"The ENDPOINT parameter must use region-specific domain names. If unspecified, it defaults to the Beijing region blb.bj.baidubce.com.
