How to Use DeepSeek AI API for Free (2025 Tutorial)

You know, let’s stop wasting money buying API credits, as from July 2025, you can use the DeepSeek AI API for free by accessing it via OpenRouter, which lets you build smart AI apps or chatbots without paying anything. Let me show you how.

Free

Introduction

See, most API providers charge per token, per minute, per sigh, which is pretty high, and if you are building an application executing test functions hundreds times, man, I feel your pain. So here is an alternative. Let’s use DeepSeek + OpenRouter, to get the work done for free.

Especially if you are a student, a developer, or someone who wants an AI assistant without going broke, here is how you do it and yes, step-by-step, with working code and no complex setup.

How to Get DeepSeek API for Free

You do not need to set up a server, buy credits, or feed your wallet into a woodchipper. Just use OpenRouter to access DeepSeek models.

Go to openrouter.ai:

OpenRouter Website

Sign in with GitHub or Google:

Sign in page

In the search bar, look for DeepSeek: R1 0528(free) model:

Search bar

Then click on this API option:

API option

Click Create API key:

Create API key option

Enter a name to remember:

Create a key

Copy and save your key somewhere safe.

That key is your passport to using DeepSeek and other AI models through a universal API endpoint. No credit card. No limits (as long as your usage is reasonable).

Simple AI Chatbot Using HTML, CSS, and JavaScript

Here is a code for a very minimal chatbot that connects directly to the DeepSeek model through OpenRouter. It is a front-end only project, so you do not need Node, Python, or any server.

Features

  • No setup headaches: Paste your key and chat
  • Beginner-friendly: Runs in a browser, no framework or libraries
  • Fast testing: Great for students or hobbyists exploring AI
  • Customizable: Add styles or features if you want more power
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>DeepSeek Chatbot</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background: #f2f2f2;
      margin: 0;
      padding: 0;
    }
    .chat-container {
      max-width: 600px;
      margin: 40px auto;
      background: white;
      border-radius: 12px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.1);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .messages {
      padding: 20px;
      height: 400px;
      overflow-y: auto;
    }
    .message {
      margin-bottom: 16px;
    }
    .user {
      text-align: right;
      color: #007bff;
    }
    .bot {
      text-align: left;
      color: #333;
    }
    .input-container {
      display: flex;
      border-top: 1px solid #ddd;
    }
    input {
      flex: 1;
      padding: 12px;
      border: none;
      outline: none;
    }
    button {
      padding: 12px 20px;
      background: #007bff;
      color: white;
      border: none;
      cursor: pointer;
    }
    button:disabled {
      background: #cccccc;
      cursor: not-allowed;
    }
    button:hover {
      background: #0056b3;
    }
    .api-key-input {
      width: 100%;
      padding: 12px;
      border: none;
      outline: none;
      border-bottom: 1px solid #ccc;
    }
  </style>
</head>
<body>

  <div class="chat-container">
    <input id="apiKey" class="api-key-input" placeholder="Paste your OpenRouter API key here..." />

    <div class="messages" id="chat"></div>

    <div class="input-container">
      <input type="text" id="userInput" placeholder="Type your message..." />
      <button id="sendButton" onclick="sendMessage()">Send</button>
    </div>
  </div>

  <script>
    const chat = document.getElementById("chat");
    const sendButton = document.getElementById("sendButton");
    const userInput = document.getElementById("userInput");

    function appendMessage(text, sender) {
      const msg = document.createElement("div");
      msg.className = `message ${sender}`;
      msg.textContent = text;
      chat.appendChild(msg);
      chat.scrollTop = chat.scrollHeight;
      return msg;
    }

    async function sendMessage() {
      const apiKey = document.getElementById("apiKey").value.trim();
      const message = userInput.value.trim();

      // No API key, no message? Abort!
      if (!apiKey) {
        alert("Please enter your OpenRouter API key");
        return;
      }
      if (!message) return;

      // Show user's message
      appendMessage(message, "user");
      userInput.value = "";

      // Disable button to prevent double-submit
      sendButton.disabled = true;

      // Show "Thinking..." and save its reference to update later
      const thinkingMsg = appendMessage("Thinking...", "bot");

      try {
        const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
          method: "POST",
          headers: {
            "Authorization": `Bearer ${apiKey}`,
            "HTTP-Referer": window.location.href, // Optional, for OpenRouter rankings
            "X-Title": "DeepSeek Chatbot",        // Optional, for OpenRouter rankings
            "Content-Type": "application/json"
          },
          body: JSON.stringify({
            model: "deepseek/deepseek-r1-0528:free", // Use the correct model ID per docs
            messages: [{ role: "user", content: message }]
          })
        });

        if (!response.ok) {
          throw new Error(`API error: ${response.status}`);
        }

        const data = await response.json();
        const reply = data.choices?.[0]?.message?.content || "No reply received.";
        thinkingMsg.textContent = reply;
      } catch (err) {
        console.error(err);
        thinkingMsg.textContent = "Error getting a response. Check the browser console.";
      } finally {
        sendButton.disabled = false;
        userInput.focus(); // Return focus to input
      }
    }

    // Handle Enter key for sending
    userInput.addEventListener("keyup", (e) => {
      if (e.key === "Enter") sendMessage();
    });

  </script>
</body>
</html>

Want to try it now:

DeepSeek Chatbot

You can use it as a personal chatbot, an assistant in a dashboard, or even embed it in your website.

This is the easiest way to get started with DeepSeek, especially if you are not comfortable setting up a full-stack application. It is also the quickest way to test prompt ideas or build tiny projects without burning a single rupee.

Other Cool Things You Can Build with DeepSeek API Key

Once you get the hang of it, DeepSeek becomes your personal AI intern (except it shows up to work). Here are more ideas:

  • Bug Whisperer: Paste in a code error and get debugging suggestions
  • Markdown Editor AI: Summarise notes or generate bullet points from long paragraphs
  • LinkedIn Message Crafter: Draft polite rejection or connection messages without sounding robotic

And if you are feeling bold, wrap your tool in a simple web interface and show it off on GitHub or a portfolio. Just remember to remove the “still learning” disclaimer.

Bye Bye Message

You now have access to a zero-cost, high-performing AI API that rivals paid tools. So if you are a student building projects, a dev prototyping an app, or just curious about AI, DeepSeek through OpenRouter gives you a solid playground.

No billing traps. No excuses. Go build something smart. Or weird. Or both.

And if you build a chatbot that roasts your code while fixing it—please, I need that in my life.

Bye Bye
Review Your Cart
0
Add Coupon Code
Subtotal