New260+ blocks and 240+ tools are now fully documented
DocumentationReferenceCore BlocksAI & Reasoning
Block

DSPy Block

Run DSPy AI programs and optimize prompts

The DSPy block runs DSPy language model programs inside your workflow, letting you execute structured AI tasks and optimize prompt chains in code. Reach for it when you need programmatic, optimizable LLM pipelines rather than a single freeform prompt.

Overview

PropertyValue
Typedspy
Categorytools
Color#E0E0E0

When to Use

  • Execute a DSPy program defined in code as part of an automated workflow
  • Optimize prompt chains and structured AI tasks programmatically
  • Build multi-step LLM pipelines that need composition and optimization
  • Run structured prediction tasks where you want a typed prediction object back
  • Integrate existing DSPy programs into a larger Zelaxy workflow
  • Connect to a self-hosted or remote DSPy server with optional API key authentication

Configuration

DSPy Program (Code)

A required code editor where you write the DSPy program to run. Start with import dspy and define your module, signature, or chain. This field is mapped to the program input.

Input

A long-input field providing the data passed to the DSPy program at execution time. Commonly references an upstream block's output using {{blockName.field}}. Mapped to the input input.

Inputs & Outputs

  • Inputs:

    • program (string) — DSPy program code to execute
    • input (string) — Input to pass to the DSPy program
  • Outputs:

    • output (string) — Program output (resolved from output, answer, or response field in the server response)
    • prediction (json) — Full prediction object returned by the DSPy server

Tools

DSPy Run (dspy_run) — Sends the program code and input to a running DSPy server via POST /run and returns the prediction output. Requires a baseUrl pointing to your DSPy server (e.g. https://your-dspy-server.com). Supports an optional apiKey for Bearer token authentication. Both baseUrl and apiKey are user-only params (not visible to the LLM); program and input are user-or-llm params.

YAML Example

dspy_1:
  type: dspy
  name: "DSPy"
  inputs:
    program: |
      import dspy
      # Define your DSPy program here
    input: "{{start.input}}"
  connections:
    outgoing:
      - target: next-block-id