Skip to main content

Python SDK for the Synthetic Data Vending Machine (SDVM) API

Project description

sdvm-python

Official Python SDK for the Synthetic Data Vending Machine (SDVM) API.

Installation

pip install sdvm

Or install from source:

pip install -e .

Quick Start

from sdvm import Refinery
from sdvm.types import RawText

refinery = Refinery(api_key="sdvm_...")

result = refinery.run([
    RawText(text="the mitochondria is the powerhouse of the cell"),
    RawText(text="water boils at 100 degrees"),
])

for item in result:
    print(item.text)

Async Support

import asyncio
from sdvm import AsyncRefinery
from sdvm.types import RawText

async def main():
    refinery = AsyncRefinery(api_key="sdvm_...")
    result = await refinery.refine([
        RawText(text="the mitochondria is the powerhouse of the cell"),
        RawText(text="water boils at 100 degrees"),
    ])
    for item in result:
        print(item.text)

asyncio.run(main())

Configuration

Parameter Default Description
api_key required Your sdvm_ API key
base_url https://api.sdvm.dev Override for self-hosted or local dev
timeout 120.0 Request timeout in seconds
refinery = Refinery(api_key="sdvm_...", base_url="http://localhost:8000")

Error Handling

from sdvm import Refinery, AuthenticationError, InsufficientCreditsError, RateLimitError, APIError
from sdvm.types import RawText

refinery = Refinery(api_key="sdvm_...")

try:
    result = refinery.run([RawText(text="hello")])
except AuthenticationError:
    print("Invalid or revoked API key.")
except InsufficientCreditsError:
    print("Not enough credits — purchase more at https://sdvm.dev.")
except RateLimitError:
    print("Slow down — rate limit hit.")
except APIError as e:
    print(f"Unexpected error {e.status_code}: {e}")

API Reference

Refinery

run(data: list[RawText]) -> list[RawText]

Refine a list of raw text samples via the API (max 100 per request).

AsyncRefinery

refine(data: list[RawText]) -> list[RawText]

Same as Refinery.run() but async.

Data Types

RawText

A dataclass with a single field:

  • text: str — the raw text sample to refine.

Exceptions

Exception HTTP Description
AuthenticationError 401 Invalid or revoked key
InsufficientCreditsError 402 Not enough credits
RateLimitError 429 Too many requests
APIError any Unexpected server error

All inherit from SDVMError.

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

sdvm-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

sdvm-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sdvm-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for sdvm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e8b2e23d376ae3f8e126d01eb07e156bedae723784cb3b5d65089b7418f731e
MD5 0e86c49e90c2eda438e245fc39f0f789
BLAKE2b-256 c622a3fa275d863a19785cd99920913893e8e1085f61a9781f248284aa4bf1fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sdvm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for sdvm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b60ead8bf756e71d23c5bbeac8ce64e69c1b6052dabcbc58e41dc6645d20040b
MD5 2c792cc8019dc96432d99f0811776232
BLAKE2b-256 02f223c1b0a01140bb49f4b49c1097717cb1718f3cb741d1368ec7a5eddd13a1

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