Skip to content

API Client

The SDK exposes a low-level ApiClient for calling platform endpoints directly. It is useful when you need access to platform routes that are not yet wrapped by higher-level SDK abstractions.

from dreadnode.app.api.client import ApiClient
client = ApiClient("https://api.example.com", api_key="dn_...")

Use the credits client to fetch balance and pricing information, then open Stripe checkout sessions. Credits are org-scoped, so provide a default org or use with_org().

from dreadnode.app.api.client import ApiClient
client = ApiClient(
"https://api.example.com",
api_key="dn_...",
default_org="my-org",
)
balance = client.credits.get_balance()
pricing = client.credits.get_plan()
checkout = client.credits.checkout(
quantity=2,
success_url="https://example.com/billing/success",
cancel_url="https://example.com/billing/cancel",
)

Auto-refill settings are also exposed on the credits client. These endpoints are available in SaaS mode (Enterprise deployments return 404).

auto_refill = client.credits.get_auto_refill()
updated = client.credits.configure_auto_refill(
enabled=True,
threshold=500,
quantity=2500,
monthly_cap=20000,
)
payment_method = client.credits.get_payment_method()
client.credits.disable_auto_refill()

provision_sandbox() wraps POST /org/{org}/sandboxes and accepts optional project, workspace, and secret identifiers.

sandbox = client.provision_sandbox(
"my-org",
"7b1b1c9a-3b2f-4e5d-9a1d-0bcd1234abcd",
project_id="proj-123",
workspace_key="default",
secret_ids=["sec-1", "sec-2"],
)

get_task_instruction() wraps GET /org/{org}/tasks/{task_name}/instruction. Provide a sandbox_id to scope the instruction to a specific sandbox.

instruction = client.get_task_instruction("my-org", "my-task")
scoped = client.get_task_instruction("my-org", "my-task", sandbox_id="sandbox-123")

list_datasets() returns the dataset catalog for an org, and get_dataset() fetches a specific version.

datasets = client.list_datasets("my-org")
latest = datasets[0]
detail = client.get_dataset("my-org", latest.name, latest.latest_version)
print(detail.full_name, detail.latest_version)

list_models() and get_model() follow the same pattern for versioned model artifacts.

models = client.list_models("my-org")
model = models[0]
detail = client.get_model("my-org", model.name, model.latest_version)
print(detail.full_name, detail.latest_version)

Use the inference endpoints to discover platform dn/ system models, read the current user’s model preferences, and provision a LiteLLM virtual key.

models = client.list_system_models()
preferences = client.get_user_preferences()
key_info = client.provision_inference_key()
print(models)
print(preferences)
print(key_info["url"], key_info["expires_at"])