Using AI-powered message generation features

Also available in:Français

Nonli exposes four Twig helpers for text generation: gpt(), claude(), gemini(), and mistral(). Each helper accepts a prompt and an optional provider model ID:

twig
1{{ gpt('Write one factual sentence.', 'gpt-5.6-luna') }}

If you omit the second argument, Nonli uses its deployed fallback. The optional examples below are a curated starting point, not a Nonli allowlist: actual access, pricing, regions, rate limits, and retirement dates depend on your provider account and API key.

1. Current reference#

Provider helperDeployed Nonli fallback when omittedCurrent compatible examplesLifecycle guidance
gpt()gpt-4ogpt-5.6, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-lunagpt-5.6 is a moving family alias; use a named variant when you need a more explicit capability/cost choice.
claude()claude-sonnet-4-5-20250929claude-fable-5, claude-opus-5, claude-sonnet-5, claude-haiku-4-5-20251001Anthropic's dateless Claude 5 IDs are pinned model IDs; the dated Haiku ID is an explicit snapshot.
gemini()gemini-3.7-flashgemini-3.7-flash, gemini-3.6-flash, gemini-3.5-flashPrefer stable entries for production. Preview and experimental IDs can change or disappear with shorter notice.
mistral()mistral-large-latestmistral-medium-3-5, mistral-small-2603, mistral-large-2512latest is a moving alias; dated/versioned IDs are better for reproducible behavior.

The fallbacks describe deployed Nonli behavior, not each provider's recommendation. If a provider retires a fallback or your key cannot use it, pass a model you can access and update the template after testing.

2. Copyable examples#

2.1. OpenAI#

twig
1{# Omitted model: Nonli uses gpt-4o #}
2{{ gpt('Return only a neutral, factual headline.') }}
3
4{# Explicit current model #}
5{{ gpt('Return only a neutral, factual headline.', 'gpt-5.6-luna') }}

See the official OpenAI model catalog.

2.2. Anthropic Claude#

twig
1{# Omitted model: Nonli uses claude-sonnet-4-5-20250929 #}
2{{ claude('Return only a neutral, factual headline.') }}
3
4{# Explicit current model #}
5{{ claude('Return only a neutral, factual headline.', 'claude-sonnet-5') }}

See the official Anthropic model overview.

2.3. Google Gemini#

twig
1{# Omitted model: Nonli uses gemini-3.7-flash #}
2{{ gemini('Return only a neutral, factual headline.') }}
3
4{# Explicit stable model #}
5{{ gemini('Return only a neutral, factual headline.', 'gemini-3.6-flash') }}

See the official Gemini model catalog.

2.4. Mistral AI#

twig
1{# Omitted model: Nonli uses mistral-large-latest #}
2{{ mistral('Return only a neutral, factual headline.') }}
3
4{# Explicit versioned model #}
5{{ mistral('Return only a neutral, factual headline.', 'mistral-medium-3-5') }}

See the official Mistral model catalog.

3. Which ID should you choose?#

  • Use the omitted model only if you accept that Nonli may update the fallback after a provider retirement.
  • Use a stable alias when you want provider-managed upgrades and can regression-test output over time.
  • Use a pinned or versioned ID when reproducibility matters, then plan a deliberate migration before retirement.
  • Use preview or experimental models only in controlled tests. Do not make them a production dependency without a fallback.
  • Select only text/message-generation models. Image, audio, TTS, embedding, moderation, OCR, video, and agent-only models are not compatible with these helpers.

When no provider credential is available, a helper can return no content. In stricter runtime contexts, a missing or invalid token, inaccessible model, rate limit, or provider error can stop rendering with an error. Always keep a deterministic fallback in important templates, and test with the same provider account used by your brand.

4. Continue the workflow#

Was this article helpful?

Book a personalized demo with our team.