Get started with evaluating prompts using the Maxim SDK. This guide will walk you through setting up the SDK and running your first prompt evaluation test run.

Installation

First, install the Maxim SDK for your preferred language:

pip install maxim-py

Getting Your API Key

Before you can use the Maxim SDK, you need to obtain an API key from the Maxim platform:

  1. Log in to Maxim: Go to app.getmaxim.ai/login and sign in to your account
  2. Navigate to Settings: Click on “Settings” in the left sidebar
  3. Go to API Keys: Click on “API keys” under “Organization settings”
  4. Generate New Key: Click the “Generate new” button
  5. Name Your Key: Enter a descriptive name for your API key (e.g., “Development”, “CI/CD”, “Local Testing”)
  6. Copy the Key: Once generated, copy the API key immediately - you won’t be able to see it again
Store your API key securely! You won’t be able to view the complete key value again after closing the generation dialog.

Configuration

Initialize the Maxim SDK with your API key:

from maxim import Maxim

# Initialize Maxim SDK

maxim = Maxim({"api_key": "your-api-key"})

Basic Prompt Test Run

Here’s how to create and run a basic prompt evaluation test run using a dataset from the platform:

# Creating a test run

result = (
    maxim.create_test_run(
        name="Basic Prompt Evaluation", in_workspace_id="your-workspace-id"
    )
    .with_data_structure(
        {
            "input": "INPUT",
            "expected_output": "EXPECTED_OUTPUT",
        }
    )
    .with_data("dataset-id")
    .with_evaluators("Bias")
    .with_prompt_version_id("prompt-version-id")
    .run()
)

print(f"Test run completed! View results: {result.test_run_result.link}")

  • createTestRun is the main function that creates a test run. It takes the name of the test run and the workspace id.

  • withDataStructure is used to define the data structure of the dataset. It takes an object with the keys as the column names and the values as the column types.

  • withData is used to specify the dataset to use for the test run. Can be a datasetId(string), a CSV file, an array of column to value mappings.

  • withEvaluators is used to specify the evaluators to use/attach for the test run. You may create an evaluator locally through code or use an evaluator that is installed in your workspace through the name directly

  • withPromptVersionId is used to specify the prompt version to use for the test run. It takes the id of the prompt version.

  • run is used to execute the test run.

Next Steps

Now that you’ve run your first prompt evaluation, explore these guides: