> ## 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.

# Agent Deployment

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

## Why deploy Agents via Maxim

* Prompt experimentation - Create multiple versions of your Agents, 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 an Agent

<Steps>
  <Step title="Navigate to Prompt Chains">
    Navigate to Evaluation > Prompts > Prompt Chains and open the prompt chain you want to deploy.
  </Step>

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

  <Step title="Add 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="997" height="736" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/deployment-rule-selection.png" />
  </Step>

  <Step title="Edit 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="1032" height="836" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/add-new-deployment-variable.png" />
  </Step>

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

  <Step title="View 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/all-deployments-list.png?fit=max&auto=format&n=ZQA_95CgxXFSFido&q=85&s=7f3b90ac1b3fc6e0c6f5356954f40911" alt="Deployments list" width="904" height="576" data-path="images/docs/evaluate/how-to/evaluate-prompts/deployments/all-deployments-list.png" />
  </Step>
</Steps>

## Fetching Agents via SDK

For building query to get Agent 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.getPromptChain("prompt-chain-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_chain("prompt-chain-id",
    QueryBuilder()
    .and_()
    .deployment_var("Environment", "prod")
    .build())
  ```
</CodeGroup>

Adding 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.getPromptChain(
    "prompt-chain-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_chain("prompt-id",
    QueryBuilder()
    	.and_()
    	.deployment_var("Environment", "prod")
    	.deployment_var("CustomerId", "123")
    	.build())
  ```
</CodeGroup>

Adding 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.getPromptChain(
    "prompt-chain-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_chain("prompt-chain-id",
    QueryBuilder()
    	.and_()
    	.deployment_var("Environment", "prod")
    	.tag("TenantId", "3000")
    	.build())
  ```
</CodeGroup>

<Callout>Learn more about advanced [prompt chain querying](/offline-evals/via-ui/agents-via-no-code-builder/querying-prompt-chains) techniques.</Callout>
