Two Ways to Save 96% of Your Money Using DeepSeek R1 in n8n

Dr. Violet Howard shows how to use DeepSeek R1, a reasoning model that costs 96% less than OpenAI's O1, in n8n workflows. She walks through two integration methods: OpenRouter credentials and direct HTTP requests. The model solves logic puzzles step-by-step and ranks in the top 3% on Codeforces.
Chapters
This is the riddle that we're going to send off to Deepseek R1 and see if it can handle it. You're in a room with 3 light switches. Each switch controls one of 3 light bulbs in a separate room, but you can't see the light bulbs from where you are. You can only enter the room with the light bulbs once. How can you figure out which switch controls which bulb? So we're going to send this riddle off to Deepseek R1. Right now it's thinking about the riddle. It's going to assess its options, and then it's going to tell us the result as well as all of the reasoning steps that it took in its brain to get to the answer. So should be pretty cool to see what it comes up with. So just finished up running. If we click into this HTTP request, we can see what we got back was content as well as reasoning content. And so if we click into this next node just so we can read it a little better, we get the answer as well as the steps that it took to get to this answer. So this method uses both light status as well as heat to understand which bulb corresponds to the switch and only entering the room once. So got some really exciting news yesterday. Deepseek just released R1, which is a new model that is a reasoning model that is comparable, if not better, than OpenAI's O1 reasoning model. So today we're going to be looking at that a little bit, breaking it down, and then talking about the actual right way that you want to go ahead and use this within N8N. So let's jump into it. And if you want to check out this report, I will leave the link for that in the description if you want to read more about it and maybe read from the people that actually have developed this thing and understand it a lot better than I do. Anyways, let's take a quick look at this LinkedIn post from Shubham. So as we can see, Deepseek just delivered what we want to call the impossible. It's a model that matches OpenAI's O-1 at just 1/27th of the cost. So we'll break up the cost in a sec, but basically over here on the right, we're seeing $60, which is a million tokens for OpenAI O-1 output, and then $2.19 per million tokens for Deepseek R-1 output, which is 96.4% cheaper and Deepseek is 100% open source. So when we're looking at the numbers that matter, like I said, here are the cost per million output tokens: $0.60 compared to $2.19. Performance comparisons, as you can see, R1 versus O1, they're very, very comparable, and R1 is better in this metric and this metric, both in the top 3.17% of Codeforces. Anyways, here's the wild part: OpenAI and Anthropic rely on traditional training methods, but Deepseek took a completely different path. So they used pure reinforcement learning, so no human supervision, just exploration and learning like a child figuring out puzzles, iterating over time. And then what they're calling the aha moment, which is during training, R1 starts to develop its own problem-solving strategies. So it literally teaches itself and starts to completely understand how to do things based on what it's already done and just gets smarter and smarter. So the evolution here started as a base model, learned through trial and error, developed its own problem-solving strategies, and eventually matched OpenAI's leading models. The real question here is, if you're using OpenAI-01, why would you be paying 27 times more for the same performance? So what exactly are you paying for? And let's look at that end-to-end, because if you've gotten there and you've, you know, kind of tried to connect OpenRouter to DeepSeek R1 or even DeepSeek V3, you may have noticed some things about the way it's calling tools or the way that it's calling your vector database that maybe you weren't too happy with. So let's talk about the right way to be using DeepSeq R1 in NNEDIN. Here's another quick comparison. This can also be found in that research report that I'll link down below. But as you can see, we've got R1, R1, another version of R1 that has different parameters, R1 mini, and then DeepSeq V3. So as you can see in the— on the far left of all these charts, the dark blue with the stripes, DeepSeq R1 is pretty much in the lead on everything. And you can even see DeepSeq V3 was super, super powerful. And how much R1 crushes V3. Here's another quick breakdown of the costs. We've got OpenAI input and output tokens, $15 or $60 per million tokens, and then Deepseek input and output, $0.55 or $2.19 per million tokens. So what that means is you can either use a million OpenAI input tokens or you could use 27.3 million Deepseek R1 tokens. So, you know, do the math there. But I'm sure at this point you guys have all seen different LinkedIn posts, different YouTube videos about Deepseek R1. So the question is, how do you actually use it in N8N the right way? Because if you watch my Deepseek V3 video, what we did is we connected this OpenAI chat model and a lot of you guys said, you know, you can't find base URL. Base URL is no longer an option here. You have to get that by going into your credential and then you get your API key and then here's where you set up the base URL. So, um, if you were confused about base URL, that's where it is now. But let's quickly talk about how to set this up and, um, how you configure this credential. So I'm going to be walking through setting up a new credential with you guys. So let's click into here, create new credential, and let's go grab our base URL as well as our API key. So head over to OpenRouter.ai. Okay, now that we're in OpenRouter, we're going to go to our profile, click on keys. We're going to create a new one, and then you can name it whatever you want. Once you hit create, you will get this API key that you will be able to copy and then paste this back into N8N. Once that's pasted into N8N, you're going to go up to the top left, search for models. As you can see, DeepSeq R1 is already right there. Very popular. And then you're going to go to API down here. What we have is the base URL is what we're looking for. So we're going to copy this base URL and then paste that into the base URL in NNN. So right here, this is currently pointing to openai.com, and that's why we'd be able to choose from a list of models, which would be GPT-4, 4 mini, all that kind of stuff. So we're going to change this base URL and now we're going to be pointing towards OpenRouter. And then once we save this credential real quick, we can see that now we have the option to put in a different model. So when this is pointing to OpenAI, you have a dropdown list of all of the different OpenAI models. But what we're going to do is change this to expression, and then we need to go find the actual Deepseek model or any sort of OpenRouter model that we want to use and then paste that in here. So back over to OpenRouter, if we just scroll up to the top of the Deepseek R1, right here is what we're looking for. All we have to do is hit copy to clipboard, and then we're going to paste that into the model section. In n8n. We paste that right in here. You're going to get this red error symbol that says the value Deepseek is not supported, but don't worry about that. You're going to hit save, and now you're pretty much hooked up to Deepseek through OpenRouter. But what I've noticed is that through testing, even with Deepseek v3 and now with Deepseek R1, if we want to use this, it sometimes has errors with its tool calling with its time, with its endless loops. So I was testing this with some RAG and it was hitting the Pinecone vector store over and over and over, like 12 times in a row, and it just wouldn't stop sending queries. So that was an issue. I've also been experiencing this issue where I just want to say hello just to make sure that I'm actually connected. And we know that we are connected because we're not getting an error right away that's saying credentials are invalid or we're not hooked up to a chat model. So we know it's working, but going through OpenRouter, I've seen stuff on community forums as well that people are just having this issue where it's taking minutes and minutes to come back. So obviously this is not ideal, and you know, if you want to test this out with different functions in N8n, you can't be waiting 15 minutes for each run. So let me show you the way that right now I would start to implement DeepSeq-R1 into my workflows. Real quick, just wanted to say if you want to download this workflow, you can do so for free by joining my FreeSchool community. That way you can just download it right away, get this into your into your environment, and then you can just put in your API key and then you're good to go right away. Like I said, once you join the free school community, click on YouTube resources, click on the post associated with this video, and then you'll be able to download the workflow right here. And if you're looking to take your skills with N8N and automation a little bit farther, check out my paid community. The link for that will also be down in the description. Got a great community of members who are also learning N8N and sharing their resources as well as obstacles that they're running, running into. Got a great classroom section with deep dive topics as well as a calendar with 5 live calls per week. Get questions answered, make sure you're not getting stuck. So I'd love to meet you guys in these calls. Anyways, let's get back to the video. What we're going to be doing is accessing Deepseek R1 through an HTTP request where in here we're able to access the model and we're able to give it sort of a system prompt as well as an actual user prompt. So in here it's just, you are helpful assistant. And then I'm using the previous tool to set a query, which in here is, you're in a room with 3 light switches. Each switch controls one of three light bulbs in a separate room, but you can't see the light bulbs from where you are. You can only enter the room with the light bulbs once. How can you figure out which switch controls which bulb? So we're gonna send this riddle off to Deepseek R1. Right now it's thinking about the riddle. It's going to assess its options, and then it's going to tell us the result as well as all of the reasoning steps that it took in its brain to get to the answer. So should be pretty cool to see what it comes up with. So just finished up running. If we click into this HTTP request, we can see what we got back was content as well as reasoning content. And so if we click into this next node, just so we can read it a little better, we get the answer as well as the steps that it took to get to this answer. So first of all, it said, to determine which switch controls each bulb with only one entry, here's what you should do. Turn on switch A and leave it on for 2 to 3 minutes. This allows that bulb, if it's controlled by switch A, to heat up. Turn off the first switch, then immediately turn on switch B. Enter the room and observe the bulbs. If the bulb that's on is controlled by switch B, the bulb that's off but warm is controlled by switch A, and then the bulb that's off but cold is controlled by switch C. So this method uses both light status as well as heat to understand which bulb corresponds to the switch and only entering the room once. So I'm not going to read all this reasoning, but as you can see, it's, it's a pretty robust amount of reasoning that this model did in order to think through what it— what, um, the answer to this riddle is. And so yeah, this is a fun use case of riddles, but let's say that we're actually doing a a multi-step process like resolving inquiries, sending emails, doing some sort of analysis on data, and then taking action, this is going to be super, super cool because you're going to understand exactly why the model did what it did. And that will also help you reprompt stuff later. And it's gonna just provide full transparency as to what is happening and why. As you can see, it started off by saying it's a classic puzzle. The challenge is figuring out which switch controls which bulb. So first thing is that they know the main constraint is that you can only enter the room once. So you need to be a little creative about how you figure out which switch controls which bulb. They talk about being able to use heat because the model understands that if a bulb is on for a long time, it's gonna warm up more than a bulb that was just flicked on right away. It even goes right here and says, but wait, this relies on the bulbs being incandescent and producing heat. If they're LED or CFL, they might not get as hot. Hmm. But the problem doesn't exactly specify the type of bulbs. Maybe we can assume they're traditional bulbs that generate heat anyways, and it breaks down more approaches. It tells you exactly the way it got to its answer. Therefore, the solution is to manipulate the switches in a way that allows you to use both light and heat as indicators. But as far as setting this up, it's going to be super, super simple. You're going to go to deepseek.com. You want to click up in the top right, click on API platform, and then all you have to do is first of all, you want to top up with some credits. I put in $2 a while ago, and as you can see, I've hardly tapped into that at all. And then what you need to do is grab your API key. And so we'll walk through an example real quick. So I'm going to create a new key. We'll call this one test 2. We'll grab this API key and copy that down for later. And then on the left-hand side, you're going to go to docs. Once you get here, this page is going to pull up that says your first API, your first API call. It's going to walk through a base URL. It's going to walk through the different headers and parameters that we need to put in. But all you really have to do is right here, you have to grab is curl and click copy. Back in n8n, we're going to grab an HTTP request, and then all we have to do is click on import curl, paste that curl in there, hit import, and now it fills out the HTTP request for us. So as you can see, it turned it into a POST method, it grabbed our right endpoint for us, it said that we need to obviously put in our API key. So right here it's going to be bearer space your API key. So let me put that in real quick. Okay, so there's my API key. Just make sure you have a space between bearer and the start of the token, as well as at the end. Make sure you have no leading or sorry, trailing whitespace. And then down here we have our actual JSON body parameters that we're sending over to the model. So let's look into here and see what we got. We have a system prompt, which is, you are a helpful assistant. And then we have the user prompt, which is just saying hello. And right now, keep in mind, the model is Deepseek Chat. And if we go back to the documentation, we can see that the deepseek-chat model has been upgraded to Deepseek v3. The API remains unchanged. However, if you want to use the latest reasoning model, Deepseek R1, You need to do Deepseek Reasoner in the model. So we're going to copy Deepseek Reasoner back in NNN. We're going to get rid of Deepseek Chat as the model parameter and change that to Deepseek Reasoner. And now that's pretty much it. We can hit test step. It's going to be sending over the message hello. So Deepseek is going to come back by saying something like hi. So as you can see, it said the user greeted me with hello, so I should respond in a friendly way and welcoming manner. Let me make sure my response is approachable and offers help. Maybe something like hello, how can I assist you today? It's straightforward, opens the conversation. I don't want to overcomplicate it, keeping it professional and still warm, and ended up saying, "Hello, how can I assist you today?" So obviously what I did in the previous example is I made the content an expression based on what we dragged in from the previous field. So you would obviously need to reference different variables and you could even change up the system prompt if you wanted to help have this agent do something very specific for you. But let's say we said something like, "Tell me a joke," and we sent this off to DeepSeek. It's going to reason about, you know, like the user asked me for a joke. It may talk about different senses of humor or whatever. But so the joke we got is, here's a lighthearted one for you. Why did the scarecrow win an award? Because he was outstanding in the field. Okay. User asked for a joke. Let me think of a good one. I want it to be lighthearted and not offensive. Maybe something with a pun. People usually like those. Hmm. How about a classic setup with a punchy, with a punny punchline? Why did the Scarecrow win an award? Okay. And as you can see, it even went way more down. It gave some other jokes and it explained them. But ultimately at the end it said that the Scarecrow one was safe and family friendly. So we'll present clarity around it. All right. It's super cool stuff. So that's going to be the way to set up Deepseek R1 as an HTTP request in here that you still have a lot of customization as far as the system prompts and the role prompt going in. Of course, this will be super cool in the future, though, being able to give your agents the brain to do all the different tool calling within you know, by using Deepseek R1. It'll be cool once Enadn creates a native node for Deepseek rather than having to go through OpenRouter, because that's where I think the issues are coming from right now. Let's say if we tried to do this again and say, tell me a joke, this one will probably not come through. But as we saw when we did it down below with this HTTP request, how quickly those, those results came back. So I, I just figured some of you guys may be running into this issue, so I wanted to show another way that you can connect to Deepseek R1 and end it, end pretty easily. So if you guys enjoyed this one, please leave a like, definitely helps me out. Um, but besides that, appreciate you guys making it to the end of this one, and I will see you in the next video.










