All Python code snippets in this document are for version 3.4.0+.
Setting Up the SDK
Initializing the SDK
Working with Deployment Variables
For a prompt chain with specific deployment variables
For building query to get prompt chain with specific deployment variables, you can useQueryBuilder.
Adding Multiple Queries
Querying Prompts Chains
Sometimes you have usescases where you need to fetch multiple deployed prompt chains at once using a single query. For example, you might want to fetch all prompts for a specific customer or specific workflow. You can usegetPromptChains function for this purpose.
You will need to query using at-least one
deploymentVar as a filter. Hence you will need to deploy prompt chain versions before querying
them.Query deployed prompt chains using folder
To get all prompts from a folder, you can usegetPromptChains function with folderId as a query parameter.
First capture folder id
There are multiple ways to capture folder id. You can use Maxim dashboard to get folder id.- Right click/click on three dots on the folder you want to get id for.
- Select
Edit Folderoption. - You will see folder id in the form.

Getting Folders by Tags
All the rules of prompt chain matching algorithm apply here. You can use same overriding techniques as explained above.
Retrieving Deployed Prompts from a Folder
Filtering Prompt Chains by Deployment Variables
You have to pass at-least one filter along with
folder().Data Structures
Prompt Chain Structure
Folder Structure
Caching
Using Custom Cache Implementation
Maxim SDK uses in-memory caching by default. You can use your own caching implementation by passing a custom cache object to the SDK. This allows you to remove complete dependency on our backend.Cache Interface Definition
Implementing Custom Cache
Default In-Memory Cache Implementation
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 chain with deployment var
envasprod,customerIdas"123"and a tag,tenantIdas456forpromptId-"abc". - SDK will first try to find a prompt chain 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 chain, we check for a prompt chain version marked as fallback.
- If we still don’t find any prompt chain, we return
null.