Skip to main content

Python SDK for the Verdikt Evaluation API

Project description

verdikt-sdk

Python SDK for Verdikt — a standalone AI evaluation service that decouples evaluation and LLM/human judging from the application being evaluated.

Installation

pip install verdikt-sdk

Usage

from verdikt_sdk import AnswerWithCost, VerdiktClient, EvaluationType, Question
from yalc import LLMModel

client = VerdiktClient(
    base_url="https://your-verdikt-instance.com",
    client_id="your-client-id",
    client_secret="your-client-secret",
)

# Register your app (idempotent — safe to call on every deploy)
await client.create_app(slug="my-app", name="My App")

# Sync questions to the dataset (idempotent)
await client.add_questions("my-app", [
    Question(question="What is the capital of France?", human_answer="Paris"),
])

# Your callback returns the answer plus the cost it took your app to produce it.
# `cost` is optional — pass None when you do not track it.
async def my_llm_function(question: str) -> AnswerWithCost:
    answer, cost = await my_app(question)
    return AnswerWithCost(answer=answer, cost=cost)

# Run an evaluation cycle
await client.run_evaluation(
    app_slug="my-app",
    app_version="v1.2.0",
    callback=my_llm_function,
    evaluation_type=EvaluationType.LLM_ONLY,
    llm_judge_models=[LLMModel.gpt_4o_mini],
)

run_evaluation calls your callback concurrently for every question in the dataset, then submits all answers to Verdikt for judgment.

Breaking change in 0.2.0: the callback now returns AnswerWithCost(answer=..., cost=...) instead of a bare str. Callers on 0.1.x must wrap their return value (return AnswerWithCost(answer=ans) is a drop-in equivalent of the old behaviour).

Authentication

The SDK authenticates via the OAuth2 client-credentials grant against any OIDC-compliant provider (Zitadel, Keycloak, Okta, Auth0, ...). The token endpoint is discovered from the provider's /.well-known/openid-configuration, so no provider-specific URL is hardcoded.

Create a machine / service-account client in your IdP and pass its client_id and client_secret to VerdiktClient:

client = VerdiktClient(
    base_url="https://verdikt.mycompany.com",
    client_id="...",
    client_secret="...",
    # Set when the backend verifies a specific OIDC_AUDIENCE and your IdP
    # wouldn't otherwise stamp it onto the token's `aud`:
    audience="<backend OIDC_AUDIENCE>",
)

The backend verifies the token's issuer and audience, so audience must match the service's OIDC_AUDIENCE when audience verification is enabled.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

verdikt_sdk-0.4.0.tar.gz (112.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

verdikt_sdk-0.4.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file verdikt_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: verdikt_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 112.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for verdikt_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c2c47d13550ef87dd211dadc55721c117d3ed35cc5aa6f4ec155aed9334a5cc4
MD5 503da6ab97359bbc291dc660e79dc528
BLAKE2b-256 a2f8d8f0d157c9df6f73ff2d43526cf223fa5d77059f8e818134e9a5585f9ca7

See more details on using hashes here.

Provenance

The following attestation bundles were made for verdikt_sdk-0.4.0.tar.gz:

Publisher: publish.yml on cognitai-labs-dev/verdikt-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file verdikt_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: verdikt_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for verdikt_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68bfdb65a37a14b23346d2b7178e15cdcf6113d75840414a2c903d22f6cdc942
MD5 55c2261045ef4f5da05df1adb33fb4ef
BLAKE2b-256 51b2a8f382d70438b1d40ca5c3d6f35898b2190845b67f5bc9cea819545ae90c

See more details on using hashes here.

Provenance

The following attestation bundles were made for verdikt_sdk-0.4.0-py3-none-any.whl:

Publisher: publish.yml on cognitai-labs-dev/verdikt-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page