SubModel SDK is a Python library for interacting with the SubModel API.
Create a Python virtual environment and install the SDK:
# Create virtual environment
python -m venv env
# Activate virtual environment
# Windows
env\Scripts\activate
# Linux/macOS
source env/bin/activate
# Install SDK
pip install submodel
It is recommended to set the API key using environment variables:
import os
import submodel
submodel.api_key = os.getenv("SUBMODEL_API_KEY")
from submodel import Client
# Create client
client = Client()
# Create instance
instance = client.instance.create(
billing_method="payg",
mode="pod",
plan="gpu-rtx4090-24g-1",
image="ubuntu-22.04"
)
# Get instance details
inst_id = instance["data"]["inst_id"]
detail = client.instance.get_instance(inst_id)
import asyncio
from submodel import create_async_client
async def main():
async with create_async_client() as client:
instance = await client.instance.create(
billing_method="payg",
mode="pod",
plan="gpu-rtx4090-24g-1",
image="ubuntu-22.04"
)
print(f"Instance created: {instance['data']['inst_id']}")
if __name__ == "__main__":
asyncio.run(main())
If you want to participate in development, please install development dependencies:
pip install -e ".[dev]"
Run tests:
pytest
MIT License
For more examples and complete documentation, please see the examples directory.