Deploy to environments

In this guide we will demonstrate how to create and use environments.

Environments enable you to deploy model configurations and experiments, making them accessible via API, while also maintaining a streamlined production workflow. These environments are created at the organizational level and can be utilized on a per-project basis.

Create an environment

1

Go to your Organization’s Environments page.

2

Click the + Environment button to open the new environment dialog.

3

Assign a custom name to the environment.

4

Click Create.


Deploying to an environment

Prerequisites

  • You already have a Prompt — if not, please follow our Prompt creation guide first.
  • Ensure that your project has existing model configs that you wish to use.

To deploy a model config to an environment:

2

Click the dropdown menu of the environment.

3

Click the Change deployment button

4

Select a version

From the model configs or experiments within that project, click on the one that you wish to deploy to the target environment

5

Click the Deploy button.


Calling the model in the environment

Prerequisites

The following steps assume you’re using an OpenAI model and that you’re calling a chat workflow. The steps needed to target a specific environment for a completion workflow are similar.

2

Click the dropdown menu of the environment you wish to use.

3

Click the Use API menu option.

A dialog will open with code snippets. Select the language you wish to use (e.g. Python, TypeScript). The value of environment parameter is the name of environment you wish to target via the chat-deployed call. An example of this can be seen in the code below.

1import os
2from humanloop import Humanloop
3
4HUMANLOOP_API_KEY = os.getenv("HUMANLOOP_API_KEY")
5
6humanloop = Humanloop(api_key=HUMANLOOP_API_KEY)
7
8response = humanloop.chat_deployed(
9 project="YOUR_PROJECT_NAME",
10 inputs={},
11 messages=[{ "role": "user", "content": "Tell a joke" }],
12 provider_api_keys={
13 "openai": "OPENAI_KEY_HERE"
14 },
15 environment="YOUR_ENVIRONMENT_NAME"
16)
17
18print(response.data[0]output)

Updating the default environment

Only Enterprise customers can update their default environment

Prerequisites

Every organization will have a default environment. This can be updated by the following:

1

Go to your Organization’s Environments page.

2

Click on the dropdown menu of an environment that is not already the default.

3

Click the Make default option

A dialog will open asking you if you are certain this is a change you want to make. If so, click the Make default button.

4

Verify the default tag has moved to the environment you selected.