(Unofficial) Novita AI Python SDK
(Unofficial,) Modern, fully type-safe Python SDK for the Novita AI API. Built with Pydantic v2 and httpx.
Features
- Fully Type-Safe: Complete type hints for excellent IDE support
- Async & Sync: Both synchronous and asynchronous clients
- Pydantic Models: Request/response validation with Pydantic v2
- Modern Stack: Built on httpx and modern Python practices
Installation
pip install novita-sdk
Quick Start
Authentication
Set your API key as an environment variable:
export NOVITA_API_KEY="your-api-key-here"
Or pass it directly to the client:
from novita import NovitaClient
client = NovitaClient(api_key="your-api-key-here")
Synchronous Client
from novita import NovitaClient, CreateInstanceRequest, Kind
client = NovitaClient()
request = CreateInstanceRequest(
name="my-gpu-instance",
product_id="prod-123", # fetch via client.gpu.products.list()
gpu_num=1,
rootfs_size=50,
image_url="ubuntu:22.04",
kind=Kind.gpu,
)
response = client.gpu.instances.create(request)
print(f"Created instance: {response.id}")
instances = client.gpu.instances.list()
for instance in instances:
print(f"{instance.name}: {instance.status.value}")
client.close()
Asynchronous Client
import asyncio
from novita import AsyncNovitaClient, CreateInstanceRequest, Kind
async def main():
async with AsyncNovitaClient() as client:
request = CreateInstanceRequest(
name="my-async-instance",
product_id="prod-123",
gpu_num=1,
rootfs_size=50,
image_url="ubuntu:22.04",
kind=Kind.gpu,
)
response = await client.gpu.instances.create(request)
print(f"Created: {response.id}")
instance = await client.gpu.instances.get(response.id)
print(f"Status: {instance.status.value}")
asyncio.run(main())
📚 Examples
For more detailed examples and use cases, check out the examples/ directory:
- basic_sync.py - Synchronous client basics
- basic_async.py - Asynchronous operations
- instance_lifecycle.py - Complete lifecycle management
- error_handling.py - Error handling patterns
- pricing_and_types.py - Pricing and instance types
- context_managers.py - Context manager patterns
See the examples README for detailed instructions.
Advanced Usage
Context Managers
Both clients support context managers for automatic cleanup:
# Synchronous
with NovitaClient() as client:
instances = client.gpu.instances.list()
# Client automatically closed
# Asynchronous
async with AsyncNovitaClient() as client:
instances = await client.gpu.instances.list()
# Client automatically closed
Custom Configuration
client = NovitaClient(
api_key="your-key",
base_url="https://custom-api.novita.ai", # Custom base URL
timeout=120.0 # Custom timeout in seconds
)
Price Conversion
Important: The Novita API returns prices in an unusual format (units of 1/100,000 USD). This SDK automatically converts all prices to standard USD for your convenience.
For example:
- API returns
67000→ SDK provides$0.67/hour - API returns
35000→ SDK provides$0.35/hour
This conversion is applied to:
GPUProduct.price- On-demand pricingGPUProduct.spot_price- Spot instance pricingSubscriptionPrice.price- Monthly subscription pricingCPUProduct.price- CPU instance pricing
The raw API values are still available if needed via *_raw fields (price_raw, spot_price_raw, etc.):
products = client.gpu.products.list()
product = products[0]
print(f"Converted: ${product.price}/hour") # e.g., $0.67/hour
print(f"Raw API value: {product.price_raw}") # e.g., 67000
print(f"Spot (converted): ${product.spot_price}/hour")
print(f"Spot (raw): {product.spot_price_raw}")
API Resources
The SDK provides complete coverage of the Novita GPU Cloud API:
- Instances - GPU instance lifecycle management
- Products - GPU and CPU product listings with filtering
- Endpoints - API endpoint management
- Networks - VPC network configuration
- Templates - Instance template management
- Jobs - Job execution and control
- Metrics - Instance performance metrics
- Storages - Network storage management
- Image Registry - Container registry authentication
- Images - Image prewarm task management
- Clusters - Available GPU cluster information
Development
Pre-commit Hooks
This project uses pre-commit hooks to ensure code quality. The hooks automatically run on every commit and check:
- Linting - Ruff checks for code issues
- Formatting - Ruff formats code consistently
- Type checking - MyPy validates type hints
- Unit tests - Fast test suite ensures no regressions
- File checks - Trailing whitespace, end-of-file, YAML/TOML validation
Install the hooks:
make pre-commit-install
Run manually on all files:
make pre-commit-run
Skip hooks for a specific commit (use sparingly):
git commit --no-verify
Requirements
- Python 3.11 or higher
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for novita-sdk 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| novita_sdk-0.5.0.tar.gz | 25.3 kB | With provenance | Details for novita_sdk-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| novita_sdk-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for novita_sdk-0.5.0-py3-none-any.whl |
Total release size: 54.9 kB
Release files / novita_sdk-0.5.0.tar.gz
| Download URL | novita_sdk-0.5.0.tar.gz |
|---|---|
| Size | 25.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d74827e9ed2ebaf50b84027ecaf1c314994518efcd82affabb931760e3b122d9
|
|
BLAKE2b-256 checksum How to use checksums |
8f8f83d73a06ba79034e8d669bddb37662287366aa0d8dc83c3c1d11cf315bde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logRelease files / novita_sdk-0.5.0-py3-none-any.whl
| Download URL | novita_sdk-0.5.0-py3-none-any.whl |
|---|---|
| Size | 29.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd4be0ca1dcce005e5aacd75cd59b0aeba6d6225fc6f2d15236c590054601c0c
|
|
BLAKE2b-256 checksum How to use checksums |
fd4087d394aeb5f091f7ca6dab469cf9db40e9c83093aa86bb97e1e5f33a28ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logSecurity for novita-sdk 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for novita_sdk-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.