配置AIHCCLI
更新时间:2025-09-05
使用AIHCCLI需先配置百度智能云accesskey、secretkey以及服务地域(region )等信息
基础配置
使用命令配置
将命令安装好之后,就可以使用命令来配置,执行 aihc config 回车,会将需要配置的字段弹出来,按照提示操作
- 获取帮助信息,在帮助信息中可以查看支持的region:cn-bj、cn-gz、cn-su、cn-bd、cn-fwh、cn-yq
- 命令示例
Bash
1$ aihc config -h
2Configure Client credentials and settings. You can:
31. Run without flags for interactive mode
42. Set specific values using flags:
5 - Set credentials: aihc config --ak <AccessKey> --sk <SecretKey>
6 - Set region: aihc config --region <region>
7 - Set CCR account: aihc config --username <Username> --password <Password>
8
9Available Regions:
10 "cn-bj": 华北-北京
11 "cn-gz": 华南-广州
12 "cn-su": 华东-苏州
13 "cn-bd": 华北-保定
14 "cn-fwh": 华中-武汉
15 "cn-yq": 华北-阳泉
16
17Usage:
18 aihc config [flags]
19 aihc config [command]
20
21Available Commands:
22 get Get current configuration
23 set Set configuration values
24
25Flags:
26 --access-key string Access Key ID
27 --aihc-username string Job creator
28 --ak string Access Key ID
29 -h, --help help for config
30 --password string CCR Password
31 --region string Region
32 --secret-key string Secret Access Key
33 --sk string Secret Access Key
34 --username string CCR Username
35
36Global Flags:
37 -C, --config string Global configuration file. (default "/Users/xxx/.aihc/config")
38
39Use "aihc config [command] --help" for more information about a command.
- 设置配置参数,输入 aihc config 后按提示输入配置信息
- 命令示例
Bash
1$ aihc config
2
3Current configuration:
4region: cn-beijing
5credentials:
6 accesskey: ""
7 secretkey: ""
8 sessionToken: ""
9ccraccount:
10 username: ""
11 password: ""
12endpoint: ""
13useragent: ""
14retry: 0
15defaultpool: ""
16defaultqueue: ""
17
18Press Enter to keep current value or input new value:
19Access Key ID [""]: 在此输入AK后回车...
20Secret Access Key [""]:
21Region [cn-bj]:
- 查看配置信息
- 命令示例
Bash
1$ aihc config get
2
3region: cn-beijing
4credentials:
5 accesskey: ALTAKeB***************csC9GO
6 secretkey: b903d4*************c7c315063
7 sessionToken: ""
8ccraccount:
9 username: ""
10 password: ""
11endpoint: aihc.bj.baidubce.com
12useragent: aihc-cli/golang/v1.0.0
13retry: 3
14defaultpool: ""
15defaultqueue: ""
直接修改配置文件
可以使用命令行(vim/nano等)或记事本打开配置文件直接修改对应参数,保存文件后重启命令行工具后生效
Bash
1vim ~/.aihc/config
2region: #必填 格式: cn-beijing
3credentials:
4 accesskey: #必填
5 secretkey: #必填
6 sessionToken: ""
7ccraccount:
8 username: ""
9 password: ""
10endpoint: #自动生成
11useragent:
12retry:
13defaultpool: "" #默认资源池ID
14defaultqueue: "" #默认队列名称
设置默认资源池
设置一个默认资源池/队列,之后操作如果不指定资源池/队列则默认使用此资源池/队列,后续命令直接使用默认资源池可以在命令中省略 -p/--pool 参数
- 命令示例
Bash
1# 根据提示输入需要设置资源池、队列的序号,回车后生效
2$ aihc pool set
3
4Available pools:
51. hpas-runtime-02 (cce-rdy)
62. hpas-runtime (cce-4kvu)
73. workflow (cce-5uvro)
8
9Select pool (enter number): 3
10
11Available queues:
121. test
132. 63a9f0ea7bb96b649e85481845
143. default
15
16Select queue (enter number): 3
