Initialization

EIP

  • API Reference
    • API function release records
    • API Service Domain Name
    • API Specifications
    • Appendix 1
    • Bandwidth Package Related Interfaces
      • Adjust the bandwidth of the bandwidth package
      • Create bandwidth package
      • Query bandwidth package details
      • Query bandwidth package list information of users
      • Release bandwidth package
      • Update the automatic release time of the bandwidth package
      • Update the name of the bandwidth package
    • DDoS Basic Protection Related Interfaces
      • Modify DDoS basic protection threshold
      • Query DDoS Basic Protection Attack Records
      • Query DDoS basic protection list
    • EIP Related Interfaces
      • Apply for EIP
      • Bind EIP
      • Disable EIP direct
      • EIP bandwidth scaling
      • EIP renewal has been enabled
      • Enable EIP direct
      • Query EIP list in bucket trash
      • Query EIP list
      • Release EIP
      • Release EIPs in the bucket trash
      • Renew EIP
      • Restore EIPs in the bucket trash
      • Selective release of EIP
      • Unbind EIP
      • Unsubscribe prepaid EIP
      • Update EIP Release Protection Switch
    • Error code
    • General Description
    • Inquiry Related
      • Bandwidth package price inquiry
      • EIP Inquiry
      • EIPGROUP Inquiry
      • Shared Traffic Package Inquiry
    • Interface Overview
    • Overview
    • Prerequisites for use
    • Shared Bandwidth Related Interfaces
      • Bandwidth scaling up for EIPGROUP
      • Create EIPGROUP
      • EIPGROUP IP count upgrade
      • EIPGROUP release
      • EIPGROUP renewal
      • EIPGROUP update
      • Migrate EIP from EIPGROUP
      • Migrate EIP into EIPGROUP
      • Query EIPGROUP details
      • Query the EIPGROUP list
      • Unsubscribe prepaid EIPGROUP
    • Shared Traffic Package Related Interfaces
      • Create a shared traffic package
      • Query shared traffic package details
      • Query shared traffic package list
    • TBSP Related Interfaces
      • Add Protection IP Allow List
      • Add Protocol Blocking
      • Add Region Blocking
      • Bind Protection Object
      • Close Protection IP Cleaning
      • Create TBSP
      • Delete Protection IP Allow List
      • Delete Protection Object
      • Delete Protocol Blocking
      • Delete Region Blocking
      • Modify Protection IP Cleaning Threshold
      • Modify Protection IP Protection Level
      • Open Protection IP Cleaning
      • Query Protection IP Allow List
      • Query Protection IP Cleaning Threshold List
      • Query Protocol Blocking List
      • Query Region Blocking List
      • Query TBSP Details
      • Query TBSP List
      • TBSP Capacity dilatation
      • TBSP renew
  • FAQs
    • Billing class
    • Configuration
    • Consultation
    • Security class
  • Function Release Records
  • Operation guide
    • Address pool
    • Bandwidth package
      • Bandwidth scale-up package
      • Cross-border acceleration package
    • Certification
    • DDoS standard protection
    • EIP Instance
      • Create instance
      • EIP Direct Connect
      • IPv6 Termination
      • Manage Alarms
      • Operation Instance
      • Shift Charge
      • View monitoring
    • EIP Self-Service Diagnostics
      • EIP Instance Diagnosis
    • EIPGROUP
      • Bind cloud resources
      • Manage Shared Bandwidth
      • Purchase Shared Bandwidth
      • View monitoring
    • High Defense EIP
    • Identity and access management
    • Recycle bin
    • Shared traffic package
      • Purchase Shared Traffic Package
      • View Shared Traffic Package
    • Tag Management
    • Traffic Burst Service Package
      • Instance management
      • Monitor alarm
      • Protection Configuration
    • Unblocking Center
  • Product Description
    • Application scenarios
    • Product advantages
    • Product Introduction
    • Usage restrictions
  • Product pricing
    • Bandwidth Package Billing
    • EIP Instance Billing
    • EIPGROUP Billing
    • Shared Traffic Package Billing
    • TBSP Billing
  • SDK
    • GO-SDK
      • DDoS Instance
      • EIP Instance
      • EipBp Instance
      • EIPGROUP Instance
      • EipTp Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
    • Java-SDK
      • EIP Instance
      • EipBP Instance
      • EIPGROUP Instance
      • EipTp Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • PHP-SDK
      • EIP Instance
      • EipBP Instance
      • EIPGROUP Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Python-SDK
      • EIP Instance
      • EipBP Instance
      • EIPGROUP Instance
      • EipTp Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
  • Service Level Agreement (SLA)
    • EIP Service Level Agreement SLA
    • TBSP Service Level Agreement SLA
  • Typical Practices
    • Bring Your Own Overseas Public IP Address to the Cloud
    • IPv6 Public Network Access
    • Save Public Network Costs
    • TCP Port 25 Restriction Description
