Skip to content

Commit a71c951

Browse files
docs: update model to gpt-4.1 and add LiquidJS reference
- Changed all examples from gpt-4o-mini to gpt-4.1 - Added note explaining that Vapi uses LiquidJS for variable substitution - Clarified that {{ }} syntax follows Liquid template language conventions VAP-11219 Co-Authored-By: Claude <[email protected]>
1 parent 1619028 commit a71c951

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

fern/chat/variable-substitution.mdx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ When using sessions with the Chat API, understanding how variable substitution w
1010

1111
**Key concept:** Variables are substituted at session creation time and "baked into" the stored assistant configuration. Template placeholders like `{{name}}` are replaced with actual values and no longer exist in the session.
1212

13+
<Note>
14+
Vapi uses [LiquidJS](https://liquidjs.com/) for variable substitution. The `{{ }}` syntax follows Liquid template language conventions, giving you access to filters, conditionals, and other Liquid features beyond simple variable replacement.
15+
</Note>
16+
1317
---
1418

1519
## How variable substitution works
@@ -19,7 +23,7 @@ When using sessions with the Chat API, understanding how variable substitution w
1923
When you create a session with `assistantOverrides.variableValues`, the system:
2024

2125
1. Takes your assistant's template variables (e.g., `"Hello {{name}} from {{company}}"`)
22-
2. Substitutes all `{{}}` placeholders with provided values
26+
2. Substitutes all `{{ }}` placeholders using LiquidJS
2327
3. Stores the **pre-substituted assistant** in the session
2428
4. Saves the original variable values in `session.metadata.variableValues` for reference
2529

@@ -69,7 +73,7 @@ If your assistant's system prompt was `"You are a helpful assistant for {{name}}
6973
When you send a chat request with a `sessionId`:
7074

7175
1. The system loads the session's pre-substituted assistant
72-
2. Any `variableValues` in the chat request are processed, but **there are no `{{}}` placeholders left** to substitute
76+
2. Any `variableValues` in the chat request are processed, but **there are no `{{ }}` placeholders left** to substitute
7377
3. New variable values have **no effect** on already-substituted text
7478

7579
---
@@ -166,7 +170,7 @@ The assistant still responds with "John" and "Acme Corp" because the original te
166170

167171
### Provide fresh templates to use new values
168172

169-
To use different variable values mid-session, provide a new template with `{{}}` placeholders along with the new values:
173+
To use different variable values mid-session, provide a new template with `{{ }}` placeholders along with the new values:
170174

171175
<CodeBlocks>
172176
```bash title="cURL"
@@ -179,7 +183,7 @@ curl -X POST https://api.vapi.ai/chat \
179183
"assistantOverrides": {
180184
"model": {
181185
"provider": "openai",
182-
"model": "gpt-4o-mini",
186+
"model": "gpt-4.1",
183187
"systemPrompt": "You are a helpful assistant for {{name}} at {{company}}. Be very formal."
184188
},
185189
"variableValues": {
@@ -196,7 +200,7 @@ const chat = await vapi.chat.create({
196200
assistantOverrides: {
197201
model: {
198202
provider: "openai",
199-
model: "gpt-4o-mini",
203+
model: "gpt-4.1",
200204
systemPrompt: "You are a helpful assistant for {{name}} at {{company}}. Be very formal."
201205
},
202206
variableValues: {
@@ -214,7 +218,7 @@ chat = vapi.chat.create(
214218
assistant_overrides={
215219
"model": {
216220
"provider": "openai",
217-
"model": "gpt-4o-mini",
221+
"model": "gpt-4.1",
218222
"systemPrompt": "You are a helpful assistant for {{name}} at {{company}}. Be very formal."
219223
},
220224
"variableValues": {
@@ -237,8 +241,8 @@ Now the assistant responds with "Jane" and "Wayne Enterprises" because fresh tem
237241
|----------|-------------------|-----|
238242
| Session creation with `variableValues` | ✅ Yes | Templates exist, substitution happens |
239243
| Chat with just `sessionId` | ✅ Session values persist | Pre-substituted assistant is used |
240-
| Chat with `sessionId` + new `variableValues` | ❌ No effect | No `{{}}` placeholders left to substitute |
241-
| Chat with `sessionId` + new template with `{{}}` + new `variableValues` | ✅ New values applied | Fresh templates provided |
244+
| Chat with `sessionId` + new `variableValues` | ❌ No effect | No `{{ }}` placeholders left to substitute |
245+
| Chat with `sessionId` + new template with `{{ }}` + new `variableValues` | ✅ New values applied | Fresh templates provided |
242246

243247
---
244248

@@ -287,15 +291,15 @@ Choose one of these approaches:
287291
```
288292
</Accordion>
289293
<Accordion title="Option B: Override with fresh templates">
290-
Include a new system prompt (or other text field) with `{{}}` placeholders plus new `variableValues` in your chat request.
294+
Include a new system prompt (or other text field) with `{{ }}` placeholders plus new `variableValues` in your chat request.
291295

292296
```typescript
293297
const chat = await vapi.chat.create({
294298
sessionId: "existing-session-id",
295299
assistantOverrides: {
296300
model: {
297301
provider: "openai",
298-
model: "gpt-4o-mini",
302+
model: "gpt-4.1",
299303
systemPrompt: "You assist {{customerName}} with their {{accountType}} account."
300304
},
301305
variableValues: {

0 commit comments

Comments
 (0)