liveBook · Manning

Placeholder

As explained in Spring AI in Action

A placeholder is a marked position in a prompt template that can be replaced with a value when the prompt is created.

A placeholder marks variable data inside a prompt template. Static instructions surround positions such as {game} and {question}; Spring AI fills those positions before submitting the completed prompt to an LLM. section 3.1 section 3.1.1

Use placeholders to keep prompt construction explicit and maintainable:

  • Define the reusable prompt as a StringTemplate or external template resource. section 3.1.1 section 11.2.1
  • Name a placeholder for each variable value, such as a game, question, source language, target language, or source text. section 3.1.1 section 11.2.1
  • Pass the template through ChatClient user configuration and call param() for each value before calling the model. section 3.1.1

Tabletop-game question

A template such as “Answer this question about {game}: {question}” can receive “checkers” and “How many pieces are there?” at request time, producing a focused prompt and answer. section 3.1.1

How Spring AI in Action covers it

How deep it goes
Defines placeholders and demonstrates template declaration, parameter binding, rendering, and invocation, without detailing template-engine internals.
Examples
Demonstrates tabletop-game questions and English-to-Spanish, English-to-Klingon, and Klingon-to-English translation requests.
What it assumes
Assumes familiarity with Spring Boot applications, Java records, REST endpoints, and injected ChatClient builders.
What you can do after
Build it from scratch by defining a template, binding request values, and sending the rendered prompt through ChatClient.
How it connects
Connects prompt templates with StringTemplate, ChatClient, LLMs, REST controllers, and generative AI applications.

Also explained in

Compare how 7 books explain placeholder →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring AI in Action. The section links point to the parts of the book it draws on.