Python SDK for the SGL Network confidential compute grid
Project description
singularity-grid
Python SDK for the SGL Network confidential compute grid. Submit inference jobs to TEE-verified nodes, check grid capacity, and use the OpenAI-compatible chat completions endpoint -- all from a single package.
Installation
pip install singularity-grid
To use the OpenAI compatibility helper:
pip install singularity-grid[openai]
Quick start
1. OpenAI-compatible usage (simplest)
The SGL Network orchestrator exposes an OpenAI-compatible /v1/chat/completions endpoint. You can use the standard openai package with no wrapper:
from openai import OpenAI
client = OpenAI(
base_url="https://sgl-network-orchestrator.ivaavimusicproductions.workers.dev/v1",
api_key="scg_your_api_key",
)
response = client.chat.completions.create(
model="gemma-4-26b",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
2. Helper function
If you prefer not to copy the URL, use the built-in helper:
from singularity_grid import create_openai_client
client = create_openai_client(api_key="scg_your_api_key")
response = client.chat.completions.create(
model="gemma-4-26b",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
3. GridClient (full grid features)
For grid-specific features like job submission, TEE attestation, capacity checks, and pricing:
from singularity_grid import GridClient
# Public endpoints -- no auth required
grid = GridClient()
capacity = grid.capacity()
models = grid.models()
pricing = grid.pricing()
print(f"Active nodes: {capacity.active_nodes}/{capacity.total_nodes}")
for m in models:
print(f" {m.id} -- {m.sgl_node_count} nodes")
# Authenticated endpoints
grid = GridClient(api_key="scg_your_api_key")
job = grid.submit_job(
model="gemma-4-26b",
input_payload={
"messages": [{"role": "user", "content": "Analyze this data"}]
},
submitter_wallet="0xYourWallet",
submitter_chain="base",
)
print(f"Job {job.job_id}: {job.status}")
# Retrieve result and attestation
result = grid.get_job(job.job_id)
attestation = grid.get_attestation(job.job_id)
print(f"TEE verified: {attestation.verified}")
API reference
GridClient
| Method | Auth | Description |
|---|---|---|
capacity() |
No | Grid-wide capacity summary |
models() |
No | Available models with pricing and TEE info |
pricing() |
No | Pricing table for all models |
submit_job(model, input_payload, ...) |
Yes | Submit a compute job |
get_job(job_id) |
Yes | Get job status and result |
get_attestation(job_id) |
Yes | Get TEE attestation proof |
Exceptions
| Exception | When |
|---|---|
SGLError |
Base class for all SDK errors |
SGLAPIError |
Non-2xx response from the API |
SGLAuthError |
401 or 403 response |
SGLNotFoundError |
404 response |
SGLConnectionError |
Orchestrator unreachable or timeout |
Configuration
| Parameter | Default | Description |
|---|---|---|
api_key |
None |
Bearer token for authenticated endpoints |
base_url |
orchestrator URL | Override the orchestrator URL |
timeout |
60.0 |
Request timeout in seconds |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file singularity_grid-0.1.0.tar.gz.
File metadata
- Download URL: singularity_grid-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4837b389a1353bdf7746ba30a15f399f641abdc2f3f30b06f461886b02a09a4
|
|
| MD5 |
ca3ee48d05a67971a4d96279449ca67e
|
|
| BLAKE2b-256 |
ec3aa57557cbdb00c98fb77489fa8fc494254e3a8551a1f985cc453e2f8d9288
|
Provenance
The following attestation bundles were made for singularity_grid-0.1.0.tar.gz:
Publisher:
publish.yml on Singularity-Layer/sgl-network-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
singularity_grid-0.1.0.tar.gz -
Subject digest:
c4837b389a1353bdf7746ba30a15f399f641abdc2f3f30b06f461886b02a09a4 - Sigstore transparency entry: 1629033327
- Sigstore integration time:
-
Permalink:
Singularity-Layer/sgl-network-sdk@99351d836d7ac5b2e95380693abd767d0504d516 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Singularity-Layer
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@99351d836d7ac5b2e95380693abd767d0504d516 -
Trigger Event:
release
-
Statement type:
File details
Details for the file singularity_grid-0.1.0-py3-none-any.whl.
File metadata
- Download URL: singularity_grid-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7faf6035b0dcad3cfb87e1da3f6f0e4781e3aff42c9943384ff12f389bfd1d9
|
|
| MD5 |
cfe5c3c8c15a5622b87bfaa5d1e97b07
|
|
| BLAKE2b-256 |
1526cd11a8990cf7407559e62eb2614f3887b583c7d7c24f9bd2016b7062b55f
|
Provenance
The following attestation bundles were made for singularity_grid-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Singularity-Layer/sgl-network-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
singularity_grid-0.1.0-py3-none-any.whl -
Subject digest:
d7faf6035b0dcad3cfb87e1da3f6f0e4781e3aff42c9943384ff12f389bfd1d9 - Sigstore transparency entry: 1629033338
- Sigstore integration time:
-
Permalink:
Singularity-Layer/sgl-network-sdk@99351d836d7ac5b2e95380693abd767d0504d516 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Singularity-Layer
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@99351d836d7ac5b2e95380693abd767d0504d516 -
Trigger Event:
release
-
Statement type: