Input Variable Handling
Thepl.run() function handles input variables in the following ways:
1. Normal Usage
Provide all required variables as defined in your prompt template:2. Missing Variables
If you don’t provide the required input variables, you’ll receive a warning in the console, but the prompt template will still run. The missing variables will be sent to the LLM as unprocessed strings:3. Extra Variables
If you include extra variables that aren’t in the template, they will be ignored:release_year variable will be ignored in the LLM request if it’s not part of the current template.
Zero Downtime Update Process
Follow these steps to safely add new variables to your prompt template without any service interruption:Example Scenario
Assume you have a prompt template version tagged withprod that uses only one input variable, favorite_movie:
mood variable to enhance the recommendations.
Step-by-Step Process
-
Create a new template version with the new
moodvariable in the PromptLayer UI -
Apply a unique temporary label (e.g.,
new-var) to the new version in the UI - Update and deploy your code to use the new template version and include the new variable:
- Verify the deployment is working correctly with the new variable
-
In the PromptLayer UI, move the
prodlabel to the new prompt version -
Update your source code to reference the
prodprompt version again and deploy:
- Clean up by deleting the temporary
new-varlabel from the PromptLayer UI
Benefits of This Approach
- Zero downtime: Your service remains available throughout the update process
- Rollback capability: You can quickly revert to the previous version if issues arise
- Gradual rollout: You can test the new version with a subset of traffic first
- Version control: Both prompt templates and code changes are versioned and synchronized
Best Practices
- Always test new variables in a staging environment first
- Use descriptive temporary labels that indicate the purpose (e.g.,
add-mood-var) - Document variable changes in your commit messages and PR descriptions
- Consider using feature flags for more complex deployments
- Monitor logs during the deployment for any unexpected warnings

