How to manage prompts?
After testing and perfecting your prompts, you can query and use them in your production systems. This guide shows how to retrieve prompts from the Maxim platform and integrate them into your applications.Prerequisites
To query prompts, you need to:- Enable prompt management in your Maxim SDK configuration
- Have deployed prompts on the Maxim platform with deployment rules
Setup
Initialize the Maxim SDK with prompt management enabled:Querying a Single Prompt
Retrieve a specific prompt using deployment variables to match your environment:Querying a Specific Prompt Version
Retrieve a specific version of a prompt using the version number:Querying Multiple Prompts
Retrieve all prompts that match specific deployment criteria:Supported Variable Types
When building queries usingdeploymentVar, ensure the value matches the type defined in your deployment configuration:
| Variable Type | SDK Data Type | Example Value |
|---|---|---|
| Text | String | "lorem" |
| Number | Number | 42 |
| Boolean | Boolean | true or false |
| Select | String | "Production" |
| Multi-select | String[] | ["US-East", "EU-West"] |
Using Tags for Fine-Grained Filtering
Query prompts using tags for more specific filtering:Folder-Based Organization
Query prompts from specific folders to organize by team or feature:Matching algorithm
Before going into the details of how to use the SDK, let’s understand how the matching algorithm works. Maxim SDK uses best matching entity algorithm.- Let’s assume that, you have asked for a prompt with deployment var
envasprod,customerIdas"123"and a tag,tenantIdas456forpromptId-"abc". - SDK will first try to find a prompt matching all conditions.
- If we don’t find any matching entity, we enforce only
deploymentVarconditions (you can override this behaviour, as explained in the next section) and match as many tags as possible. - If we still don’t find any prompt, we check for a prompt version marked as fallback.
- If we still don’t find any prompt, we return
null.
Overriding fallback algorithm
- You can override fallback algorithm by calling
.exactMatch()onQueryBuilderobject. That will enforce all conditions to be matched.
- You can override fallback algorithm at each variable level. The third optional parameter in
deploymentVar&tagfunction isenforce. If you passtrueto this parameter, it will enforce exact match for that variable.
Caching and Performance
The Maxim SDK automatically caches prompt configurations to improve performance using the cache provided to the constructor. When you request a prompt or prompt chain, the SDK first checks the cache for a matching deployment variable rule before making an API call.Best Practices
- Environment Separation: Use deployment variables to separate dev/staging/production prompts
- Graceful Degradation: Implement fallback prompts for critical functionality
- Version Management: Use tags to manage prompt versions and gradual rollouts
Next Steps
- CI/CD Integration - Automate prompt testing and deployment
- Local Prompt Testing - Test changes before deployment
- Maxim Prompt Testing - Validate prompt versions