Skip to content

KasarLabs/cairo-coder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

143 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cairo Coder MCP Logo

npm version npm downloads GitHub stars License: MIT

Cairo Coder

Important

Sunset notice — the hosted Cairo Coder service will shut down on July 31, 2026.

The public API at api.cairo-coder.com and the cairo-coder.com website will be permanently discontinued at the end of July 2026. Please migrate any integrations that rely on the hosted API before this date.

Cairo Coder remains fully open source. You can keep using it by self-hosting this repository — see the Quick Start below. Thank you to everyone who used and supported the hosted service.

The most powerful open-source CairoLang generator.

Hosted Service (deprecated)

The hosted service operated by Kasar Labs is being sunset and will shut down on July 31, 2026. New API keys are no longer recommended for production use. To continue using Cairo Coder after this date, self-host it using the instructions below.

Overview

Cairo Coder is an intelligent code generation service that makes writing Cairo smart contracts and programs faster and easier. It uses an advanced, optimizable Retrieval-Augmented Generation (RAG) pipeline built with DSPy to understand Cairo's syntax, patterns, and best practices.

Features

  • Cairo Code Generation: Transforms natural language requests into functional Cairo code
  • DSPy RAG Architecture: Structured and optimizable RAG pipeline for accurate code generation
  • OpenAI Compatible API: Drop-in replacement for OpenAI API format
  • Multi-LLM Support: Works with OpenAI, Anthropic, Google Gemini, and other providers
  • Source-Informed Generation: Code generated from up-to-date Cairo documentation
  • MCP Support: Integration with agentic tools via cairo-coder-mcp

Quick Start

Using Docker (Recommended)

# Clone and configure
git clone https://github.com/KasarLabs/cairo-coder.git
cd cairo-coder
cp .env.example .env
# Edit .env with your API keys

# First time: populate vector database
docker compose up postgres ingester --build

# Run the service
docker compose up postgres backend --build

The API is available at http://localhost:3001/v1/chat/completions.

API Usage

curl -X POST http://localhost:3001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "cairo-coder",
    "messages": [
      {"role": "user", "content": "How do I implement a counter contract in Cairo?"}
    ]
  }'

Documentation

Document Description
API Reference HTTP endpoints, request/response formats, streaming
Architecture System design, RAG pipeline, project structure
CLAUDE.md Agent instructions for development

Development

Prerequisites

  • Python 3.10+ with uv
  • Bun for the ingester
  • Docker for PostgreSQL

Local Setup

# Start database
docker compose up postgres

# Setup Python backend
cd python
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync

# Run ingester (first time)
cd ../ingesters
bun install
bun run generate-embeddings:yes

# Start server
cd ../python
uv run cairo-coder --dev

Running Tests

# Python tests
cd python
uv run pytest

# Ingester tests
cd ingesters
bun test

Project Structure

cairo-coder/
├── python/           # Python backend (FastAPI + DSPy RAG)
├── ingesters/        # TypeScript documentation ingester
├── docs/             # Documentation
└── docker-compose.yml

Credits

This project is based on Starknet Agent, an open-source AI search engine for the Starknet ecosystem.

Contributing

We welcome contributions! Whether you're fixing bugs, improving documentation, or adding new features, your help is appreciated.

License

MIT License - see LICENSE for details.

About

Vibe. Prove. Verify.

Resources

License

Stars

40 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors