Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Vers Python API Library

This library provides convenient access to the Vers REST API from Python.

It is generated with Sterling.

Installation

pip install vers-sdk

Usage

import asyncio
from vers_sdk import VersSdkClient

async def main():
    client = VersSdkClient(
        api_key="your-api-key",  # or set VERS_API_KEY env var
    )

    # List all VMs
    response = await client.list_vms()
    print(response.json())

    # Create a new root VM
    vm = await client.create_new_root_vm(body={"vm_config": {}})
    print(vm.json())

    await client.close()

asyncio.run(main())

Configuration

client = VersSdkClient(
    api_key="your-api-key",       # or set VERS_API_KEY env var
    base_url="https://api.vers.sh", # or set VERS_BASE_URL env var
    max_retries=2,
    timeout=30.0,
    http_client=custom_httpx_client,  # optional custom httpx.AsyncClient
)

Error handling

from vers_sdk.errors import APIError, NotFoundError, RateLimitError

try:
    await client.delete_vm("nonexistent-id")
except NotFoundError as e:
    print(f"Not found: {e.status} {e.message}")
except APIError as e:
    print(f"API error: {e.status}")

Retries

Requests are automatically retried up to 2 times on 5xx errors and connection failures, with exponential backoff and jitter. The client respects Retry-After headers (capped at 60s).

Async context manager

async with VersSdkClient(api_key="...") as client:
    vms = await client.list_vms()

Requirements

  • Python 3.10+
  • httpx

License

MIT

About

Vers SDK — generated from the Vers OpenAPI spec

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages