DEV Community

Alex Spinov
Alex Spinov

Posted on

Tabby Has a Free API — Self-Hosted AI Code Completion Like GitHub Copilot

Tabby is a self-hosted AI code completion server — an open-source alternative to GitHub Copilot. Run it on your own hardware, keep your code private, and get intelligent autocomplete in your IDE.

Free, open source, with a REST API and IDE extensions for VS Code, IntelliJ, and Vim.

Why Use Tabby?

  • Self-hosted — your code never leaves your network
  • Free forever — no subscription, no per-seat pricing
  • IDE support — VS Code, IntelliJ, Neovim, Emacs
  • Code completion — inline suggestions like Copilot
  • Chat — ask questions about your codebase
  • RAG — indexes your repo for context-aware completions

Quick Setup

1. Install

# Docker (recommended)
docker run -it --gpus all -p 8080:8080 \
  -v $HOME/.tabby:/data \
  tabbyml/tabby serve --model StarCoder-1B --device cuda

# CPU only
docker run -it -p 8080:8080 \
  -v $HOME/.tabby:/data \
  tabbyml/tabby serve --model StarCoder-1B --device cpu

# Or install directly
curl -fsSL https://raw.githubusercontent.com/TabbyML/tabby/main/install.sh | bash
tabby serve --model StarCoder-1B
Enter fullscreen mode Exit fullscreen mode

2. Code Completion API

curl -s http://localhost:8080/v1/completions \
  -H "Content-Type: application/json" \
  -d '{
    "language": "python",
    "segments": {
      "prefix": "import requests\n\ndef scrape_website(url):\n    ",
      "suffix": "\n    return data"
    }
  }' | jq '.choices[0].text'
Enter fullscreen mode Exit fullscreen mode

3. Chat API

curl -s http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "How do I handle pagination in web scraping with Python?"}
    ]
  }' | jq '.choices[0].message.content'
Enter fullscreen mode Exit fullscreen mode

4. Health & Model Info

# Health check
curl -s http://localhost:8080/v1/health | jq

# Model info
curl -s http://localhost:8080/v1/models | jq '.data[].id'
Enter fullscreen mode Exit fullscreen mode

5. Connect Your Repository

# Add a Git repository for context-aware completions
curl -s -X POST http://localhost:8080/v1beta/repositories \
  -H "Content-Type: application/json" \
  -d '{"git_url": "https://github.com/my-org/my-project"}'

# Tabby will index the repo and use it for better completions
Enter fullscreen mode Exit fullscreen mode

Python Client

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8080/v1", api_key="not-needed")

# Chat about code
response = client.chat.completions.create(
    model="StarCoder-1B",
    messages=[
        {"role": "system", "content": "You are a coding assistant."},
        {"role": "user", "content": "Write a Python function to extract all links from a webpage"}
    ]
)
print(response.choices[0].message.content)

# Inline completion
import requests
completion = requests.post("http://localhost:8080/v1/completions", json={
    "language": "python",
    "segments": {
        "prefix": "def parse_html(html_content):\n    from bs4 import BeautifulSoup\n    soup = BeautifulSoup(html_content, 'html.parser')\n    ",
        "suffix": ""
    }
}).json()
print(completion["choices"][0]["text"])
Enter fullscreen mode Exit fullscreen mode

Supported Models

Model Size Best For
StarCoder-1B 1B Fast completions, low resources
StarCoder-3B 3B Better quality, moderate resources
StarCoder-7B 7B High quality, needs GPU
CodeLlama-7B 7B Strong code generation
DeepSeek-Coder-6.7B 6.7B Excellent for all languages

Key Endpoints

Endpoint Description
/v1/completions Code completion
/v1/chat/completions Chat (OpenAI-compatible)
/v1/models List models
/v1/health Health check
/v1beta/repositories Manage indexed repos

IDE Setup

  • VS Code: Install 'Tabby' extension → Settings → set server URL to http://localhost:8080
  • IntelliJ/JetBrains: Install 'Tabby' plugin → Settings → Tabby → Server URL
  • Neovim: Use tabby.nvim plugin

Need custom data extraction or scraping solution? I build production-grade scrapers for any website. Email: Spinov001@gmail.com | My Apify Actors

Top comments (0)