Skip to main content

Automated end-to-end fine-tuning of OpenAI models with Google Drive integration

Workflow preview

Workflow preview
100%
Automated end-to-end fine-tuning of OpenAI models with Google Drive integration preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

1. How it Works This n8n workflow automates fine tuning OpenAI models through these key steps: Manual Trigger : Starts with the "When clicking ‘Test workflow’" event to initiate the process. Downlo...

Best for

  • Engineering automation workflows
  • AI Chatbot automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.googledrive, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.openai, n8n-nodes-base.httprequest

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Davide.

Original n8n.io source

1.1 Workflow description

Title
Automated end-to-end fine-tuning of OpenAI models with Google Drive integration
Workflow name
Automated end-to-end fine-tuning of OpenAI models with Google Drive integration

1. How it Works

This n8n workflow automates fine-tuning OpenAI models through these key steps:

  • Manual Trigger:
    • Starts with the "When clicking ‘Test workflow’" event to initiate the process.
    • Downloads a .jsonl file from Google Drive
  • Upload to OpenAI:
    • Uploads the .jsonl file to OpenAI via the "Upload File" node (with purpose "fine-tune").
  • Create Fine-tuning Job:
    • Sends a POST request to the endpoint https://api.openai.com/v1/fine_tuning/jobs with:
      {  
        "training_file": "{{ $json.id }}",  
        "model": "gpt-4o-mini-2024-07-18"  
      }  
      
    • OpenAI automatically starts training the model based on the provided file.
  • Interaction with the Trained Model:
    • An "AI Agent" uses the custom model (e.g., ft:gpt-4o-mini-2024-07-18:n3w-italia::XXXX7B) to respond to chat messages.

2. Set up Steps

To configure the workflow:

  1. Prepare the Training File:

    • Create a .jsonl file following the specified syntax (e.g., travel assistant Q/A examples).
    • Upload it to Google Drive and update the ID in the "Google Drive" node.
  2. Configure Credentials:

    • Google Drive: Connect an account via OAuth2 (googleDriveOAuth2Api).
    • OpenAI: Add your API key in the "OpenAI Chat Model" and "Upload File" nodes.
  3. Customize the Model:

    • In the "OpenAI Chat Model" node, specify the name of your fine-tuned model (e.g., ft:gpt-4o-mini-...).
    • Update the HTTP request body (Create Fine-tuning Job) if needed (e.g., a different base model).
  4. Start the Workflow:

    • Use the manual trigger ("Test workflow") to begin the upload and training process.
    • Test the model via the "Chat Trigger" (chat messages).
  5. Integrated Documentation:

    • Follow the instructions in the Sticky Notes to:
      • Properly format the .jsonl (Step 1).
      • Monitor progress on OpenAI (Step 2, link: https://platform.openai.com/finetune/).

Note: Ensure the .jsonl file adheres to OpenAI’s required structure and that credentials are valid.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Google Drive

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 3 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 4 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 5 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.1

Block 6 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Upload File

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 9 - Create Fine-tuning Job

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

3. Summary Table

Workflow Automated end-to-end fine-tuning of OpenAI models with Google Drive integration
Complexity intermediate
Nodes 9
Categories Engineering, AI Chatbot
Author Davide
Published 23 Jan 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2781/2781.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automated end-to-end fine-tuning of OpenAI models with Google Drive integration do?

1. How it Works This n8n workflow automates fine tuning OpenAI models through these key steps: Manual Trigger : Starts with the "When clicking ‘Test workflow’" event to initiate the process. Downlo...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI Chatbot use case.