Initialization
Initialization
Confirm Endpoint
Before configuring the endpoint for SDK usage, please refer to the developer guide section on API Service Domain Name to understand Endpoint-related concepts.
| Access region | Endpoint |
|---|---|
| Global | csn.baidubce.com |
Retrieve AK/SK
To use Baidu AI Cloud CSN, you must have a valid AK (Access Key ID) and SK (Secret Access Key) for signature authentication. These AK/SK credentials are system-generated strings used to identify users and authenticate service access. You can obtain and review your AK/SK information using the following steps:
Register a Baidu AI Cloud account
Create AK/SK
Create CsnClient
The CsnClient acts as the interface for CSN services, offering developers several methods for interacting with the services. When creating a CSN client, first configure a BceClientConfiguration object with parameters like endpoint, AK, and SK. Then use this configuration object to initialize the CsnClient. Here's an example of the setup process:
1from baidubce.auth.bce_credentials import BceCredentials
2from baidubce.bce_client_configuration import BceClientConfiguration
3from baidubce.services.csn import csn_client
4if __name__ == "__main__":
5 ak = '' # User’s AK
6 sk = '' # User’s SK
7 endpoint = "csn.baidubce.com"
8 config = BceClientConfiguration(credentials=BceCredentials(access_key_id=ak, secret_access_key=sk),
9 endpoint=endpoint)
10 csn_client = csn_client.CsnClient(config)
