EchoStash
Docs

Meta Templates

Dynamic model configuration with conditional logic

Meta Templates

Meta templates let you define dynamic model configuration that changes based on variables. A single prompt template can target different models, temperatures, and providers depending on input.

Basic Meta Template

meta-basic.echo
provider: openai
model: gpt-4o
temperature: 0.7
maxTokens: 1024

Dynamic Meta with Conditions

meta-dynamic.echo
provider: openai

[#IF {{task}} #equals(creative)]
model: gpt-4o
temperature: 0.9
maxTokens: 2048
[ELSE IF {{task}} #equals(analysis)]
model: gpt-4o-mini
temperature: 0.2
maxTokens: 4096
[ELSE]
model: gpt-4o-mini
temperature: 0.5
[END IF]

Usage with renderMessages()

const echo = createEcho()
const result = await echo.renderMessages(template, variables, {
  metaTemplate: metaDsl
})

result.meta  // { provider: "openai", model: "gpt-4o", temperature: 0.9 }

How It Works

The meta template is processed through the full Echo DSL engine — variables are substituted, conditionals are evaluated. The rendered text is then parsed as simple YAML (key: value pairs, one per line). Values are automatically typed:

  • true / false become booleans
  • Numeric strings become numbers
  • Quoted strings become strings

Supported Meta Keys

Any key-value pair is valid. Common keys:

  • provider — LLM provider (openai, anthropic, google)
  • model — Model name
  • temperature — Sampling temperature
  • maxTokens — Maximum output tokens
  • topP, topK, seed, stop

Use Case

A creative writing prompt might use GPT-4o with high temperature, while a data extraction prompt uses GPT-4o-mini with low temperature — all configured in the meta template, not in application code. This keeps model selection as part of the prompt definition rather than hard-coded in your application.