All documents
menu
No results found, please re-enter

EIP

  • API Reference
    • API function release records
    • API Service Domain Name
    • API Specifications
    • Appendix 1
    • Bandwidth Package Related Interfaces
      • Adjust the bandwidth of the bandwidth package
      • Create bandwidth package
      • Query bandwidth package details
      • Query bandwidth package list information of users
      • Release bandwidth package
      • Update the automatic release time of the bandwidth package
      • Update the name of the bandwidth package
    • DDoS Basic Protection Related Interfaces
      • Modify DDoS basic protection threshold
      • Query DDoS Basic Protection Attack Records
      • Query DDoS basic protection list
    • EIP Related Interfaces
      • Apply for EIP
      • Bind EIP
      • Disable EIP direct
      • EIP bandwidth scaling
      • EIP renewal has been enabled
      • Enable EIP direct
      • Query EIP list in bucket trash
      • Query EIP list
      • Release EIP
      • Release EIPs in the bucket trash
      • Renew EIP
      • Restore EIPs in the bucket trash
      • Selective release of EIP
      • Unbind EIP
      • Unsubscribe prepaid EIP
      • Update EIP Release Protection Switch
    • Error code
    • General Description
    • Inquiry Related
      • Bandwidth package price inquiry
      • EIP Inquiry
      • EIPGROUP Inquiry
      • Shared Traffic Package Inquiry
    • Interface Overview
    • Overview
    • Prerequisites for use
    • Shared Bandwidth Related Interfaces
      • Bandwidth scaling up for EIPGROUP
      • Create EIPGROUP
      • EIPGROUP IP count upgrade
      • EIPGROUP release
      • EIPGROUP renewal
      • EIPGROUP update
      • Migrate EIP from EIPGROUP
      • Migrate EIP into EIPGROUP
      • Query EIPGROUP details
      • Query the EIPGROUP list
      • Unsubscribe prepaid EIPGROUP
    • Shared Traffic Package Related Interfaces
      • Create a shared traffic package
      • Query shared traffic package details
      • Query shared traffic package list
    • TBSP Related Interfaces
      • Add Protection IP Allow List
      • Add Protocol Blocking
      • Add Region Blocking
      • Bind Protection Object
      • Close Protection IP Cleaning
      • Create TBSP
      • Delete Protection IP Allow List
      • Delete Protection Object
      • Delete Protocol Blocking
      • Delete Region Blocking
      • Modify Protection IP Cleaning Threshold
      • Modify Protection IP Protection Level
      • Open Protection IP Cleaning
      • Query Protection IP Allow List
      • Query Protection IP Cleaning Threshold List
      • Query Protocol Blocking List
      • Query Region Blocking List
      • Query TBSP Details
      • Query TBSP List
      • TBSP Capacity dilatation
      • TBSP renew
  • FAQs
    • Billing class
    • Configuration
    • Consultation
    • Security class
  • Function Release Records
  • Operation guide
    • Address pool
    • Bandwidth package
      • Bandwidth scale-up package
      • Cross-border acceleration package
    • Certification
    • DDoS standard protection
    • EIP Instance
      • Create instance
      • EIP Direct Connect
      • IPv6 Termination
      • Manage Alarms
      • Operation Instance
      • Shift Charge
      • View monitoring
    • EIP Self-Service Diagnostics
      • EIP Instance Diagnosis
    • EIPGROUP
      • Bind cloud resources
      • Manage Shared Bandwidth
      • Purchase Shared Bandwidth
      • View monitoring
    • High Defense EIP
    • Identity and access management
    • Recycle bin
    • Shared traffic package
      • Purchase Shared Traffic Package
      • View Shared Traffic Package
    • Tag Management
    • Traffic Burst Service Package
      • Instance management
      • Monitor alarm
      • Protection Configuration
    • Unblocking Center
  • Product Description
    • Application scenarios
    • Product advantages
    • Product Introduction
    • Usage restrictions
  • Product pricing
    • Bandwidth Package Billing
    • EIP Instance Billing
    • EIPGROUP Billing
    • Shared Traffic Package Billing
    • TBSP Billing
  • SDK
    • GO-SDK
      • DDoS Instance
      • EIP Instance
      • EipBp Instance
      • EIPGROUP Instance
      • EipTp Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
    • Java-SDK
      • EIP Instance
      • EipBP Instance
      • EIPGROUP Instance
      • EipTp Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • PHP-SDK
      • EIP Instance
      • EipBP Instance
      • EIPGROUP Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Python-SDK
      • EIP Instance
      • EipBP Instance
      • EIPGROUP Instance
      • EipTp Instance
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
  • Service Level Agreement (SLA)
    • EIP Service Level Agreement SLA
    • TBSP Service Level Agreement SLA
  • Typical Practices
    • Bring Your Own Overseas Public IP Address to the Cloud
    • IPv6 Public Network Access
    • Save Public Network Costs
    • TCP Port 25 Restriction Description
  • Document center
  • arrow
  • EIP
  • arrow
  • SDK
  • arrow
  • Java-SDK
  • arrow
  • Initialization
