Chapter 1 of 7 · 4 practices · 3 min · 4-question quiz
Prompt design and structured output
Clear prompts and machine-readable output are the foundation. These practices make model behaviour predictable enough to test and to parse.
Start: Write specific instructions with the context a new colleague would need4 practices in this chapter
- 1Write specific instructions with the context a new colleague would needModels do what you ask, not what you meant. A vague prompt leaves the model to guess, and guesses are what break in production.
- 2Use schema-enforced structured output when code reads the responseIf your code parses the answer, free-form text is a bug waiting to happen. Ask for JSON that matches a schema, and use your provider's structured output feature when it has one.
- 3Keep prompts in version control and tag every call with the prompt versionA prompt is code. When quality drops, you need to know whether the prompt, the model or the input changed, and that is only possible if prompts have a history.
- 4Check why generation stopped before you trust the outputEvery API response tells you why the model stopped. Code that only reads the text will happily save half a JSON object or a truncated answer, so read the stop or finish reason on every call.
Check yourself on this chapter
4 questions, right here once you are signed in. Your progress is saved as you read.