Skip to main content
singularity-grid is the official Python client for SGL Grid. Submit inference to TEE-verified nodes, check capacity, read pricing, and verify attestation — from one package.

Install

pip install singularity-grid
# OpenAI compatibility helper:
pip install "singularity-grid[openai]"

Quick start

from singularity_grid import GridClient

grid = GridClient()                       # public endpoints — no auth
cap = grid.capacity()
print(f"Active nodes: {cap.active_nodes}/{cap.total_nodes}")
for m in grid.models():
    print(f"  {m.id}{m.sgl_node_count} nodes")

Configuration

ParameterDefaultDescription
api_keyNoneBearer token for authenticated endpoints
base_urlorchestrator URLOverride the orchestrator URL
timeout60.0Request timeout in seconds
grid = GridClient(api_key="scg_your_api_key", timeout=30.0)

Submit a job + verify attestation

from singularity_grid import GridClient

grid = GridClient(api_key="scg_your_api_key")

job = grid.submit_job(
    model="<model-id>",
    input_payload={"messages": [{"role": "user", "content": "Analyze this data"}]},
    submitter_wallet="<your-wallet>",
    submitter_chain="base",          # or "solana"
)

result = grid.get_job(job.job_id)
attestation = grid.get_attestation(job.job_id)
print(f"TEE verified: {attestation.verified}, type: {attestation.tee_type}")

OpenAI-compatible usage

# Direct
from openai import OpenAI
client = OpenAI(base_url="https://grid.x402compute.cc/v1", api_key="scg_your_api_key")

# Or via the bundled helper (no need to copy the URL)
from singularity_grid import create_openai_client
client = create_openai_client(api_key="scg_your_api_key")

resp = client.chat.completions.create(
    model="<model-id>",
    messages=[{"role": "user", "content": "Hello from the grid"}],
)
print(resp.choices[0].message.content)

API reference

MethodAuthDescription
capacity()NoGrid-wide capacity summary
models()NoAvailable models with pricing + TEE info
pricing()NoPricing table for all models
submit_job(model, input_payload, ...)YesSubmit a compute job
get_job(job_id)YesJob status + result
get_attestation(job_id)YesTEE attestation proof
create_openai_client(api_key=...)Helper returning a configured OpenAI client

Exceptions

ExceptionWhen
SGLErrorBase class for all SDK errors
SGLAPIErrorNon-2xx response
SGLAuthError401 / 403 (bad or missing key)
SGLNotFoundError404
SGLConnectionErrorOrchestrator unreachable / timeout
from singularity_grid import GridClient, SGLAuthError, SGLNotFoundError

try:
    grid.get_job("nonexistent")
except SGLNotFoundError:
    ...
except SGLAuthError:
    ...
See Confidential inference for attestation details and the TypeScript SDK for the JS/TS client.