Custom Tools
The @tool decorator turns a typed, documented function into something a model can call:
The @tool decorator turns a typed, documented function into something a model can call:
withstructuredoutput wraps a chat model so it returns a validated Pydantic object instead of prose you then have to parse. The provider enforces the schema at generation time (constrained decoding or native tool-calling), which is far more reliable than parsing free-form output after the fact.