UNPKG

@n8n/n8n-nodes-langchain

Version:
37 lines • 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.apiRequest = apiRequest; const n8n_workflow_1 = require("n8n-workflow"); async function apiRequest(method, endpoint, parameters) { const { body, qs, headers } = parameters ?? {}; const credentials = await this.getCredentials('anthropicApi'); const baseUrl = credentials.url ?? 'https://api.anthropic.com'; const betas = ['files-api-2025-04-14']; if (parameters?.enableAnthropicBetas?.promptTools) { betas.push('prompt-tools-2025-04-02'); } if (parameters?.enableAnthropicBetas?.codeExecution) { betas.push('code-execution-2025-05-22'); } const requestHeaders = { 'anthropic-version': '2023-06-01', 'anthropic-beta': betas.join(','), ...headers, }; if (credentials.header && typeof credentials.headerName === 'string' && credentials.headerName && typeof credentials.headerValue === 'string') { requestHeaders[credentials.headerName] = credentials.headerValue; } const options = { headers: requestHeaders, method, body, qs, url: (0, n8n_workflow_1.requestUrl) `${baseUrl}${endpoint}`, json: true, }; return await this.helpers.httpRequestWithAuthentication.call(this, 'anthropicApi', options); } //# sourceMappingURL=index.js.map