> For the complete documentation index, see [llms.txt](https://weavescope.gitbook.io/beam_weaver/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://weavescope.gitbook.io/beam_weaver/data-and-retrieval/prompts_parsers.md).

# Prompts And Parsers

Prompts and parsers expose focused constructors and tagged results. Internal composition support is intentionally secondary to direct prompt/parser APIs.

Prompt templates use the safe `:simple` format only, with `{variable}` interpolation. BeamWeaver does not add Mustache, Jinja2, EEx, or Python template aliases.

Prompts can be persisted as declarative BeamWeaver specs:

```elixir
prompt =
  BeamWeaver.Prompt.chat([
    BeamWeaver.Prompt.message(:system, "Use {style} answers."),
    BeamWeaver.Prompt.message(:user, "{input}")
  ])
  |> BeamWeaver.Prompt.partial(%{style: "short"})

:ok = BeamWeaver.Prompt.save(prompt, "priv/prompts/support.yaml")
{:ok, loaded} = BeamWeaver.Prompt.load("priv/prompts/support.yaml")
```

The durable format is JSON-compatible BeamWeaver data, not a serialized Elixir module or Python class reference. Loader configs must declare a BeamWeaver `"type"` and use native keys such as `"partials"`.

Plain template files can be loaded with `Prompt.from_file/2`:

```elixir
{:ok, prompt} = BeamWeaver.Prompt.from_file("priv/prompts/answer.txt")
```

Output parsers include string, JSON, list, CSV/markdown-list, XML, OpenAI tools, OpenAI functions, and schema parsers. Failures return tagged `%BeamWeaver.Core.Error{}` values.

Example:

* `examples/prompt_parser_pipeline.exs`

## Related Guides

* [Messages](/beam_weaver/core-components/messages.md)
* [Models](/beam_weaver/core-components/models.md)
* [Structured Output](/beam_weaver/core-components/structured_output.md)
* [Tools](/beam_weaver/core-components/tools.md)
* [Core](/beam_weaver/data-and-retrieval/core.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://weavescope.gitbook.io/beam_weaver/data-and-retrieval/prompts_parsers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
