DEV Community

Alex Spinov
Alex Spinov

Posted on

Jan.ai Has a Free API: Open-Source ChatGPT Alternative Running 100% Offline

Jan is an open-source ChatGPT alternative that runs 100% offline on your computer. It provides an OpenAI-compatible API, a beautiful chat interface, and supports dozens of open-source models.

What Is Jan?

Jan is a desktop application that turns your computer into an AI server. It downloads and runs LLMs locally with full privacy — no data ever leaves your machine. It is fully open-source (AGPLv3) and works on Windows, Mac, and Linux.

Key Features:

  • 100% offline, no cloud dependency
  • OpenAI-compatible API server
  • Beautiful chat UI with threads
  • Supports GGUF models from Hugging Face
  • GPU acceleration (CUDA, Metal, Vulkan)
  • Extension system for plugins
  • Local RAG with file uploads

Quick Start

  1. Download Jan from jan.ai
  2. Open the app and go to Model Hub
  3. Download a model (e.g., Llama 3.2, Mistral, Phi-3)
  4. Start chatting or enable the API server

Jan API: OpenAI-Compatible Local Server

Jan runs a local API server on port 1337 that is fully compatible with the OpenAI API:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:1337/v1",
    api_key="jan"  # Any string works
)

# Chat completion
response = client.chat.completions.create(
    model="llama3.2-3b-instruct",
    messages=[
        {"role": "system", "content": "You are a senior developer."},
        {"role": "user", "content": "How do I set up a CI/CD pipeline with GitHub Actions?"}
    ],
    temperature=0.7,
    max_tokens=1000
)
print(response.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Streaming Chat

stream = client.chat.completions.create(
    model="llama3.2-3b-instruct",
    messages=[{"role": "user", "content": "Explain microservices architecture"}],
    stream=True
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="", flush=True)
Enter fullscreen mode Exit fullscreen mode

Using with JavaScript/TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:1337/v1",
  apiKey: "jan"
});

async function chat(prompt: string) {
  const response = await client.chat.completions.create({
    model: "llama3.2-3b-instruct",
    messages: [{ role: "user", content: prompt }]
  });
  return response.choices[0].message.content;
}

const answer = await chat("What is WebAssembly?");
console.log(answer);
Enter fullscreen mode Exit fullscreen mode

REST API Direct

# Chat completion
curl http://localhost:1337/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d x27{"model": "llama3.2-3b-instruct", "messages": [{"role": "user", "content": "Hello!"}]}x27

# List models
curl http://localhost:1337/v1/models

# Download a model
curl -X POST http://localhost:1337/v1/models/download \
  -H "Content-Type: application/json" \
  -d x27{"model": "mistral-7b-instruct"}x27
Enter fullscreen mode Exit fullscreen mode

Jan vs LM Studio vs Ollama

Feature Jan LM Studio Ollama
Open source Yes (AGPL) No Yes (MIT)
GUI Chat-focused Model explorer CLI
API port 1337 1234 11434
Extensions Plugin system No No
Local RAG Built-in No No
Model format GGUF GGUF GGUF

Resources


Need to scrape web data for your AI projects? Check out my web scraping tools on Apify — production-ready actors for Reddit, Google Maps, and more. Questions? Email me at spinov001@gmail.com

Top comments (0)