Skip to main content

Prime Evals SDK

Lightweight Python SDK for managing Prime Intellect evaluations - push, track, and analyze your model evaluation results.

Features

  • Simple evaluation management - Create, push samples, and finalize evaluations
  • Type-safe - Full type hints and Pydantic models
  • Authentication caching - Automatic token management
  • Environment checking - Validate environments before pushing
  • No CLI dependencies - Pure SDK, lightweight installation
  • Context manager support - Automatic resource cleanup

Installation

uv pip install prime-evals

Or with pip:

pip install prime-evals

Quick Start

from prime_evals import APIClient, EvalsClient

# Initialize client
api_client = APIClient(api_key="your-api-key")
client = EvalsClient(api_client)

# Create an evaluation
eval_response = client.create_evaluation(
    name="gsm8k-gpt4o-baseline",
    model_name="gpt-4o-mini",
    dataset="gsm8k",
    framework="verifiers",
    metadata={
        "version": "1.0",
        "num_examples": 10,
        "temperature": 0.7,
    }
)

eval_id = eval_response["evaluation_id"]
print(f"Created evaluation: {eval_id}")

# Push samples
samples = [
    {
        "example_id": 0,
        "reward": 1.0,
        "correct": True,
        "answer": "18",
        "prompt": [{"role": "user", "content": "What is 9+9?"}],
        "completion": [{"role": "assistant", "content": "The answer is 18."}],
    }
]

client.push_samples(eval_id, samples)

# Finalize with metrics
metrics = {
    "avg_reward": 0.87,
    "avg_correctness": 0.82,
    "success_rate": 0.87,
}

client.finalize_evaluation(eval_id, metrics=metrics)
print("Evaluation finalized!")

Async Usage

import asyncio
from prime_evals import AsyncEvalsClient

async def main():
    async with AsyncEvalsClient(api_key="your-api-key") as client:
        # Create evaluation
        eval_response = client.create_evaluation(
            name="my-evaluation",
            model_name="gpt-4o-mini",
            dataset="gsm8k",
        )
        
        eval_id = eval_response["evaluation_id"]
    
        # Push samples
        await client.push_samples(eval_id, samples)
        
        # Finalize
        await client.finalize_evaluation(eval_id)
        
# Client automatically closed

asyncio.run(main())

Authentication

The SDK looks for credentials in this order:

  1. Direct parameter: APIClient(api_key="sk-...")
  2. Environment variable: export PRIME_API_KEY="sk-..."
  3. Config file: ~/.prime/config.json (created by prime login CLI command)

Complete Example

from prime_evals import APIClient, EvalsClient

# Initialize
api_client = APIClient(api_key="your-api-key")
client = EvalsClient(api_client)

# Create evaluation with full metadata
eval_response = client.create_evaluation(
    name="gsm8k-experiment-1",
    model_name="gpt-4o-mini",
    dataset="gsm8k",
    framework="verifiers",
    task_type="math",
    description="Baseline evaluation on GSM8K dataset",
    tags=["baseline", "math", "gsm8k"],
    metadata={
        "version": "1.0",
        "timestamp": "2025-10-09T12:00:00Z",
        "num_examples": 100,
        "temperature": 0.7,
        "max_tokens": 2048,
    }
)

eval_id = eval_response["evaluation_id"]

# Push samples in batches
samples_batch = [
    {
        "example_id": i,
        "task": "gsm8k",
        "reward": 1.0 if i % 2 == 0 else 0.5,
        "correct": i % 2 == 0,
        "format_reward": 1.0,
        "correctness": 1.0 if i % 2 == 0 else 0.0,
        "answer": str(i * 2),
        "prompt": [
            {"role": "system", "content": "Solve the math problem."},
            {"role": "user", "content": f"What is {i} + {i}?"}
        ],
        "completion": [
            {"role": "assistant", "content": f"The answer is {i * 2}."}
        ],
        "info": {"batch": 1}
    }
    for i in range(10)
]

client.push_samples(eval_id, samples_batch)

# Finalize with computed metrics
final_metrics = {
    "avg_reward": 0.75,
    "avg_format_reward": 1.0,
    "avg_correctness": 0.50,
    "success_rate": 0.75,
    "total_samples": len(samples_batch),
}

