Learn how to retrieve and use tested prompts from the Maxim platform for your production workflows
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.
Retrieve a specific prompt using deployment variables to match your environment:
Copy
Ask AI
# Query a prompt for production environmentprompt = maxim.get_prompt( id="your-prompt-id", rule=QueryBuilder() .and_() .deployment_var( "Environment", "prod" ) # make sure to use your deployment variables here .deployment_var("TenantId", 123) .build(),)if prompt: # Use the prompt in your application response = prompt.run( input="What are the benefits of cloud computing?", variables={"user_level": "beginner", "industry": "healthcare"}, ) print(f"Response: {response.choices[0].message.content}")else: print("No matching prompt found")
Retrieve all prompts that match specific deployment criteria:
Copy
Ask AI
from maxim import Maximfrom maxim.models import QueryBuilder# Initialize Maxim with prompt management enabledmaxim = Maxim( { "api_key": "your-maxim-api-key", "prompt_management": True, # Enable prompt management })# Get all prompts for a specific environment and featureprompts = maxim.get_prompts( rule=QueryBuilder().and_().deployment_var("Environment", "prod").build())print(f"Found {len(prompts)} matching prompts:")for prompt in prompts: print(f"- Prompt ID: {prompt.prompt_id}, Version: {prompt.version_id}")# Use prompts in your applicationif prompts: support_prompt = prompts[0] # Use first matching prompt response = support_prompt.run("How can I reset my password?") print( f"\nResponse from first prompt and version: {response.choices[0].message.content}" )else: print("No matching prompts found")
Query prompts from specific folders to organize by team or feature:
Copy
Ask AI
# Query prompts from a specific folderprompts = maxim.get_prompts( rule=QueryBuilder() .and_() .folder("folder-id-for-marketing-team") .deployment_var("Environment", "production") .build())print(f"Found {len(prompts)} marketing production prompts")