# Structured Output with LangChain and Llamafile

DevFeed: [Structured Output with LangChain and Llamafile](<https://devfeed.tech/articles/structured-output-with-langchain-and-llamafile-25139.md>)

Original publisher: [Read original article](<https://blog.brakmic.com/structured-output-with-langchain-and-llamafile/>)

Author: brakmic

Published: 2025-06-22T16:50:12Z

Content type: tutorial

Language: en

Sources: [Harris Brakmic - Coding](<https://devfeed.tech/sources/harris-brakmic-coding.md>)

Topics: [LangChain](<https://devfeed.tech/topics/langchain.md>), [llamafile](<https://devfeed.tech/topics/llamafile.md>), [JSON](<https://devfeed.tech/topics/json.md>), [llama.cpp](<https://devfeed.tech/topics/llama-cpp.md>), [Parser](<https://devfeed.tech/topics/parser.md>), [Pydantic](<https://devfeed.tech/topics/pydantic.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [code](<https://devfeed.tech/tags/code.md>), [coding](<https://devfeed.tech/tags/coding.md>), [cpp](<https://devfeed.tech/tags/cpp.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [import](<https://devfeed.tech/tags/import.md>), [json](<https://devfeed.tech/tags/json.md>), [langchain](<https://devfeed.tech/tags/langchain.md>), [llama-cpp](<https://devfeed.tech/tags/llama-cpp.md>), [llamafile](<https://devfeed.tech/tags/llamafile.md>), [llm](<https://devfeed.tech/tags/llm.md>), [local](<https://devfeed.tech/tags/local.md>), [local-llm](<https://devfeed.tech/tags/local-llm.md>), [models](<https://devfeed.tech/tags/models.md>), [properties](<https://devfeed.tech/tags/properties.md>), [python](<https://devfeed.tech/tags/python.md>), [structured-output](<https://devfeed.tech/tags/structured-output.md>)

## AI overview

A tutorial on using LangChain with Llamafile to produce structured JSON output from a local large language model. It uses JsonOutputParser, PromptTemplate, and a Pydantic model because Llamafile does not provide a with_structured_output method.

## Source excerpt

Learn how to extend Llamafile with LangChain's JsonParser to produce clean, structured JSON output