TextGrad
TextGrad is a self-hosted library in the Prompt Engineering layer of the AI stack. Automatic prompt optimisation via textual feedback loops.
By Kunj ShahFacts verifiedmethod
- Licence
- MIT
- Language
- Python
- Cost
- free
- Owned by
- Applied Engineering
Use TextGrad when
Automatic prompt optimisation via textual feedback loops.
Skip TextGrad when
Optimising without an eval set is guessing.
Makes the prompt an artifact you can diff and test. See every prompts tool.
Badge this entry
[](https://lattice.kunjshah.in/prompt-engineering/textgrad)Rules of thumb
- Prompt changes without evals are guesses. Version prompts and measure before you ship a wording change.
- Keep prompts out of string literals. A prompt you cannot diff is a prompt you cannot review.
- Fix the examples before the instructions. Models copy what you show more faithfully than what you tell.
Quick answers
- Is TextGrad open source?
- Yes. TextGrad is open source under the MIT licence. It is free to use.
- What are the alternatives to TextGrad?
- The closest alternatives to TextGrad are DSPy.
Ask an AI about this page
Opens the assistant with this page’s link and a question already filled in.
Reading on prompts
- When you don't need LLM evals (and when you do)Skip evals while nothing depends on the output. The day a prompt change can break something a user relies on, you need them, and twenty cases is enough to start.
- Prompt, or fine-tune?Almost every 'the model does not know this' problem is a retrieval problem wearing a hat. Here is how to tell the difference before you spend a week on a training run.
- Context is a budget, not a containerThe instinct is to keep everything in case it is needed. The models are not filing systems, and past a certain length the middle of your context is doing nothing but costing money.
Alternatives to TextGrad
Listed as an alternative to
- DSPyDSPyDeclarative prompting that compiles to optimized programs from examples.MIT · self-hosted · free
Use when Compiling prompts into optimised programs from labelled examples.
Skip when You have no examples and no way to score them.
Also in prompts
- DSPyDSPyDeclarative prompting that compiles to optimized programs from examples.MIT · self-hosted · free
Use when Compiling prompts into optimised programs from labelled examples.
Skip when You have no examples and no way to score them.
- InstructorInstructorSchema-constrained extraction with automatic validation and retry.MIT · self-hosted · free
Use when Schema-validated extraction with typed retry and partial streaming.
Skip when You need a hard token-level guarantee rather than validation.
- HumanloopHumanloopPrompt versioning and evaluation for production teams.proprietary · saas · usage-based
Use when Prompt versioning and evaluation run by a product team.
Skip when Prompts or data cannot be sent to a vendor.
- GuidanceGuidanceConstrained generation by interleaving control flow and model output.MIT · self-hosted · free
Use when Constrained decoding with control flow interleaved into generation.
Skip when You need better ergonomics for plain extraction.
- PromptLayerPromptLayerPrompt registry with request logging and regression testing.proprietary · saas · usage-based
Use when A prompt registry with request logging and regression tests.
Skip when You need self-hosting.
- AgentaAgentaOpen-source prompt management with a playground and versioning.Apache-2.0 · self-hosted · free-tier
Use when Open-source prompt management with a playground and versioning.
Skip when You need eval depth rather than prompt ergonomics.
- PromptwatchPromptwatchPrompt regression tests and side-by-side comparison.proprietary · saas · usage-based
Use when Prompt regression tests and side-by-side comparison.
Skip when You need self-hosting.
- OutlinesOutlinesConstrained generation that masks the token space to valid output.Apache-2.0 · self-hosted · free
Use when Token-level constrained generation from a JSON schema or grammar.
Skip when Post-hoc validation is enough for your use case.