n8n/packages/nodes-base/credentials/OpenAiApi.credentials.ts
Jan Oberhauser 7a984bb6b7
feat(OpenAI Node): Add a node to work with OpenAI (#4932)
* feat(OpenAI Node): Add a node to work with OpenAI

* Added codex file for OpenAi node

* Minor tweaks to Operation Image.

* Minor tweaks to Resource Text.

* Minor copy modification to Image:Create.

* Removed "a Text" in Text operations names.

*  Connect Response Format parameter and other improvements

*  Add "filter" postReceiveAction

*  Rename operations and add spelling mistake again to example

*  Rename another operation

Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
Co-authored-by: Giulio Andreini <andreini@netseven.it>
2022-12-16 01:05:42 +01:00

51 lines
1.1 KiB
TypeScript

import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class OpenAiApi implements ICredentialType {
name = 'openAiApi';
displayName = 'OpenAi';
documentationUrl = 'openAiApi';
properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
typeOptions: { password: true },
required: true,
default: '',
},
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'string',
default: '',
description:
"For users who belong to multiple organizations, you can set which organization is used for an API request. Usage from these API requests will count against the specified organization's subscription quota.",
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bearer {{$credentials.apiKey}}',
'OpenAI-Organization': '={{$credentials.organizationId}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.openai.com',
url: '/v1/models',
},
};
}