Table of contents on this page
  • Confirm Endpoint
  • Retrieve access key
  • Create EipClient/EipGroupClient/EipBpClient
  • Create EipClient/EipGroupClient/EipBpClient with AK/SK
  • Create EipClient/EipGroupClient/EipBpClient with STS
  • Request STS Token
  • Create EipClient with STS Token
  • Configure HTTPS protocol to access Eip/EipGroup/EipBp
  • Configure EipClient/EipGroupClient/EipBpClient
  • Use a proxy
  • Set network parameters

Initialization

Updated at:2025-10-16

Confirm Endpoint

Before configuring the endpoint for SDK usage, please refer toAPI Service Domain Name in API Reference to understand endpoint-related concepts. Baidu AI Cloud currently supports multiple regions. Please refer toRegion Selection Guide. Corresponding information:

Access region Endpoint
Beijing eip.bj.baidubce.com
Guangzhou eip.gz.baidubce.com
Suzhou eip.su.baidubce.com
Hong Kong eip.hkg.baidubce.com
Wuhan eip.fwh.baidubce.com
Baoding eip.bd.baidubce.com

Retrieve access key

To use Baidu AI Cloud EIP, users need a valid AK (Access Key ID) and SK (Secret Access Key) for signature certification. AK/SK are system-assigned strings used to identify users and perform signature certification for EIP. Your AK/SK information can be obtained and understood through the following steps: Register a Baidu AI Cloud account Create AK/SK

Create EipClient/EipGroupClient/EipBpClient

The EipClient acts as the client for EipTp services, providing developers with various methods to interact with EIP services.

Create EipClient/EipGroupClient/EipBpClient with AK/SK

Users can refer to the following code to create a client to access Eip with AK/SK:

Java
1public class Sample {
2    public static void main(String[] args) {
3 String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
4 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
5        
6 // Initialize EipClient
7        BceClientConfiguration config = new BceClientConfiguration();
8        config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
9        EipClient client = new EipClient(config);
10        
11 // Initialize an EipGroupClient
12        BceClientConfiguration config = new BceClientConfiguration();
13        config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
14        EipGroupClient client = new EipGroupClient(config);
15        
16 // Initialize EipBpClient
17        BceClientConfiguration config = new BceClientConfiguration();
18        config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
19        EipBpClient client = new EipGroupClient(config);
20    }
21}

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.

