n8n-nodes-zihin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Aionz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # n8n-nodes-zihin
2
+
3
+ [![npm version](https://badge.fury.io/js/n8n-nodes-zihin.svg)](https://badge.fury.io/js/n8n-nodes-zihin)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ n8n node for **Zihin LLM Gateway** - Unified LLM API with intelligent provider routing.
7
+
8
+ ## O que é o Zihin?
9
+
10
+ Zihin é um gateway inteligente de LLMs que oferece:
11
+
12
+ - **Roteamento Automático**: Seleciona automaticamente o melhor modelo para cada tarefa
13
+ - **Cache Semântico**: Reduz custos e latência com cache inteligente
14
+ - **Acesso Unificado**: Uma única API para múltiplos providers (OpenAI, Anthropic, Google, Grok, OpenRouter)
15
+ - **Monitoramento**: Rastreamento de custos, uso e performance em tempo real
16
+
17
+ ## Instalação
18
+
19
+ ### Via n8n Community Nodes
20
+
21
+ 1. Abra sua instância do n8n
22
+ 2. Vá para **Settings** > **Community Nodes**
23
+ 3. Selecione **Install**
24
+ 4. Digite `n8n-nodes-zihin` e clique em **Install**
25
+
26
+ ### Via npm
27
+
28
+ ```bash
29
+ npm install n8n-nodes-zihin
30
+ ```
31
+
32
+ ### Desenvolvimento Local
33
+
34
+ ```bash
35
+ # Clone o repositório
36
+ git clone https://github.com/oliveiraronan/n8n-nodes-zihin.git
37
+ cd n8n-nodes-zihin
38
+
39
+ # Instale dependências
40
+ npm install
41
+
42
+ # Build
43
+ npm run build
44
+
45
+ # Link para n8n local
46
+ cd ~/.n8n/nodes
47
+ npm link /caminho/para/n8n-nodes-zihin
48
+ ```
49
+
50
+ ## Configuração
51
+
52
+ ### Obter API Key
53
+
54
+ 1. Acesse [zihin.ai](https://zihin.ai) e crie uma conta
55
+ 2. Navegue até **Settings** > **API Keys**
56
+ 3. Crie uma nova API Key (formato: `zhn_live_xxx` ou `zhn_test_xxx`)
57
+
58
+ ### Configurar Credenciais no n8n
59
+
60
+ 1. No n8n, vá para **Credentials** > **Add Credential**
61
+ 2. Busque por **Zihin API**
62
+ 3. Cole sua API Key
63
+ 4. Salve as credenciais
64
+
65
+ ## Uso
66
+
67
+ ### Exemplo Básico - Prompt Simples
68
+
69
+ 1. Adicione o nó **Zihin Gateway** ao seu workflow
70
+ 2. Selecione um modelo (ex: `OpenAI - GPT-4o`)
71
+ 3. Escolha **Input Type**: `Prompt Simples`
72
+ 4. Digite seu prompt
73
+ 5. Execute o workflow
74
+
75
+ ### Exemplo - Auto-routing
76
+
77
+ O Zihin pode selecionar automaticamente o melhor modelo para sua tarefa:
78
+
79
+ 1. Selecione **Model**: `Auto (Roteamento Inteligente)`
80
+ 2. Escolha o **Task Type** que melhor descreve sua tarefa:
81
+ - `Chat / Conversação`: Conversas gerais
82
+ - `Coding / Programação`: Geração e análise de código
83
+ - `Analysis / Análise`: Análise de dados e documentos
84
+ - `Planning / Planejamento`: Planejamento e estratégia
85
+ - `Creative / Criativo`: Escrita criativa
86
+ - `Data Query / Consulta de Dados`: Consultas estruturadas
87
+ - `Tool Calling / Chamada de Ferramentas`: Uso de ferramentas/funções
88
+ 3. Adicione suas mensagens no formato **Messages** (o modo Auto requer formato conversacional)
89
+
90
+ ### Exemplo - Conversação Multi-turno
91
+
92
+ Para conversas com contexto:
93
+
94
+ 1. Escolha **Input Type**: `Messages (Conversacional)`
95
+ 2. Adicione mensagens com diferentes roles:
96
+ - `System`: Instruções de comportamento do assistente
97
+ - `User`: Mensagens do usuário
98
+ - `Assistant`: Respostas anteriores do assistente
99
+
100
+ ## Parâmetros
101
+
102
+ ### Parâmetros Principais
103
+
104
+ | Parâmetro | Tipo | Obrigatório | Descrição |
105
+ |-----------|------|-------------|-----------|
106
+ | Model | options | Sim | Modelo LLM ou "auto" para roteamento inteligente |
107
+ | Task Type | options | Não | Tipo de tarefa (apenas quando model="auto") |
108
+ | Input Type | options | Sim | "Prompt Simples" ou "Messages" (Auto requer Messages) |
109
+ | Prompt | string | Condicional | Texto do prompt (quando Input Type = "Prompt Simples") |
110
+ | Messages | collection | Condicional | Lista de mensagens (quando Input Type = "Messages") |
111
+
112
+ ### Options (Avançado)
113
+
114
+ | Parâmetro | Tipo | Default | Descrição |
115
+ |-----------|------|---------|-----------|
116
+ | Temperature | number | 0.7 | Criatividade (0-2) |
117
+ | Max Tokens | number | 1000 | Limite de tokens na resposta |
118
+ | Top P | number | 1 | Nucleus sampling (0-1) |
119
+ | Frequency Penalty | number | 0 | Reduz repetição (-2 a 2) |
120
+ | Presence Penalty | number | 0 | Incentiva novos tópicos (-2 a 2) |
121
+ | Stop Sequences | string | - | Sequências de parada (vírgula-separadas) |
122
+ | Session ID | string | - | ID para manter contexto entre chamadas |
123
+
124
+ ## Modelos Disponíveis
125
+
126
+ ### OpenAI
127
+ - GPT-5 (`openai.gpt-5`)
128
+ - GPT-5 Mini (`openai.gpt-5-mini`)
129
+ - GPT-5 Nano (`openai.gpt-5-nano`)
130
+ - GPT-4.1 (`openai.gpt-4.1`)
131
+ - GPT-4.1 Mini (`openai.gpt-4.1-mini`)
132
+ - GPT-4.1 Nano (`openai.gpt-4.1-nano`)
133
+
134
+ ### Anthropic
135
+ - Claude Sonnet 4.5 (`anthropic.claude-sonnet-4-5-20250929`)
136
+ - Claude Haiku 4.5 (`anthropic.claude-haiku-4-5-20251001`)
137
+ - Claude Opus 4.1 (`anthropic.claude-opus-4-1-20250805`)
138
+ - Claude Sonnet 4 (`anthropic.claude-sonnet-4-20250514`)
139
+ - Claude 3.5 Haiku (`anthropic.claude-3-5-haiku-20241022`)
140
+
141
+ ### Google
142
+ - Gemini 2.5 Flash Lite (`google.gemini-2.5-flash-lite`)
143
+ - Gemini 2.0 Flash (`google.gemini-2.0-flash`)
144
+ - Gemini 2.0 Flash Lite (`google.gemini-2.0-flash-lite`)
145
+
146
+ ### Grok
147
+ - Grok 4 Fast Reasoning (`grok.grok-4-fast-reasoning`)
148
+ - Grok 4 Fast (`grok.grok-4-fast-non-reasoning`)
149
+ - Grok 4 (`grok.grok-4-0709`)
150
+ - Grok Code Fast (`grok.grok-code-fast-1`)
151
+ - Grok 3 (`grok.grok-3`)
152
+ - Grok 3 Mini (`grok.grok-3-mini`)
153
+ - Grok 2 (`grok.grok-2-1212`)
154
+ - Grok 2 Vision (`grok.grok-2-vision-1212`)
155
+
156
+ ## Output
157
+
158
+ O nó retorna um objeto JSON com a seguinte estrutura:
159
+
160
+ ```json
161
+ {
162
+ "content": "Resposta do modelo...",
163
+ "model": "gpt-4.1-mini",
164
+ "provider": "openai",
165
+ "threadId": null,
166
+ "finishReason": "stop",
167
+ "usage": {
168
+ "prompt_tokens": 50,
169
+ "completion_tokens": 100,
170
+ "total_tokens": 150,
171
+ "cached_tokens": 0
172
+ },
173
+ "cost": {
174
+ "input_cost_usd": 0.00025,
175
+ "output_cost_usd": 0.0015,
176
+ "total_cost_usd": 0.00175
177
+ },
178
+ "cached": false,
179
+ "requestId": "req_abc123",
180
+ "executionTimeMs": 1234,
181
+ "autoRouting": null
182
+ }
183
+ ```
184
+
185
+ Quando usando `model="auto"`, o campo `autoRouting` contém:
186
+
187
+ ```json
188
+ {
189
+ "autoRouting": {
190
+ "originalModel": "auto",
191
+ "selectedModel": "openai.gpt-4o",
192
+ "confidence": 0.95,
193
+ "reasoning": "Task requires coding capabilities..."
194
+ }
195
+ }
196
+ ```
197
+
198
+ ## Troubleshooting
199
+
200
+ ### Erro: "API Key inválida ou expirada"
201
+ - Verifique se a API Key está correta
202
+ - Confirme que a key não expirou no dashboard do Zihin
203
+ - Teste a key diretamente na API
204
+
205
+ ### Erro: "Rate limit excedido"
206
+ - Aguarde o tempo indicado na mensagem
207
+ - Considere upgrade do plano no Zihin
208
+ - Implemente retry com backoff no workflow
209
+
210
+ ### Erro: "Modelo inválido"
211
+ - Verifique se o modelo selecionado está disponível
212
+ - Use o modelo "auto" se não tiver certeza
213
+
214
+ ### Erro de conexão
215
+ - Verifique sua conexão com a internet
216
+ - Confirme que `llm.zihin.ai` está acessível
217
+ - Verifique firewall/proxy da sua rede
218
+
219
+ ## Links Úteis
220
+
221
+ - [Documentação Zihin](https://docs.zihin.ai)
222
+ - [Dashboard Zihin](https://zihin.ai)
223
+ - [Documentação n8n](https://docs.n8n.io)
224
+ - [GitHub Issues](https://github.com/aionz-tech/n8n-nodes-zihin/issues)
225
+
226
+ ## Suporte
227
+
228
+ - **Bugs e Features**: [GitHub Issues](https://github.com/aionz-tech/n8n-nodes-zihin/issues)
229
+ - **Email**: dev@aionz.com.br
230
+ - **Documentação**: [docs.zihin.ai](https://docs.zihin.ai)
231
+
232
+ ## Licença
233
+
234
+ MIT License - veja o arquivo [LICENSE](LICENSE) para detalhes.
235
+
236
+ ---
237
+
238
+ Desenvolvido por [Aionz](https://aionz.com.br)
@@ -0,0 +1,9 @@
1
+ import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class ZihinApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ test: ICredentialTestRequest;
9
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZihinApi = void 0;
4
+ class ZihinApi {
5
+ constructor() {
6
+ this.name = 'zihinApi';
7
+ this.displayName = 'Zihin API';
8
+ this.documentationUrl = 'https://docs.zihin.ai';
9
+ this.properties = [
10
+ {
11
+ displayName: 'API Key',
12
+ name: 'apiKey',
13
+ type: 'string',
14
+ typeOptions: {
15
+ password: true,
16
+ },
17
+ default: '',
18
+ required: true,
19
+ description: 'API Key do Zihin (formato: zhn_live_xxx ou zhn_test_xxx)',
20
+ },
21
+ ];
22
+ this.authenticate = {
23
+ type: 'generic',
24
+ properties: {
25
+ headers: {
26
+ 'X-Api-Key': '={{$credentials.apiKey}}',
27
+ },
28
+ },
29
+ };
30
+ this.test = {
31
+ request: {
32
+ baseURL: 'https://llm.zihin.ai',
33
+ url: '/api/v3/llm/public/call',
34
+ method: 'POST',
35
+ headers: {
36
+ 'Content-Type': 'application/json',
37
+ },
38
+ body: JSON.stringify({
39
+ model: 'openai.gpt-4.1-mini',
40
+ prompt: 'Say "ok" only.',
41
+ options: {
42
+ maxTokens: 5,
43
+ },
44
+ }),
45
+ },
46
+ };
47
+ }
48
+ }
49
+ exports.ZihinApi = ZihinApi;
50
+ //# sourceMappingURL=ZihinApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZihinApi.credentials.js","sourceRoot":"","sources":["../../src/credentials/ZihinApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,QAAQ;IAArB;QACE,SAAI,GAAG,UAAU,CAAC;QAClB,gBAAW,GAAG,WAAW,CAAC;QAC1B,qBAAgB,GAAG,uBAAuB,CAAC;QAC3C,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACX,QAAQ,EAAE,IAAI;iBACf;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,0DAA0D;aACxE;SACF,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,WAAW,EAAE,0BAA0B;iBACxC;aACF;SACF,CAAC;QAEF,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,sBAAsB;gBAC/B,GAAG,EAAE,yBAAyB;gBAC9B,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,KAAK,EAAE,qBAAqB;oBAC5B,MAAM,EAAE,gBAAgB;oBACxB,OAAO,EAAE;wBACP,SAAS,EAAE,CAAC;qBACb;iBACF,CAAC;aACH;SACF,CAAC;IACJ,CAAC;CAAA;AA5CD,4BA4CC"}
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class ZihinGateway implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,432 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZihinGateway = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class ZihinGateway {
6
+ constructor() {
7
+ this.description = {
8
+ displayName: 'Zihin LLM Gateway',
9
+ name: 'zihinGateway',
10
+ icon: 'file:zihin.png',
11
+ group: ['transform'],
12
+ version: 1,
13
+ subtitle: '={{$parameter["model"]}}',
14
+ description: 'Unified LLM API with intelligent provider routing',
15
+ defaults: {
16
+ name: 'Zihin LLM Gateway',
17
+ },
18
+ inputs: ['main'],
19
+ outputs: ['main'],
20
+ credentials: [
21
+ {
22
+ name: 'zihinApi',
23
+ required: true,
24
+ },
25
+ ],
26
+ properties: [
27
+ // Model Selection
28
+ {
29
+ displayName: 'Model',
30
+ name: 'model',
31
+ type: 'options',
32
+ required: true,
33
+ default: 'auto',
34
+ description: 'Modelo LLM a ser usado. Use "auto" para roteamento inteligente.',
35
+ options: [
36
+ { name: 'Auto (Roteamento Inteligente)', value: 'auto' },
37
+ // OpenAI - GPT-5 Family
38
+ { name: 'OpenAI - GPT-5', value: 'openai.gpt-5' },
39
+ { name: 'OpenAI - GPT-5 Mini', value: 'openai.gpt-5-mini' },
40
+ { name: 'OpenAI - GPT-5 Nano', value: 'openai.gpt-5-nano' },
41
+ // OpenAI - GPT-4.1 Family
42
+ { name: 'OpenAI - GPT-4.1', value: 'openai.gpt-4.1' },
43
+ { name: 'OpenAI - GPT-4.1 Mini', value: 'openai.gpt-4.1-mini' },
44
+ { name: 'OpenAI - GPT-4.1 Nano', value: 'openai.gpt-4.1-nano' },
45
+ // Anthropic - Claude 4.5 Family
46
+ { name: 'Anthropic - Claude Sonnet 4.5', value: 'anthropic.claude-sonnet-4-5-20250929' },
47
+ { name: 'Anthropic - Claude Haiku 4.5', value: 'anthropic.claude-haiku-4-5-20251001' },
48
+ // Anthropic - Claude 4 Family
49
+ { name: 'Anthropic - Claude Opus 4.1', value: 'anthropic.claude-opus-4-1-20250805' },
50
+ { name: 'Anthropic - Claude Sonnet 4', value: 'anthropic.claude-sonnet-4-20250514' },
51
+ // Anthropic - Legacy
52
+ { name: 'Anthropic - Claude 3.5 Haiku', value: 'anthropic.claude-3-5-haiku-20241022' },
53
+ // Google - Gemini Family
54
+ { name: 'Google - Gemini 2.5 Flash Lite', value: 'google.gemini-2.5-flash-lite' },
55
+ { name: 'Google - Gemini 2.0 Flash', value: 'google.gemini-2.0-flash' },
56
+ { name: 'Google - Gemini 2.0 Flash Lite', value: 'google.gemini-2.0-flash-lite' },
57
+ // Grok - Grok-4 Family
58
+ { name: 'Grok - Grok 4 Fast Reasoning', value: 'grok.grok-4-fast-reasoning' },
59
+ { name: 'Grok - Grok 4 Fast', value: 'grok.grok-4-fast-non-reasoning' },
60
+ { name: 'Grok - Grok 4', value: 'grok.grok-4-0709' },
61
+ { name: 'Grok - Grok Code Fast', value: 'grok.grok-code-fast-1' },
62
+ // Grok - Grok-3 Family
63
+ { name: 'Grok - Grok 3', value: 'grok.grok-3' },
64
+ { name: 'Grok - Grok 3 Mini', value: 'grok.grok-3-mini' },
65
+ // Grok - Grok-2 Legacy
66
+ { name: 'Grok - Grok 2', value: 'grok.grok-2-1212' },
67
+ { name: 'Grok - Grok 2 Vision', value: 'grok.grok-2-vision-1212' },
68
+ ],
69
+ },
70
+ // Task Type (conditional - only when model="auto")
71
+ {
72
+ displayName: 'Task Type',
73
+ name: 'taskType',
74
+ type: 'options',
75
+ default: 'chat',
76
+ description: 'Tipo de tarefa para otimizar a seleção automática do modelo',
77
+ displayOptions: {
78
+ show: {
79
+ model: ['auto'],
80
+ },
81
+ },
82
+ options: [
83
+ { name: 'Chat / Conversação', value: 'chat' },
84
+ { name: 'Coding / Programação', value: 'coding' },
85
+ { name: 'Analysis / Análise', value: 'analysis' },
86
+ { name: 'Planning / Planejamento', value: 'planning' },
87
+ { name: 'Creative / Criativo', value: 'creative' },
88
+ { name: 'Data Query / Consulta de Dados', value: 'data_query' },
89
+ { name: 'Tool Calling / Chamada de Ferramentas', value: 'tool_calling' },
90
+ ],
91
+ },
92
+ // Input Type (when model is NOT auto)
93
+ {
94
+ displayName: 'Input Type',
95
+ name: 'inputType',
96
+ type: 'options',
97
+ default: 'prompt',
98
+ description: 'Formato de entrada: prompt simples ou mensagens conversacionais',
99
+ displayOptions: {
100
+ hide: {
101
+ model: ['auto'],
102
+ },
103
+ },
104
+ options: [
105
+ { name: 'Prompt Simples', value: 'prompt' },
106
+ { name: 'Messages (Conversacional)', value: 'messages' },
107
+ ],
108
+ },
109
+ // Input Type (when model IS auto - only messages allowed)
110
+ {
111
+ displayName: 'Input Type',
112
+ name: 'inputType',
113
+ type: 'hidden',
114
+ default: 'messages',
115
+ displayOptions: {
116
+ show: {
117
+ model: ['auto'],
118
+ },
119
+ },
120
+ },
121
+ // Notice for auto mode
122
+ {
123
+ displayName: 'O modo Auto requer formato Messages (conversacional)',
124
+ name: 'autoNotice',
125
+ type: 'notice',
126
+ default: '',
127
+ displayOptions: {
128
+ show: {
129
+ model: ['auto'],
130
+ },
131
+ },
132
+ },
133
+ // Prompt (conditional - inputType="prompt" AND model is NOT auto)
134
+ {
135
+ displayName: 'Prompt',
136
+ name: 'prompt',
137
+ type: 'string',
138
+ typeOptions: {
139
+ rows: 4,
140
+ },
141
+ default: '',
142
+ required: true,
143
+ displayOptions: {
144
+ show: {
145
+ inputType: ['prompt'],
146
+ },
147
+ hide: {
148
+ model: ['auto'],
149
+ },
150
+ },
151
+ description: 'Texto do prompt a ser enviado ao modelo',
152
+ },
153
+ // Messages (conditional - inputType="messages" OR model="auto")
154
+ {
155
+ displayName: 'Messages',
156
+ name: 'messages',
157
+ type: 'fixedCollection',
158
+ typeOptions: {
159
+ multipleValues: true,
160
+ sortable: true,
161
+ },
162
+ default: {},
163
+ displayOptions: {
164
+ show: {
165
+ inputType: ['messages'],
166
+ },
167
+ },
168
+ placeholder: 'Add Message',
169
+ options: [
170
+ {
171
+ name: 'messageValues',
172
+ displayName: 'Message',
173
+ values: [
174
+ {
175
+ displayName: 'Role',
176
+ name: 'role',
177
+ type: 'options',
178
+ options: [
179
+ { name: 'System', value: 'system' },
180
+ { name: 'User', value: 'user' },
181
+ { name: 'Assistant', value: 'assistant' },
182
+ ],
183
+ default: 'user',
184
+ description: 'Papel da mensagem na conversa',
185
+ },
186
+ {
187
+ displayName: 'Content',
188
+ name: 'content',
189
+ type: 'string',
190
+ typeOptions: {
191
+ rows: 3,
192
+ },
193
+ default: '',
194
+ description: 'Conteúdo da mensagem',
195
+ },
196
+ ],
197
+ },
198
+ ],
199
+ description: 'Lista de mensagens para conversação multi-turno',
200
+ },
201
+ // Options (collapsible collection)
202
+ {
203
+ displayName: 'Options',
204
+ name: 'options',
205
+ type: 'collection',
206
+ placeholder: 'Add Option',
207
+ default: {},
208
+ options: [
209
+ {
210
+ displayName: 'Temperature',
211
+ name: 'temperature',
212
+ type: 'number',
213
+ typeOptions: {
214
+ minValue: 0,
215
+ maxValue: 2,
216
+ numberStepSize: 0.1,
217
+ },
218
+ default: 0.7,
219
+ description: 'Controla a criatividade (0 = determinístico, 2 = muito criativo)',
220
+ },
221
+ {
222
+ displayName: 'Max Tokens',
223
+ name: 'maxTokens',
224
+ type: 'number',
225
+ typeOptions: {
226
+ minValue: 1,
227
+ maxValue: 128000,
228
+ },
229
+ default: 1000,
230
+ description: 'Limite máximo de tokens na resposta',
231
+ },
232
+ {
233
+ displayName: 'Top P',
234
+ name: 'topP',
235
+ type: 'number',
236
+ typeOptions: {
237
+ minValue: 0,
238
+ maxValue: 1,
239
+ numberStepSize: 0.1,
240
+ },
241
+ default: 1,
242
+ description: 'Nucleus sampling (alternativa a temperature)',
243
+ },
244
+ {
245
+ displayName: 'Frequency Penalty',
246
+ name: 'frequencyPenalty',
247
+ type: 'number',
248
+ typeOptions: {
249
+ minValue: -2,
250
+ maxValue: 2,
251
+ numberStepSize: 0.1,
252
+ },
253
+ default: 0,
254
+ description: 'Reduz repetição de tokens frequentes',
255
+ },
256
+ {
257
+ displayName: 'Presence Penalty',
258
+ name: 'presencePenalty',
259
+ type: 'number',
260
+ typeOptions: {
261
+ minValue: -2,
262
+ maxValue: 2,
263
+ numberStepSize: 0.1,
264
+ },
265
+ default: 0,
266
+ description: 'Incentiva novos tópicos na resposta',
267
+ },
268
+ {
269
+ displayName: 'Stop Sequences',
270
+ name: 'stop',
271
+ type: 'string',
272
+ default: '',
273
+ description: 'Sequências que param a geração (separadas por vírgula, máx 4)',
274
+ },
275
+ {
276
+ displayName: 'Session ID',
277
+ name: 'sessionId',
278
+ type: 'string',
279
+ default: '',
280
+ description: 'ID de sessão para manter contexto entre chamadas',
281
+ },
282
+ ],
283
+ },
284
+ ],
285
+ };
286
+ }
287
+ async execute() {
288
+ const items = this.getInputData();
289
+ const returnData = [];
290
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
291
+ try {
292
+ // Get parameters
293
+ const model = this.getNodeParameter('model', itemIndex);
294
+ const inputType = this.getNodeParameter('inputType', itemIndex);
295
+ const options = this.getNodeParameter('options', itemIndex, {});
296
+ // Build request body
297
+ const body = {
298
+ model,
299
+ };
300
+ // Add prompt or messages based on input type
301
+ if (inputType === 'prompt') {
302
+ const prompt = this.getNodeParameter('prompt', itemIndex);
303
+ if (!prompt) {
304
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Prompt é obrigatório quando Input Type é "Prompt Simples"', { itemIndex });
305
+ }
306
+ body.prompt = prompt;
307
+ }
308
+ else {
309
+ const messagesData = this.getNodeParameter('messages', itemIndex, {});
310
+ if (!messagesData.messageValues || messagesData.messageValues.length === 0) {
311
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Pelo menos uma mensagem é obrigatória quando Input Type é "Messages"', { itemIndex });
312
+ }
313
+ body.messages = messagesData.messageValues.map((msg) => ({
314
+ role: msg.role,
315
+ content: msg.content,
316
+ }));
317
+ }
318
+ // Add context for auto-routing
319
+ if (model === 'auto') {
320
+ const taskType = this.getNodeParameter('taskType', itemIndex);
321
+ body.context = {
322
+ task: taskType,
323
+ };
324
+ }
325
+ // Add options
326
+ const requestOptions = {};
327
+ if (options.temperature !== undefined) {
328
+ requestOptions.temperature = options.temperature;
329
+ }
330
+ if (options.maxTokens !== undefined) {
331
+ requestOptions.maxTokens = options.maxTokens;
332
+ }
333
+ if (options.topP !== undefined) {
334
+ requestOptions.topP = options.topP;
335
+ }
336
+ if (options.frequencyPenalty !== undefined) {
337
+ requestOptions.frequencyPenalty = options.frequencyPenalty;
338
+ }
339
+ if (options.presencePenalty !== undefined) {
340
+ requestOptions.presencePenalty = options.presencePenalty;
341
+ }
342
+ if (options.stop) {
343
+ const stopSequences = options.stop.split(',').map((s) => s.trim()).slice(0, 4);
344
+ if (stopSequences.length > 0) {
345
+ requestOptions.stop = stopSequences;
346
+ }
347
+ }
348
+ if (options.sessionId) {
349
+ requestOptions.session_id = options.sessionId;
350
+ }
351
+ if (Object.keys(requestOptions).length > 0) {
352
+ body.options = requestOptions;
353
+ }
354
+ // Make API request
355
+ const response = await this.helpers.httpRequestWithAuthentication.call(this, 'zihinApi', {
356
+ method: 'POST',
357
+ url: 'https://llm.zihin.ai/api/v3/llm/public/call',
358
+ headers: {
359
+ 'Content-Type': 'application/json',
360
+ },
361
+ body,
362
+ json: true,
363
+ });
364
+ // Handle response
365
+ if (!response.success) {
366
+ if (response.error === 'RATE_LIMIT_EXCEEDED') {
367
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
368
+ message: `Rate limit excedido. Aguarde ${response.retryAfter || 60} segundos.`,
369
+ description: 'Muitas requisições em curto período.',
370
+ });
371
+ }
372
+ if (response.error === 'UNAUTHORIZED') {
373
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
374
+ message: 'API Key inválida ou expirada',
375
+ description: 'Verifique suas credenciais do Zihin.',
376
+ });
377
+ }
378
+ if (response.error === 'MODEL_REQUIRED' || response.error === 'INVALID_MODEL') {
379
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
380
+ message: `Modelo inválido: ${model}`,
381
+ description: response.message || 'O modelo especificado não é válido ou não está disponível.',
382
+ });
383
+ }
384
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
385
+ message: response.message || 'Erro na API Zihin',
386
+ description: `Erro: ${response.error}. Request ID: ${response.requestId || 'N/A'}`,
387
+ });
388
+ }
389
+ // Return structured output
390
+ if (response.data) {
391
+ returnData.push({
392
+ json: {
393
+ content: response.data.content,
394
+ model: response.data.model,
395
+ provider: response.data.provider,
396
+ threadId: response.data.threadId || null,
397
+ finishReason: response.data.finish_reason || null,
398
+ usage: response.data.usage,
399
+ cost: response.data.cost || null,
400
+ cached: response.data.usage?.cached_tokens ? response.data.usage.cached_tokens > 0 : false,
401
+ requestId: response.data.metadata?.request_id || null,
402
+ executionTimeMs: response.data.metadata?.execution_time_ms || null,
403
+ autoRouting: response.data.autoRouting || null,
404
+ },
405
+ pairedItem: { item: itemIndex },
406
+ });
407
+ }
408
+ }
409
+ catch (error) {
410
+ if (error instanceof n8n_workflow_1.NodeApiError || error instanceof n8n_workflow_1.NodeOperationError) {
411
+ if (this.continueOnFail()) {
412
+ returnData.push({
413
+ json: {
414
+ error: error.message,
415
+ },
416
+ pairedItem: { item: itemIndex },
417
+ });
418
+ continue;
419
+ }
420
+ throw error;
421
+ }
422
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
423
+ message: 'Falha na comunicação com Zihin API',
424
+ description: error instanceof Error ? error.message : 'Erro desconhecido',
425
+ });
426
+ }
427
+ }
428
+ return [returnData];
429
+ }
430
+ }
431
+ exports.ZihinGateway = ZihinGateway;
432
+ //# sourceMappingURL=ZihinGateway.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZihinGateway.node.js","sourceRoot":"","sources":["../../../src/nodes/ZihinGateway/ZihinGateway.node.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAgEtB,MAAa,YAAY;IAAzB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,mBAAmB;YAChC,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,0BAA0B;YACpC,WAAW,EAAE,mDAAmD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AAC;wBACH,SAAS;oBACX,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;oBACrC,OAAO,EAAE,oCAAoC;oBAC7C,WAAW,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;iBAC1E,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;CACF;AA7cD,oCA6cC"}
@@ -0,0 +1,4 @@
1
+ <svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="60" height="60" rx="8" fill="#005257"/>
3
+ <path d="M14 18H46V24H25.5L46 42V48H14V42H34.5L14 24V18Z" fill="#29E529"/>
4
+ </svg>
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "n8n-nodes-zihin",
3
+ "version": "0.1.0",
4
+ "description": "n8n node for Zihin LLM Gateway - Unified LLM API with intelligent provider routing",
5
+ "keywords": [
6
+ "n8n-community-node-package",
7
+ "n8n",
8
+ "llm",
9
+ "ai",
10
+ "zihin",
11
+ "openai",
12
+ "anthropic",
13
+ "claude",
14
+ "gpt",
15
+ "gemini"
16
+ ],
17
+ "license": "MIT",
18
+ "homepage": "https://zihin.ai",
19
+ "author": {
20
+ "name": "Zihin AI Inc.",
21
+ "email": "support@zihin.ai"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/aionz-tech/n8n-nodes-zihin.git"
26
+ },
27
+ "main": "dist/nodes/ZihinGateway/ZihinGateway.node.js",
28
+ "scripts": {
29
+ "build": "tsc && gulp build:icons",
30
+ "dev": "tsc --watch",
31
+ "lint": "eslint src --ext .ts",
32
+ "lint:fix": "eslint src --ext .ts --fix",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "n8n": {
39
+ "n8nNodesApiVersion": 1,
40
+ "credentials": [
41
+ "dist/credentials/ZihinApi.credentials.js"
42
+ ],
43
+ "nodes": [
44
+ "dist/nodes/ZihinGateway/ZihinGateway.node.js"
45
+ ]
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^20.10.0",
49
+ "@typescript-eslint/eslint-plugin": "^6.13.0",
50
+ "@typescript-eslint/parser": "^6.13.0",
51
+ "eslint": "^8.55.0",
52
+ "gulp": "^4.0.2",
53
+ "n8n-workflow": "^1.20.0",
54
+ "typescript": "^5.3.0"
55
+ },
56
+ "peerDependencies": {
57
+ "n8n-workflow": "*"
58
+ },
59
+ "engines": {
60
+ "node": ">=18.0.0"
61
+ }
62
+ }