> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt Deployment

> Quick iterations on Prompts should not require code deployments every time. With more and more stakeholders working on prompt engineering, its critical to keep deployments of Prompts as easy as possible without much overhead. Prompt deployments on Maxim allow conditional deployment of prompt changes that can be used via the SDK.

## Why Deploy Prompts via Maxim

* Prompt experimentation - Create multiple versions of your Prompts, and use a wide variety of models available on Maxim to test and compare their performance using your custom data.
* Deploy without code changes - Deploy the final version directly from UI—no code changes required. Use Maxim's RBAC support to limit deployment permission to key stakeholders.
* Custom variables - Use custom variables to create rules to control which environments or user groups should receive the updates. This helps in setting up A/B tests or testing prompt variations internally before pushing to users.

### Deploying a prompt

<Steps>
  <Step title="Select prompt version">
    Open the prompt version you want to deploy.

    <img src="https://mintcdn.com/maximai/ZQA_95CgxXFSFido/images/docs/evaluate/how-to/evaluate-prompts/deployments/prompt-versions-list.png?fit=max&auto=format&n=ZQA_95CgxXFSFido&q=85&s=948c8e4ad4f0c5dfac128284bbd85794" alt="Prompt version list" width="100%" className="max-w-full" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/prompt-versions-list.png" />
  </Step>

  <Step title="Access deployment options">
    Click the <Icon icon="rocket" /> button in the header and choose to deploy the present version.
  </Step>

  <Step title="Configure deployment rules">
    Add one or more rules for deployment e.g. Environment = prod.

    <img src="https://mintcdn.com/maximai/ZQA_95CgxXFSFido/images/docs/evaluate/how-to/evaluate-prompts/deployments/deployment-rule-selection.png?fit=max&auto=format&n=ZQA_95CgxXFSFido&q=85&s=0d2bb743c83dc26a6fe5a65d1b465390" alt="Deployment rules selection" width="100%" className="max-w-full" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/deployment-rule-selection.png" />
  </Step>

  <Step title="Manage deployment variables">
    Edit or define new variables by clicking `Edit deployment variables`
  </Step>

  <Step title="Define variable properties">
    Define the name and type of any variable.

    * For variables of type `select` provide possible options. e.g. Environment: Beta, Staging, Prod.

    <img src="https://mintcdn.com/maximai/ZQA_95CgxXFSFido/images/docs/evaluate/how-to/evaluate-prompts/deployments/add-new-deployment-variable.png?fit=max&auto=format&n=ZQA_95CgxXFSFido&q=85&s=315bc072584d3cc2597ad297722960e8" alt="Add new deployment variable" width="100%" className="max-w-full" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/add-new-deployment-variable.png" />

    * For variables of type `multiselect`, configure when the deployment runs:
      * all selected options are present in the deployment rule using the `=` operator, or
      * any of the selected options are present in the deployment rule using the `includes` operator.

    <img src="https://mintcdn.com/maximai/ZQA_95CgxXFSFido/images/docs/evaluate/how-to/evaluate-prompts/deployments/multiselect-deployment-rule.png?fit=max&auto=format&n=ZQA_95CgxXFSFido&q=85&s=ceec5844c391220fc9837b063fd45fba" alt="Multiselect deployment rule" width="100%" className="max-w-full" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/multiselect-deployment-rule.png" />
  </Step>

  <Step title="Apply conditional deployments">
    Every time you have a new version to deploy, use the variable based rules to deploy conditionally.
  </Step>

  <Step title="Review existing deployments">
    View existing deployments for any prompt from the deploy button in the header.

    <img src="https://mintcdn.com/maximai/ZQA_95CgxXFSFido/images/docs/evaluate/how-to/evaluate-prompts/deployments/deployment-list.png?fit=max&auto=format&n=ZQA_95CgxXFSFido&q=85&s=19f94a73346a6e9056b1e318835365ce" alt="Deployments list" width="100%" className="max-w-full" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/deployment-list.png" />

    <Info>When you create multiple deployments via the UI, only the latest deployment is available for use.</Info>
  </Step>
</Steps>

## Fetching Prompts via SDK

