This workflow follows the HTTP Request → Postgres recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Actualizar_preciosxtoken_ia",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 5
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.3,
"position": [
0,
0
],
"id": "7c772283-ed36-4678-ba43-f0ef490d8228",
"name": "Schedule Trigger"
},
{
"parameters": {
"url": "https://openrouter.ai/api/v1/models",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_API_KEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [
208,
0
],
"id": "f4a70dbd-7bc6-460b-9466-86a819fc3635",
"name": "Embeddings_Openrouter"
},
{
"parameters": {
"operation": "executeQuery",
"query": "INSERT INTO precios_modelos (modelo, precio_input, precio_output, updated_at)\nVALUES (\n '{{ $json.modelo }}',\n {{ $json.precio_input }},\n {{ $json.precio_output }},\n NOW()\n)\nON CONFLICT (modelo)\nDO UPDATE SET\n precio_input = EXCLUDED.precio_input,\n precio_output = EXCLUDED.precio_output,\n updated_at = NOW();",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
624,
0
],
"id": "c28d7ddb-83df-4691-a55c-3f35acc21381",
"name": "Insertar_precios",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const modelos = $input.first().json.data;\n\nconst modelosDeseados = [\n 'openai/text-embedding-3-small',\n 'meta-llama/llama-3.1-8b-instruct',\n 'google/gemini-2.5-flash'\n];\n\nconst result = [];\n\nfor (const modelo of modelos) {\n if (modelosDeseados.some(m => modelo.id.includes(m.split('/')[1]))) {\n result.push({\n json: {\n modelo: modelo.id,\n precio_input: parseFloat(modelo.pricing.prompt),\n precio_output: parseFloat(modelo.pricing.completion)\n }\n });\n }\n}\n\n// Si no encuentra alguno, agregar precios fijos como fallback\nconst encontrados = result.map(r => r.json.modelo);\n\nif (!encontrados.some(m => m.includes('text-embedding'))) {\n result.push({ json: { modelo: 'openai/text-embedding-3-small', precio_input: 0.00000002, precio_output: 0.00000002 } });\n}\nif (!encontrados.some(m => m.includes('llama-3.1-8b'))) {\n result.push({ json: { modelo: 'meta-llama/llama-3.1-8b-instruct', precio_input: 0.00000005, precio_output: 0.00000008 } });\n}\nif (!encontrados.some(m => m.includes('gemini-2.5-flash'))) {\n result.push({ json: { modelo: 'google/gemini-2.5-flash', precio_input: 0.0000003, precio_output: 0.0000025 } });\n}\n\nreturn result;"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
416,
0
],
"id": "faf37cf4-ce2c-400e-a8c8-725bc660de46",
"name": "Clasificar_modelos"
}
],
"connections": {
"Schedule Trigger": {
"main": [
[
{
"node": "Embeddings_Openrouter",
"type": "main",
"index": 0
}
]
]
},
"Embeddings_Openrouter": {
"main": [
[
{
"node": "Clasificar_modelos",
"type": "main",
"index": 0
}
]
]
},
"Clasificar_modelos": {
"main": [
[
{
"node": "Insertar_precios",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate",
"availableInMCP": false,
"timeSavedMode": "fixed",
"errorWorkflow": "Lg4ma3dxwZeqgxOJDE0ew",
"callerPolicy": "workflowsFromSameOwner"
},
"versionId": "e6a24f31-e8c2-4cf8-91ec-4f8336e981f9",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "Nt_TG8twqBci0YAGNqGe1",
"tags": []
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
postgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Actualizar_preciosxtoken_ia. Uses httpRequest, postgres. Scheduled trigger; 4 nodes.
Source: https://github.com/sergioRancibia/n8n-automation-ai-agents-portfolio/blob/main/n8n-ai-automation-system/workflows/actualizar-tokens.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Automatically retrieve AWS invoices and create corresponding bills in FreeAgent, marking them as paid. This workflow eliminates manual data entry for AWS billing. Fetches invoices from AWS Invoicing A
Complete PostgreSQL-backed system: Keyword scoring → AI research → Multi-part content generation → fal.ai Nano Banana image generation → WordPress publishing
Chanchito_PROD. Uses googleGemini, postgres, telegram, httpRequest. Scheduled trigger; 94 nodes.
Version : 1.0
Automate Microsoft Teams Meeting Analysis with GPT-4.1, Outlook & Mem.ai Watch the YouTube video to get started Follow along with the blog post