Skip to main content

Entropy0 Python SDK — source trust and URL safety for AI agents

Project description

entropy0

Python SDK for Entropy0 — source trust and URL safety for AI agents.

pip install entropy0

What it does

Entropy0 evaluates source-level infrastructure signals before an agent fetches an external URL. One call before requests.get() or httpx.get() tells you whether the source is safe to interact with.

Quick start

import os
from entropy0 import Entropy0Client

client = Entropy0Client()  # reads ENTROPY0_API_KEY from env

result = client.decide("github.com")
print(result.action)          # "proceed"
print(result.scores.trust)    # 96
print(result.is_safe)         # True

result = client.decide("githvb.com")
print(result.action)          # "deny"
print(result.reason_codes)    # ["BRAND_MISMATCH", "NEWLY_REGISTERED_DOMAIN"]
print(result.is_safe)         # False

Get an API key at entropy0.ai/signup. The Developer plan is free.

Actions

Action Meaning
proceed Source infrastructure posture is consistent with normal automated interaction
proceed_with_caution Acceptable; keep interaction read-only
sandbox Elevated signals; interact only in a constrained environment
escalate_to_human Ambiguous or high-risk; request human review
deny Infrastructure posture is inconsistent with safe automated interaction

result.is_safe is True for proceed and proceed_with_caution.

Usage

Sync client

from entropy0 import Entropy0Client

with Entropy0Client(api_key="sk_ent0_...") as client:
    result = client.decide("example.com")
    if result.is_safe:
        # fetch the URL
        ...
    else:
        print(f"Blocked ({result.action}): {result.reason_codes}")

Async client

from entropy0 import AsyncEntropy0Client

async with AsyncEntropy0Client() as client:
    result = await client.decide("example.com")

Batch

results = client.batch(["github.com", "githvb.com", "pypi.org"])
for r in results:
    print(r.target_value, r.action, r.scores.trust)

URL evaluation (Team+ plans)

decide_url passes the full URL path to the API. On Developer/free plans it automatically falls back to domain evaluation.

result = client.decide_url("https://github.com/user/repo/raw/main/script.sh")

Interaction context

The defaults (fetch / read_only / medium / balanced) are suitable for most RAG pipelines. Override when needed:

result = client.decide(
    "example.com",
    interaction_kind="api_call",
    interaction_mode="read_write",
    interaction_sensitivity="high",
    policy_profile="strict",
)

LangChain example

from langchain_core.tools import tool
from entropy0 import Entropy0Client, SAFE_ACTIONS

_client = Entropy0Client()

@tool
def entropy0_decide(url: str) -> str:
    """
    Call this before fetching, reading, summarizing, citing, or acting on
    any external URL or domain. If the returned action is not 'proceed' or
    'proceed_with_caution', do NOT call fetch_url — report the action and
    reason_codes to the user instead.
    """
    result = _client.decide(url)
    return (
        f"action={result.action} trust={result.scores.trust} "
        f"threat={result.scores.threat} reason_codes={result.reason_codes}"
    )

Error handling

from entropy0 import Entropy0Client, AuthenticationError, RateLimitError, APIError

try:
    result = client.decide("example.com")
except AuthenticationError:
    # bad or missing API key
    ...
except RateLimitError as e:
    # e.retry_after is seconds until reset (if provided by the API)
    ...
except APIError as e:
    # e.status_code for the HTTP status
    ...

Links

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

entropy0-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

entropy0-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file entropy0-0.1.0.tar.gz.

File metadata

  • Download URL: entropy0-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for entropy0-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f8af3916f29e034cf7237dbb1950666e6caf6f6bceafc6df6404a5fdeb72b3c
MD5 d428180dd9182a23d05073894dff42f1
BLAKE2b-256 1efc71d0469008c51bb99dd75ba90861dd11a9f34000fa415ae17ee1ad35b7c3

See more details on using hashes here.

File details

Details for the file entropy0-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: entropy0-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for entropy0-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82dd1cf093297cfef2fa4ce8bbf569e7f4760185aa76c18fa1218c895a941c02
MD5 4a4fa5e73171d63753ec3f996e63b09f
BLAKE2b-256 c11db327485f34095ca3632caa1dafa9b3b5c6e8af6c4b95722e935422a8405d

See more details on using hashes here.

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