Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.goantiai.com/llms.txt

Use this file to discover all available pages before exploring further.

Installation

pip install oculus-sdk

Quick reference

from oculus_sdk import OculusClient
from oculus_sdk.exceptions import OculusAuthError, OculusAPIError, TokenRevokedException

client = OculusClient(
    client_id="your-client-id",
    client_secret="your-client-secret",
    base_url="https://api.antiailabs.com",
)

token = client.get_token(scope="db:read")
token = await client.aget_token(scope="db:read")
token = client.get_token(scope="db:read stripe:customer:read")
token = client.get_token(scope="db:read", audience="https://myservice.example.com")

client.stop()  # on shutdown

Full example

import os
import atexit
import httpx
from oculus_sdk import OculusClient
from oculus_sdk.exceptions import OculusAuthError, OculusAPIError, TokenRevokedException

client = OculusClient(
    client_id=os.environ["AGENT_CLIENT_ID"],
    client_secret=os.environ["AGENT_CLIENT_SECRET"],
    base_url=os.environ.get("ANTI_AI_URL", "https://api.antiailabs.com"),
)
atexit.register(client.stop)

def call_api(endpoint: str, scope: str) -> dict:
    try:
        token = client.get_token(scope=scope)
    except TokenRevokedException:
        raise RuntimeError("Agent access has been revoked. Contact your admin.")
    except OculusAuthError as e:
        raise RuntimeError(f"Authentication failed: {e}")
    except OculusAPIError as e:
        raise RuntimeError(f"Anti AI error: {e}")

    response = httpx.get(endpoint, headers={"Authorization": f"Bearer {token}"})
    response.raise_for_status()
    return response.json()

Token caching

The SDK caches tokens in memory keyed by (scope, audience). Tokens are reused until 10 seconds before expiry. You never manage token lifetimes.

Exception reference

ExceptionWhen raisedWhat to do
OculusAuthErrorInvalid credentials, agent suspended/revokedCheck credentials; verify agent status
OculusAPIErrorAny other API errorCheck e.status_code and e.details
TokenRevokedExceptionCached token revokedAlert your team — this is intentional