# generaltranslation: General Translation Core SDK: GTConstructorParams URL: https://generaltranslation.com/zh/docs/core/types/gt-constructor-params.mdx --- title: GTConstructorParams description: GT 类构造函数参数的 TypeScript 接口 --- ## 概述 `GTConstructorParams` 定义了 GT 类初始化的配置选项。 ```typescript interface GTConstructorParams { apiKey?: string; devApiKey?: string; sourceLocale?: string; targetLocale?: string; locales?: string[]; projectId?: string; baseUrl?: string; customMapping?: CustomMapping; } ``` 所有属性均为可选。如果未提供,构造函数会从环境变量中读取 `GT_API_KEY`、`GT_DEV_API_KEY` 和 `GT_PROJECT_ID`。 ## 属性 | 属性 | 类型 | 描述 | | ---------------- | --------------- | ----------- | | `apiKey?` | `string` | 生产环境 API 密钥 | | `devApiKey?` | `string` | 开发环境 API 密钥 | | `sourceLocale?` | `string` | 默认源区域设置 | | `targetLocale?` | `string` | 默认目标区域设置 | | `locales?` | `string[]` | 支持的区域设置代码 | | `projectId?` | `string` | 项目标识符 | | `baseUrl?` | `string` | 自定义 API 端点 | | `customMapping?` | `CustomMapping` | 自定义区域设置映射 | ## 示例 ### 基础设置 ```typescript copy const gt = new GT({ apiKey: 'your-api-key', sourceLocale: 'en', targetLocale: 'es', locales: ['en', 'es', 'fr'] }); ``` ### 通过环境变量 ```typescript copy const gt = new GT({ sourceLocale: 'en', targetLocale: 'es' }); // 从环境变量中读取 GT_API_KEY 和 GT_PROJECT_ID ``` ## 相关类型 * [`CustomMapping`](/docs/core/types/custom-mapping) - 自定义区域设置的定义