The method mentioned above uses the default domain name as the service address for EIP. To use a custom domain name, pass the ENDPOINT parameter during configuration.

Java
1String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
2 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
3 String ENDPOINT = <domain-name>;                               // User-defined domain name
4 BceClientConfiguration config = new BceClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID,SECRET_ACCESS_KEY));
6 config.setEndpoint(ENDPOINT);
7 EipClient client = new EipClient(config);
8 EipGroupClient client = new EipGroupClient(config);
9 EipBpClient client = new EipBpClient(config);

Note: The ENDPOINT parameter must use region-specific domains (e.g., http://aihc.bj.baidubce.com for Beijing). If unspecified, it defaults to the Beijing region endpoint (http://eip.bj.baidubce.com).

Create EipClient/EipGroupClient/EipBpClient with STS

Request STS Token

EIP allows temporary third-party access authorization using the STS mechanism. STS (Security Token Service) is a temporary authorization service offered by Baidu AI Cloud. With STS, you can issue access credentials with customizable validity periods and permissions to third-party users. These users can then utilize the credentials to directly call Baidu AI Cloud APIs or SDKs to access cloud resources.

To access EIP via STS, users must first request a certification string through the STS client. For instructions on obtaining STS credentials, refer to Baidu AI Cloud STS Usage Guide。

Create EipClient with STS Token

After requesting the STS token, configure it in the EipClient. The following codes demonstrate how to create an EipClient:

Java
1public class StsExample {
2    private static final String STS_ENDPOINT = "http://sts.bj.baidubce.com";
3    private static final String ACCESS_KEY_ID = "your accesskey id";
4    private static final String SECRET_ACCESS_KEY = "your secret accesskey";
5    public static void main(String[] args) {
6        BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY);
7        StsClient client = new StsClient(
8                new BceClientConfiguration().withEndpoint(STS_ENDPOINT).withCredentials(credentials)
9        );
10        GetSessionTokenResponse response = client.getSessionToken(new GetSessionTokenRequest());
11        // or simply call:
12        // GetSessionTokenResponse response = client.getSessionToken();
13        // or you can specify limited permissions with ACL:
14        // GetSessionTokenResponse response = client.getSessionToken(new GetSessionTokenRequest().withAcl("blabla"));
15        // build DefaultBceSessionCredentials object from response:
16        BceCredentials eipStsCredentials = new DefaultBceSessionCredentials(
17                response.getAccessKeyId(),
18                response.getSecretAccessKey(),
19                response.getSessionToken());
20        System.out.println("==================================");
21        System.out.println("GetSessionToken result:");
22        System.out.println("    accessKeyId:  " + response.getAccessKeyId());
23        System.out.println("    secretAccessKey:  " + response.getSecretAccessKey());
24        System.out.println("    securityToken:  " + response.getSessionToken());
25        System.out.println("    expiresAt:  " + response.getExpiration().toString());
26        System.out.println("==================================");
27        // build eip client
28        BceClientConfiguration config = new BceClientConfiguration();
29        config.setCredentials(eipStsCredentials);
30        EipClient eipClient = new EipClient(config);
31        EipGroupClient client = new EipGroupClient(config);
32        EipBpClient client = new EipBpClient(config);
33    }
34}

Note: Currently, when configuring a client with STS, regardless of where the corresponding EIP service endpoint is located, the endpoint must be set to http://sts.bj.baidubce.com.

Configure HTTPS protocol to access Eip/EipGroup/EipBp

EIP supports HTTPS transport protocol. You can use HTTPS to access the EIP service in the EIP Java SDK in the following two ways:

  • Specify HTTPS in the endpoint:
Java
1 String endpoint = "https://eip.bj.baidubce.com";
2 String ak = "ak";
3 String sk = "sk";
4 BceClientConfiguration config = new BceClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ak, sk));
6 EipClient client = new EipClient(config);
7 EipGroupClient client = new EipGroupClient(config);
8 EipBpClient client = new EipBpClient(config);
  • Configure HTTPS by calling setProtocol:
