Skip to content

Getting Started

Install FastSprout with Python 3.12, 3.13, or 3.14:

pip install fastsprout

The core package includes schemas, fields, actions, and DTOs. Use the optional data-sql and events extras when you need those integrations.

Your first action

This example defines an input schema, an output schema, and a class implementing BaseAction. The source lives in docs_src/quickstart.py so it can be run and checked independently of this page.

"""A runnable typed action for the Getting Started guide."""

import asyncio

from fastsprout.core import BaseAction, BaseSchema, Field


class GreetingInput(BaseSchema):
    name: Field[str]


class Greeting(BaseSchema):
    message: Field[str]


class Greet(BaseAction[GreetingInput, Greeting]):
    async def __call__(self, payload: GreetingInput, /) -> Greeting:
        return Greeting(message=f"Hello, {payload.name}!")


async def main() -> None:
    greeting = await Greet()(GreetingInput(name="world"))
    print(greeting.message)


if __name__ == "__main__":
    asyncio.run(main())

Run it from the repository root:

uv run python docs_src/quickstart.py

Result

Hello, world!

An async function can implement the same action protocol; see the class and function examples.

Next steps