fix(sdk-js): Pass api key in headers by default if in env

This commit is contained in:
bracesproul
2024-10-15 11:33:40 -07:00
parent f6fb2ef5ca
commit 85a76912d3
+3
View File
@@ -60,6 +60,9 @@ class BaseClient {
this.defaultHeaders = config?.defaultHeaders || {};
if (config?.apiKey != null) {
this.defaultHeaders["X-Api-Key"] = config.apiKey;
} else if (process.env.LANGCHAIN_API_KEY) {
// Attempt to read the API key from the environment
this.defaultHeaders["X-Api-Key"] = process.env.LANGCHAIN_API_KEY;
}
}