Java
1 String endpoint = "eip.bj.baidubce.com"; // endpointwithout protocol
2 String ak = "ak";
3 String sk = "sk";
4 BceClientConfiguration config = new BceClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ak, sk));
6 config.setEndpoint(ENDPOINT);
7 config.setProtocol(Protocol.HTTPS); // Defaults to HTTP if unspecified
8 EipClient client = new EipClient(config);
9 EipGroupClient client = new EipGroupClient(config);
10 EipBpClient client = new EipBpClient(config);

Note: If the endpoint already includes a protocol, the one in endpoint takes effect, and the setProtocol() method will be ignored.

Java
1 String endpoint = "http://eip.bj.baidubce.com";
2 String ak = "ak";
3 String sk = "sk";
4 BceClientConfiguration config = new BceClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ak, sk));
6 config.setEndpoint(ENDPOINT);    
7 config.setProtocol(Protocol.HTTPS); // Invalid operation if specified in endpoint, applicable to HTTP cases
8 EipClient client = new EipClient(config);
9 EipGroupClient client = new EipGroupClient(config);
10 EipBpClient client = new EipBpClient(config);

Configure EipClient/EipGroupClient/EipBpClient

To configure specific parameters for the EipClient, pass a BceClientConfiguration object during initialization. This enables you to adjust proxy settings, maximum connections, and other network parameters.

Use a proxy

The following code snippet enables the client to access EIP service using a proxy:

Java
1String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
2 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
3 String ENDPOINT = <domain-name>;                               // User-defined domain name
4 // Create BceClientConfiguration instance
5 BceClientConfiguration config = new BceClientConfiguration();
6 // Configure proxy to local port 8080
7 config.setProxyHost("127.0.0.1");
8 config.setProxyPort(8080);
9 // Create EIP client
10 config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID,SECRET_ACCESS_KEY));
11 config.setEndpoint(ENDPOINT);
12 EipClient client = new EipClient(config);
13 EipGroupClient client = new EipGroupClient(config);
14 EipBpClient client = new EipBpClient(config);

All client requests will then be routed through the proxy at 127.0.0.1:8080.

For verified proxies, configure credentials:

Plain Text
1// Create BceClientConfiguration instance
2 BceClientConfiguration config = new BceClientConfiguration();
3    
4 // Configure proxy to local port 8080
5 config.setProxyHost("127.0.0.1");
6 config.setProxyPort(8080);
7    
8 // Set username and password
9 config.setProxyUsername(<username>);                             // Username
10 config.setProxyPassword(<password>);                             // Password

Set network parameters

Users may set the basic network parameters with BceClientConfiguration:

Java
1BceClientConfiguration config = new BceClientConfiguration();
2    
3 // Set maximum number of HTTP connections to 10
4config.setMaxConnections(10);
5    
6 // Set TCP connection timeout to 5,000 milliseconds
7config.setConnectionTimeout(5000);
8    
9 // Set timeout for Socket data transmission to 2,000 milliseconds
10config.setSocketTimeout(2000);

Parameter description The following parameters can be configured via BceClientConfiguration:

Parameters Description
UserAgent User agent, refers to HTTP’s User-Agent header
Protocol Connection protocol type
ProxyDomain Windows domain for NTLM-verified proxy
ProxyHost Proxy server host address
ProxyPort Proxy server port
ProxyUsername Proxy verification username
ProxyPassword Proxy verification password
ProxyPreemptiveAuthenticationEnabled Enable user agent verification or not
ProxyWorkstation NTLM proxy workstation name
LocalAddress Local address
ConnectionTimeoutInMillis Timeout for establishing TCP connections (unit: ms)
SocketTimeoutInMillis Timeout for socket data transmission (unit: ms)
MaxConnections Maximum allowable HTTP connections
RetryPolicy Retry policy for connections
SocketBufferSizeInBytes Buffer size for socket operations

Previous
Exception handling
Next
Install the SDK Package