# Twinny

> Free VS Code code completion and chat that can run entirely against a local model

- Category: AI Coding / IDE Copilots
- Language: TypeScript
- Licence: MIT
- Repository: https://github.com/twinnydotdev/twinny
- Website: https://twinnydotdev.github.io/twinny-docs/
- Canonical page: https://ai-tldr.dev/tools/twinny/

## In short

Twinny is a free AI extension for Visual Studio Code that adds two things most developers want from a copilot: fill-in-the-middle code completion as you type, and a sidebar chat you can ask about the code in front of you. It sits in the IDE Copilots category of the AI Coding tools and is open-source, written in TypeScript and licensed MIT.

## Overview

Twinny is a free AI extension for Visual Studio Code that adds two things most developers want from a copilot: fill-in-the-middle code completion as you type, and a sidebar chat you can ask about the code in front of you. Its default provider is a localhost OpenAI/Ollama-compatible API, so the extension works with no account and no key against a model running on your own machine.

If you would rather use a hosted model, the same settings accept OpenAI, Anthropic, OpenRouter, Deepseek, Cohere, Mistral AI, Perplexity and Groq. Because the endpoint, model, port and path are all configurable, Twinny can also point at any other service that speaks the OpenAI API standard — the extension treats a provider as a URL plus a prompt template rather than a hard-coded integration.

Beyond completion and chat it covers the smaller jobs an IDE assistant is expected to do: generating a git commit message, explaining or refactoring a selection, writing tests, creating a new document from a code block, showing a side-by-side diff of a suggestion, and keeping conversations between sessions. Workspace embeddings give the chat context from the rest of the repository rather than just the open file.

## What it does

- Single and multiline fill-in-the-middle code completion, online or fully offline
- Sidebar chat about your code: explanations, tests, refactors, with preserved conversations
- Default localhost Ollama/OpenAI-compatible provider, plus OpenAI, Anthropic, OpenRouter, Deepseek, Cohere, Mistral AI, Perplexity and Groq
- Configurable API endpoint, model, port, path and prompt templates — anything OpenAI-API-compatible works
- Workspace embeddings so chat answers draw on the wider repository, not only the open file
- Side-by-side diff view, direct acceptance of a code solution, and git commit message generation
- Optional team gateway (`npx twinny-server quickstart`) that serves one model host to a whole team, free for five

## Getting started

Twinny installs from the VS Code marketplace and expects an OpenAI-compatible endpoint. The default configuration points at localhost, so the quickest path is to run a model locally first.

1. Install the extension

   Search for Twinny in the VS Code Extensions view, or install it from the marketplace by id.

```bash
code --install-extension rjmacarthy.twinny
```

2. Point it at a model

   Out of the box Twinny talks to a localhost OpenAI/Ollama-compatible API. If you would rather use a hosted provider, open the Twinny settings and set the API provider, model, port and path — the extension follows the OpenAI API standard, so any compatible service works.

3. Complete and chat

   Start typing to get fill-in-the-middle suggestions inline, and open the Twinny sidebar to chat about the file or selection — asking for an explanation, tests or a refactor. Accepted solutions can be applied directly or reviewed in a side-by-side diff.

4. Optional: serve a team from one machine

   If one machine in the team has the GPU, the Twinny gateway serves its models to everyone else's VS Code. The quickstart finds your model server, creates an admin key and starts serving; from the admin page you set default models and invite developers with a link. Free for teams of five.

```bash
npx twinny-server quickstart
```

## When to use it

- Get Copilot-style inline completion on a machine that is offline, or on a codebase that may not leave it
- Run code completion and chat against a local Ollama model with no subscription and no API key
- Try several providers behind one extension — swap between a local model, Groq and Anthropic by changing settings rather than tools
- Share one GPU machine's models across a small team's editors through the Twinny gateway
