Skip to content
DSPy Code Logo
DSPy Code Banner
DSPy Code

Welcome to DSPy Code

Develop DSPy Applications â€ĸ Optimize with GEPA

The Complete Platform for Building and Optimizing DSPy Applications

đŸ—ī¸ Develop
đŸ§Ŧ Optimize
🚀 Deploy
📚 Learn
Learn Build Optimize Connect

💡 Note: DSPy Code is in its initial release and under active development. The quality and effectiveness of generated code depends on several factors: the language model you connect, MCP (Model Context Protocol) servers you integrate, and the context you provide to DSPy Code. We're continuously improving based on community feedback.


đŸŽ¯ What is DSPy Code?

đŸ—ī¸ Develop DSPy Applications

Build, learn, and create DSPy programs with natural language. Generate signatures, modules, and complete applications with AI-powered assistance.

  • Natural language to code
  • Codebase understanding
  • Validation & best practices
  • 20+ templates

đŸ§Ŧ Optimize with GEPA

Transform your DSPy code into production-ready applications using GEPA (Genetic Pareto). Automatically improve accuracy and achieve better performance.

  • Real GEPA execution
  • Automated metrics
  • Prompt evolution
  • Production-ready code

The Complete Workflow

Develop → Validate → Optimize with GEPA → Deploy

From idea to production-ready DSPy application in one platform


💡 Who is This For?

  • Complete Beginners

    Never used DSPy before? Perfect! Start here and learn by doing. The CLI teaches you DSPy concepts as you build real programs.

    No prerequisites needed.

  • DSPy Developers

    Already know DSPy? Supercharge your workflow with AI-powered code generation, validation, and optimization.

    Build faster, optimize smarter.

  • Production Teams

    Building production DSPy applications? Get validated, optimized, production-ready code with GEPA optimization and best practices built-in.

    Ship with confidence.


🔄 Complete Development + Optimization Workflow

  • Phase 1: Development

    Build your DSPy application from scratch or enhance existing code.

    Steps: 1. /init - Initialize project 2. Natural language commands to generate code 3. /validate - Ensure best practices 4. Test and iterate

    Start Developing →

  • Phase 2: Optimization

    Optimize your working code with GEPA for production.

    Steps: 1. /data - Generate training examples 2. /optimize - Run GEPA optimization 3. /eval - Evaluate improvements 4. /export - Package for deployment

    Start Optimizing →

đŸŽ¯ The Result

Production-ready DSPy applications with optimized performance, evolved prompts, and documented improvements


🚀 Use Cases: When to Use DSPy Code

1. đŸ—ī¸ Starting a New DSPy Project

Perfect for:

  • Building a new AI application from scratch
  • Prototyping ideas quickly
  • Learning DSPy fundamentals

What you get:

dspy-code
/init --fresh

✅ Complete project structure
✅ Configuration files
✅ Example programs
✅ Best practices setup
✅ Ready to code in 2 minutes

Example: "I want to build a customer support chatbot with sentiment analysis and automated responses."

Start Your First Project →


2. đŸ§Ŧ Optimizing DSPy Programs with GEPA

Perfect for: - Improving accuracy of existing programs - Automatic prompt engineering - Production optimization

What you get:

# Generate training data
→ Generate 100 examples for sentiment analysis

# Optimize automatically
/optimize my_program.py training_data.jsonl

✅ Real GEPA execution (not just code generation)
✅ Automated metric functions
✅ Progress tracking & resumption
✅ Production-ready optimized code
✅ Performance improvements documented

Real results: 75% → 92% accuracy automatically!

Example: "My sentiment analyzer is 75% accurate. Optimize it with GEPA to reach 90%+"

Learn GEPA Optimization →


3. Adding DSPy to Existing Projects

Perfect for:

  • Enhancing existing Python applications
  • Adding AI capabilities to current systems
  • Modernizing legacy code

What you get:

cd my-existing-project
dspy-code
/init

✅ Minimal setup (no disruption)
✅ Scans your existing code
✅ Understands your project structure
✅ Generates code that fits your style
✅ Works alongside your current code

Example: "I have a Django app. I want to add AI-powered document summarization."

Add to Existing Project →


4. Learning DSPy (No Docs Required!)

Perfect for:

  • First time using DSPy
  • Understanding DSPy concepts
  • Exploring different patterns

How it works:

Just ask questions in natural language:

→ What is a DSPy Signature?
→ How does ChainOfThought work?
→ Show me an example of ReAct
→ When should I use GEPA optimization?

The CLI answers using YOUR installed DSPy version and provides working code examples!

No reading required. Learn by building.

Start Learning →


5. Connecting to MCP Servers for Powerful DSPy Programs

DSPy Code is an MCP Client!

Connect to any MCP (Model Context Protocol) server to supercharge your DSPy programs with external tools, APIs, and data sources.

What you can do:

# Add MCP server
/mcp-add web-tools --transport stdio --command "python server.py"