For building query to get prompt with specific deployment variables, you can use `QueryBuilder`.

<CodeGroup>
  ```typescript JS/TS theme={null}
  import { Maxim, QueryBuilder } from "@maximai/maxim-js;

  const maxim = new Maxim({ apiKey: "", promptManagement: true });

  const prompt = await maxim.getPrompt("prompt-id",
                  new QueryBuilder()
                    .and()
                    .deploymentVar("Environment", "prod")
                    .build());
  ```

  ```python Python theme={null}
  from maxim import Maxim, Config
  from maxim.models import QueryBuilder

  maxim = Maxim(Config(api_key="", prompt_management=True))

  prompt = maxim.get_prompt("prompt-id",
    QueryBuilder()
    .and_()
    .deployment_var("Environment", "prod")
    .build())
  ```
</CodeGroup>

Add multiple queries

<CodeGroup>
  ```typescript JS/TS theme={null}
  import { Maxim, QueryBuilder } from "@maximai/maxim-js;

  const maxim = new Maxim({ apiKey: "", promptManagement: true });

  const prompt = await maxim.getPrompt(
    "prompt-id",
    new QueryBuilder().and().deploymentVar("Environment", "prod").deploymentVar("CustomerId", "123").build(),
  );
  ```

  ```python Python theme={null}
  from maxim import Maxim, Config
  from maxim.models import QueryBuilder

  maxim = Maxim(Config(api_key="", prompt_management=True))

  prompt = maxim.get_prompt("prompt-id",
    QueryBuilder()
      .and_()
      .deployment_var("Environment", "prod")
      .deployment_var("CustomerId", "123")
      .build())
  ```
</CodeGroup>

Add filters based on tags

<CodeGroup>
  ```typescript JS/TS theme={null}
  import { Maxim, QueryBuilder } from "@maximai/maxim-js;

  const maxim = new Maxim({ apiKey: "", promptManagement: true});

  const prompt = await maxim.getPrompt(
    "prompt-id",
    new QueryBuilder().and().deploymentVar("Environment", "prod").tag("TenantId", "3000").build(),
  );
  ```

  ```python Python theme={null}
  from maxim import Maxim, Config
  from maxim.models import QueryBuilder

  maxim = Maxim(Config(api_key="", prompt_management=True))

  prompt = maxim.get_prompt("prompt-id",
    QueryBuilder()
      .and_()
      .deployment_var("Environment", "prod")
      .tag("TenantId", "3000")
      .build())
  ```
</CodeGroup>

Use multiselect variables

<CodeGroup>
  ```typescript JS/TS theme={null}
  import { Maxim, QueryBuilder } from "@maximai/maxim-js;

  const maxim = new Maxim({ apiKey: "", promptManagement: true});

  const prompt = await maxim.getPrompt(
    "prompt-id",
    new QueryBuilder().and().deploymentVar("Tenant ID", ["Tenant1"]).build(),
  );
  ```

  ```python Python theme={null}
  from maxim import Maxim, Config
  from maxim.models import QueryBuilder

  maxim = Maxim(Config(api_key="", prompt_management=True))

  prompt = maxim.get_prompt("prompt-id",
    QueryBuilder()
      .and_()
      .deployment_var("Tenant ID", ["Tenant1"])
      .build())
  ```
</CodeGroup>

Fetch a specific prompt version

You can fetch a specific version of a prompt:

<CodeGroup>
  ```typescript JS/TS theme={null}
  import { Maxim, QueryBuilder } from "@maximai/maxim-js";

  const maxim = new Maxim({ apiKey: "maxim-api-key", promptManagement: true });

  const prompt = await maxim.getPrompt(
    "prompt-id",
    new QueryBuilder()
      .promptVersionNumber(1) // fetches version 1
      .build(),
  );
  ```

  ```python Python theme={null}
  from maxim import Maxim, Config
  from maxim.models import QueryBuilder

  maxim = Maxim(Config(api_key="", prompt_management=True))

  prompt = maxim.get_prompt("prompt-id",
    QueryBuilder()  
    .prompt_version_number(1) # fetches version 1
    .build())
  ```
</CodeGroup>
