LangChain 1 · Prompts and chains

Get structured output

Make the model return data that matches a Pydantic class.

from pydantic import BaseModel

class Movie(BaseModel):
    title: str
    year: int

structured = model.with_structured_output(Movie)
structured.invoke("Tell me about Inception.")

Official LangChain 1 documentation

More prompts and chains commands

All prompts and chains commands · LangChain 1 cheatsheet

Was this page helpful?