# Connect to server
/mcp-connect web-tools

# Use tools in your DSPy programs
→ Create a DSPy module that searches the web and summarizes results

✅ Access external tools - Web search, databases, APIs
✅ Read from data sources - Files, documents, databases
✅ Execute commands - System operations, scripts
✅ Integrate services - Third-party APIs and tools
✅ Build powerful workflows - Combine DSPy with external capabilities

Example: "Build a RAG system that uses MCP to query my company's database and generate answers."

Learn MCP Integration →


6. Building Production AI Applications

Perfect for:

  • Enterprise applications
  • Production deployments
  • Mission-critical systems

What you get:

✅ Validated, production-ready code
✅ Best practices built-in
✅ Error handling and logging
✅ Type hints and documentation
✅ Optimized performance
✅ Export as packages

Quality score: 90+ out of 100 automatically!

Production Best Practices →


✨ Key Features

  • Natural Language Interface

    Describe what you want in plain English. The CLI generates complete, working DSPy code.

    "Build a RAG system for document Q&A"
    

    Done! Complete code generated.

  • Built-in MCP Client

    Connect to any MCP server to access external tools, APIs, databases, and services in your DSPy programs.

    Build powerful, connected AI applications.

  • Version-Aware Intelligence

    Adapts to YOUR installed DSPy version. Answers questions using your actual code, not outdated docs.

    Always current. Always accurate.

  • Real GEPA Optimization

    Not mocked. Real GEPA (Genetic Pareto) optimization that improves your programs by 10-30% automatically.

    Production-grade results.

  • Smart Validation

    Every generated code is validated for quality, best practices, and correctness. Score: 90+/100.

    Ship with confidence.

  • Codebase Knowledge

    Indexes your DSPy installation and project. Ask questions about your own code!

    "Explain my RAG module" - Done!

  • Universal Model Support

    Connect to any LLM: Ollama (local), OpenAI, Anthropic, Gemini. Switch anytime.

    Your choice, your control.

  • Learn as You Build

    No docs, books, or tutorials needed. Ask questions, get answers from your code, build in real-time.

    Interactive learning experience.


đŸŽŦ See It In Action

Quick Example

# Start DSPy Code
dspy-code

# Initialize project
→ /init --fresh

# Connect to model
→ /model

# Generate code in natural language
→ Create a sentiment analyzer with confidence scores

# Validate
→ /validate

# Save
→ /save sentiment_analyzer.py

# Generate training data
→ Generate 50 examples for sentiment analysis

# Optimize with GEPA
→ /optimize sentiment_analyzer.py training_data.jsonl

Result: Production-ready, optimized sentiment analyzer in 5 minutes!


🏃 Quick Start

1. Install

pip install dspy-code

2. Start

dspy-code

3. Build

/init
/model
Create a [your app]

Complete Quick Start Guide →


đŸ’Ŧ Real Workflows

Workflow 1: Complete Beginner

Day 1:
→ Install DSPy Code
→ /init --fresh
→ "What is DSPy?"
→ "Create a simple text classifier"
→ /save my_first_program.py
→ /run

Result: Working DSPy program, understanding of basics

Workflow 2: Building Production App

Week 1:
→ dspy-code /init in existing project
→ Generate signatures, modules, programs
→ Generate 200 training examples
→ Optimize with GEPA
→ Validate (95/100 quality score)
→ Export as package
→ Deploy

Result: Production-ready AI application

Workflow 3: Learning Advanced Patterns

→ "Show me how ReAct works"
→ "Create a multi-agent system"
→ "Explain GEPA optimization"
→ "Build a RAG system with custom retrieval"

Result: Deep understanding through hands-on building

đŸŽ¯ Common Questions

Do I need to know DSPy first?

No! That's the whole point. DSPy Code teaches you as you build. Just start creating and ask questions when you need help.

Can I use this with my existing DSPy code?

Yes! Run /init in your project directory. DSPy Code will scan your code and help you extend it.

What models can I use?

Any! Ollama (local), OpenAI, Anthropic, Gemini. Connect easily with /model or directly with /connect <provider> <model>.

Is the optimization real or mocked?

Real GEPA optimization! Actual Genetic Pareto optimization that improves accuracy by 10-30%.

Do I need to read documentation?

No! Just ask DSPy Code. It answers questions using your actual installed DSPy version.


🚀 Ready to Start?

Start Building in 2 Minutes

No docs to read. No tutorials to follow. Just start building.


📚 Documentation Structure

  • Getting Started

    Installation, quick start, first program, understanding the architecture

  • User Guide

    Interactive mode, code generation, validation, optimization, project management

  • Tutorials

    Step-by-step guides for building real applications

  • Reference

    Commands, configuration, FAQ, troubleshooting

  • Advanced

    MCP integration, custom modules, deployment


🤝 Technical Support

Need help? Check these resources:


DSPy Code by Superagentic AI

Comprehensive CLI to Optimize Your DSPy Code - Learn by building. No docs required.