Step 1: Access Your LLM Provider and Obtain an API Key. For OpenAI, visit platform.openai.com/api-keys. For Google Cloud (Gemini), follow their credential setup for API access. For Anthropic Claude, obtain a key from their console.
Step 2: Create New Credentials in n8n. In n8n, navigate to 'Credentials' in the left sidebar. Click 'New Credential' and search for your chosen LLM provider (e.g., 'OpenAI API'). Select it and paste your API key into the designated field. Give the credential a descriptive name (e.g., 'MyOpenAIKey') and save it securely.
Step 3: Start a New Workflow and Add an LLM Node. In the n8n canvas, create a new workflow. Add a 'Start' node. Search for your LLM provider's node (e.g., 'OpenAI') and drag it onto the canvas. Connect the 'Start' node to the 'OpenAI' node.
Step 4: Configure the LLM Node with Credentials and Model. Double-click the LLM node. In the 'Credentials' dropdown, select the credential you created in Step 2. Choose an appropriate 'Model' (e.g., 'gpt-3.5-turbo' for OpenAI, 'gemini-pro' for Google).
Step 5: Craft Your First Prompt. In the LLM node's parameters, locate the 'Messages' section. Add a new message. Set the 'Role' to 'User'. In the 'Content' field, enter your prompt. For example: 'Draft a concise, engaging social media post announcing a new online course on n8n AI automation. Highlight its benefits: flexibility, cost-effectiveness, and powerful integrations.'
Step 6: Execute the Workflow and Review Output. Click 'Execute Workflow' on the n8n canvas. After execution, inspect the output of the LLM node. The generated text will typically be within a 'data' array, often under 'choices[0].message.content' for OpenAI or similar paths for other providers.
Step 7: Parse the LLM Output. Add a 'Set' node after the LLM node. Use an expression like {{ $json.choices[0].message.content }} to extract the generated text. This isolates the desired content for use in subsequent nodes. Connect the 'Set' node to the LLM node and re-execute to see the parsed output.