mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-03 08:57:28 -08:00
6cf0abab5b
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
51 lines
925 B
TypeScript
51 lines
925 B
TypeScript
import type {
|
|
IAuthenticateGeneric,
|
|
ICredentialTestRequest,
|
|
ICredentialType,
|
|
INodeProperties,
|
|
} from 'n8n-workflow';
|
|
|
|
export class AnthropicApi implements ICredentialType {
|
|
name = 'anthropicApi';
|
|
|
|
displayName = 'Anthropic';
|
|
|
|
documentationUrl = 'anthropic';
|
|
|
|
properties: INodeProperties[] = [
|
|
{
|
|
displayName: 'API Key',
|
|
name: 'apiKey',
|
|
type: 'string',
|
|
typeOptions: { password: true },
|
|
required: true,
|
|
default: '',
|
|
},
|
|
];
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
type: 'generic',
|
|
properties: {
|
|
headers: {
|
|
'x-api-key': '={{$credentials.apiKey}}',
|
|
},
|
|
},
|
|
};
|
|
|
|
test: ICredentialTestRequest = {
|
|
request: {
|
|
baseURL: 'https://api.anthropic.com',
|
|
url: '/v1/messages',
|
|
method: 'POST',
|
|
headers: {
|
|
'anthropic-version': '2023-06-01',
|
|
},
|
|
body: {
|
|
model: 'claude-3-haiku-20240307',
|
|
messages: [{ role: 'user', content: 'Hey' }],
|
|
max_tokens: 1,
|
|
},
|
|
},
|
|
};
|
|
}
|