You need to enable JavaScript to run this app.
导航

初始化

最近更新时间2024.02.20 11:29:18

首次发布时间2021.03.15 12:01:33

Nodejs SDK 可通过 Access Key 初始化,本文为您介绍初始化的操作步骤。

前提条件

初始化

设置 AK / SK

支持以下 3 种 AK/SK 的设置方法,您可以根据实际需求选择如何设置 AK/SK。

  • 方法一:在业务代码中配置
import { ImageXClient } from "@volcengine/imagex-openapi";
// 使用 ak/sk 实例化 Client
const Client = new ImageXClient({
  accessKey: 'your ak',
  secretKey: 'your sk',
  host: 'host',
  region: 'region'
});
  • 方法二:在环境变量中配置
VOLC_ACCESSKEY="your ak" 
VOLC_SECRETKEY="your sk"
  • 方法三:在文件中配置

以 json 格式放在 ~/.volc/config 中,具体格式如下所示:

{"VOLC_ACCESSKEY":"your ak","VOLC_SECRETKEY":"your sk"}

设置地域 Region

veImageX 目前支持以下三个地域:

  • cn-north-1 (默认国内)

  • ap-singapore-1 (新加坡)

默认地域为中国(cn-north-1),若需调用其它地域服务,请在初始化时传入指定的地域信息。代码示例如下所示:

// 初始化实例时支持传入地域
const Client = new ImageXClient({
  accessKey: 'your ak',
  secretKey: 'your sk',
  host: 'host',
  region: 'ap-singapore-1' // 指定地域为新加坡
});