DEV Community

Bipin Budhathoki
Bipin Budhathoki

Posted on Edited on

Introducing aip-lang: Compiling Declarative Prompt Contracts into Standalone PHP and Python

Why Another AI Tool?

Most AI engineering tools (LangChain, LlamaIndex, DSPy) assume two things:

  1. You want heavy runtime abstractions wrapping your entire application.
  2. Your backend is strictly Python or TypeScript.

If your web stack is built on PHP (Laravel, Symfony, WordPress) or you simply want clean, version-controlled prompt templates without hundreds of third-party dependencies, your options are limited.


What is aip-lang?

aip-lang is an open-source domain-specific language (DSL) and compiler for typed LLM prompts. It treats prompt templates as version-controlled software contracts.

Example Contract (support_ticket.aiprompt):

system:
    You are an automated support classifier. Extract details strictly.
user:
    Customer Message: {{ $message }}
generate as TicketAssessment {
    model: "gemini-2.5-flash",
    temperature: 0.1,
    schema: {
        summary: string,
        urgent: bool,
        tags: list[string]
    }
}
Enter fullscreen mode Exit fullscreen mode

Key Capabilities

  • Lark AST Parser: Parses instructions, variable slots, and schema definitions into a structured AST.

  • PHP 8.1+ Code Generation: Generates native PHP classes that handle HTTP transport, payload formatting, and schema validation with zero external Composer packages.

  • Python Target: Generates Pydantic-backed classes with dynamic type enforcement.

  • Multi-Provider: Direct API integration with Google Gemini, Anthropic Claude, and OpenAI.

  • Developer Tooling: Includes a CLI (aip check, aip compile, aip schema) and an offline React-based playground.

Try It Out

GitHub Repository: https://github.com/BipinBudhathoki0/aip-lang

Installation:

git clone https://github.com/BipinBudhathoki0/aip-lang.git
cd aip-lang
pip install -e .
aip check examples/examiner.aiprompt
Enter fullscreen mode Exit fullscreen mode

Top comments (0)