client.finalize_evaluation(eval_id, metrics=final_metrics)

# Retrieve evaluation details
eval_details = client.get_evaluation(eval_id)
print(f"Evaluation Status: {eval_details.get('status')}")

# List all evaluations
evaluations = client.list_evaluations(limit=10)
for eval in evaluations.get("evaluations", []):
    print(f"{eval['name']}: {eval.get('total_samples', 0)} samples")

# Get samples
samples_response = client.get_samples(eval_id, page=1, limit=100)
print(f"Retrieved {len(samples_response.get('samples', []))} samples")

Push from JSON File

You can also push evaluations from a JSON file:

import json
from prime_evals import APIClient, EvalsClient

with open("eval_results.json") as f:
    eval_data = json.load(f)

api_client = APIClient()
client = EvalsClient(api_client)
# Create
eval_response = client.create_evaluation(
    name=eval_data["eval_name"],
    model_name=eval_data["model_name"],
    dataset=eval_data["dataset"],
    metadata=eval_data.get("metadata"),
    metrics=eval_data.get("metrics"),
)

eval_id = eval_response["evaluation_id"]

# Push samples
if "results" in eval_data:
    client.push_samples(eval_id, eval_data["results"])

# Finalize
client.finalize_evaluation(eval_id, metrics=eval_data.get("metrics"))

print(f"Successfully pushed evaluation: {eval_id}")

API Reference

EvalsClient

Main client for interacting with the Prime Evals API.

Methods:

  • create_evaluation() - Create a new evaluation
  • push_samples() - Push evaluation samples
  • finalize_evaluation() - Finalize an evaluation with final metrics
  • get_evaluation() - Get evaluation details by ID
  • list_evaluations() - List evaluations with optional filters
  • get_samples() - Get samples for an evaluation
  • create_hosted_evaluation() - Start a hosted evaluation on the platform
  • cancel_hosted_evaluation() - Cancel a running hosted evaluation

AsyncEvalsClient

Async version of EvalsClient with the same methods (all async).

Models

Evaluation

  • Full evaluation object with metadata

Sample

  • Individual evaluation sample with prompt/completion/scores

CreateEvaluationRequest

  • Request model for creating evaluations

EvaluationStatus

  • Enum: PENDING, RUNNING, COMPLETED, FAILED, CANCELLED

Error Handling

Most methods raise EvalsAPIError for validation/producer errors and EvaluationNotFoundError when an evaluation does not exist. The hosted methods (create_hosted_evaluation, cancel_hosted_evaluation) perform no wrapping, so transport failures surface as the underlying APIError from the injected client (sync) or the SDK's own AsyncAPIClient (async). Catch both:

from prime_evals import APIClient, APIError, EvalsClient, EvalsAPIError, EvaluationNotFoundError

try:
    api_client = APIClient()
    client = EvalsClient(api_client)
    client.get_evaluation("non-existent-id")
except EvaluationNotFoundError:
    print("Evaluation not found")
except APIError as e:
    print(f"Transport error: {e}")
except EvalsAPIError as e:
    print(f"API error: {e}")
  • prime - Full CLI + SDK with pods, sandboxes, inference, and more (includes this package)
  • prime-sandboxes - SDK for managing remote code execution environments

License

MIT License - see LICENSE file for details

Metadata

Release files for prime-evals 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prime-evals 0.2.4
File Size Uploaded
prime_evals-0.2.4.tar.gz 16.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prime-evals 0.2.4
File Interpreter ABI Platform
prime_evals-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / prime_evals-0.2.4.tar.gz

Download URL prime_evals-0.2.4.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
759d99e58f587ce8be314a58bdc811106006a74435e981c95c7783045f41cdd0
BLAKE2b-256 checksum
How to use checksums
9c89bfbb4aa271669b16e9bc1303d3edeaaace000e5dd29df9ac7ffebf1fb59e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / prime_evals-0.2.4-py3-none-any.whl

Download URL prime_evals-0.2.4-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50641df3bbc63acac9a85595c2ec363260d41bcc78775a227800449c20648f69
BLAKE2b-256 checksum
How to use checksums
b895c3c2ac163f3ae4909e3e4f47f3244441006432e9e78e9a14833466bac769
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page