Skip to content
Phylax
Tools & interfaces

SDKs

Integrate Phylax from JavaScript, TypeScript, and Python.

  1. Available SDKs

    Both clients are open source, and both wrap the same REST API. Reach for one when you want auth, retries, redaction, and error handling already solved.

  2. Install

    Terminal window
    npm install @phyi/sdk
  3. Authenticate

    The SDKs require a paid subscription. Anonymous access covers the public catalog and search on the web, and stops there. Every call in this guide needs a Builder plan or above, so create a token in the key manager and expose it as PHYLAX_API_TOKEN. Both clients read that variable, so nothing in your source has to hold the credential.

    A token is required. Constructing a client without one fails immediately rather than at the first request, so a missing secret surfaces at startup instead of halfway through a deploy.

    import { PhylaxSdk } from '@phyi/sdk';
    const phylax = new PhylaxSdk({
    apiToken: process.env.PHYLAX_API_TOKEN,
    });
  4. Verify an artifact

    Methods are grouped by the resource they act on, so the call reads like the question you are asking.

    const result = await phylax.artifacts.verify('pkg:npm/express@4.18.2');
    if (!result.success) {
    console.error(result.code, result.error);
    process.exit(1);
    }
    console.log(result.data.verdict); // 'ALLOW' | 'WARN' | 'BLOCK'

    Verify a whole dependency list in one call. One batch request costs a single unit of quota where a loop costs one per artifact, and it avoids paying network latency once per dependency.

    const result = await phylax.artifacts.verifyMany([
    'pkg:npm/express@4.18.2',
    'pkg:pypi/requests@2.32.3',
    ], { policy: 'prod-runtime-policy' });
  5. Handle failure

    The two clients report failure differently, because the idiomatic answer differs by language. TypeScript cannot force you to catch an exception, so the JavaScript client returns a result you have to inspect before reaching the data. Python callers already expect try and except, so the Python client raises.

    const result = await phylax.policies.evaluate('pkg:npm/express@4.18.2');
    if (!result.success) {
    switch (result.code) {
    case 'plan_required':
    return upgradePrompt();
    case 'quota_exceeded':
    return notifyOwner();
    case 'rate_limited':
    return retryLater();
    default:
    throw new Error(result.error);
    }
    }

    result.data is only reachable on the success branch, so the compiler stops you from reading a field off a failed call.

    Rate limits and transient faults are retried for you, with Retry-After honoured when present and exponential backoff with full jitter otherwise. Writes are the exception: a POST or DELETE retries only on 408 and 429, never on a 5xx, because the server may have committed the change before failing to respond.

  6. Check entitlements before you spend

    Access is gated by plan, by token permission, and by period allowance. Most of the SDK is available on Builder; policy controls start at Marketplace, because a policy is how a team enforces one decision across everyone. Rather than discovering a rejection mid-run, ask first.

    const entitlements = await phylax.quota.entitlements();
    if (!entitlements.success) {
    throw new Error(entitlements.error);
    }
    const check = phylax.quota.checkAccess('policies.evaluate', entitlements.data);
    if (!check.allowed) {
    throw new Error(check.reasons.join('; '));
    }

    Read entitlements once at startup and cache them. They change when a subscription changes, not between requests. Treat the check as a fast path that avoids a doomed call, and still handle the rejection at the call site, because the server is the authority and a local table can be stale.

  7. Resource map

    artifacts verify, verifyMany, get, list, search. Verification and lookup for packages, MCP servers, repositories, and skills.
    attestations list, get, verify. Signed evidence, and the check that confirms a bundle you already hold.
    policies list, get, create, update, delete, evaluate. The rule that turns findings into a verdict.
    repositories list, get, add, remove, verify. Track a source repository, or verify one you do not own.
    webhooks list, get, create, update, delete, plus signature verification for inbound deliveries.
    quota entitlements, checkAccess, and the cost table behind every method.

    Full signatures live with each SDK: TypeScript reference, Python reference.

For the endpoints behind these methods, see the REST API. For a terminal workflow, see the Phylax CLI. To verify inbound webhook deliveries, see Webhooks.

Did this page help you?