Introducing dspy-cli: DSPy Programs as HTTP APIs

Letterpress typesetter arranging movable type

Getting DSPy programs into production shouldn't require a bunch of boilerplate

DSPy is an excellent tool for declaratively defining your AI programs. Rather than describing how something should be achieved, DSPy lets you spend your time doing the hard work of defining what you want. Your definition, expressed as a signature, is isolated from the LLM, optimizations, tools, and test-time strategies. This separation of concerns allows you to iterate faster, benefit from modularity, and future-proof your program.

DSPy grew up in the data and research space. It evolved to thrive in experimental notebooks and data pipelines handling batch tasks. That's one of the reasons it remains underappreciated in the agentic and application domains. Other frameworks come with batteries-included and development patterns suited to how most agents or AI functions are built and used.

This is why we created dspy-cli, a tool to quickly create, develop, and deploy DSPy-powered web services. dspy-cli adopts the conventions of web and application development, helping developers quickly scaffold project directories and AI functions.

Here's how quickly you can get started:

$ uv tool install dspy-cli
$ dspy-cli new cms-kit

Running new and providing a project name (here we're building a suite of functions for a CMS), starts an interactive menu that walks you through setting up your first program and an inference provider.

Our first program in cms-kit will be summarizer, a function that accepts a blog post and returns a brief summary. Its signature is "post -> short_summary".

dspy-cli sets up our project directory and creates our summarizer signature and module files.

We can stand up our service locally by running:

$ cd cms-kit
$ dspy-cli serve

dspy-cli detects all modules in our project, notes their input parameters, and sets up an HTTP endpoint for each. We can curl our program, or visit http://localhost:8000 and use the web UI.

After trying and tweaking our programs, we can use the dspy-cli created Dockerfile to deploy our project on cloud services Fly, Render, or AWS.

For example, I maintain a hobby app called StepList that manages checklist routines. StepList is a Rails web app with a few AI-powered features implemented as services, defined with handwritten prompts: string templates mixed in with Ruby code.

Recently, I rebuilt these functions in a dspy-cli project (it took only a few minutes) then used the Dockerfile to deploy them as a Render private service. Now, it's much easier to iterate and maintain my AI programs, route them to more suitable models (shifting one simple program from GPT-5-nano to gpt-oss-20b delivered a ~17x speed up), and reuse the programs elsewhere (you can check out the project here).

We're excited to add more features in the coming weeks, including endpoint authentication and prompt optimization tooling. We hope dspy-cli can simplify building with AI and expose more programmers to the benefits of declarative AI programming.