sgrs-client
Python HTTP client for the SGRS REST API.
Installation
pip install sgrs-client
Quick Start
Async Usage
import asyncio
from sgrs_client import create_client
async def main():
client = create_client(base_url='http://localhost:3000')
# Get a scope
response = await client.get_scope('my-scope')
if response.ok:
print(f"Scope: {response.data}")
else:
print(f"Error: {response.error}")
await client.close()
asyncio.run(main())
Sync Usage
from sgrs_client import create_client
client = create_client(base_url='http://localhost:3000')
# Get a scope
response = client.get_scope_sync('my-scope')
if response.ok:
print(f"Scope: {response.data}")
else:
print(f"Error: {response.error}")
client._sync_client.close()
Context Manager
import asyncio
from sgrs_client import create_client
async def main():
async with create_client(base_url='http://localhost:3000') as client:
response = await client.get_scope('my-scope')
print(response.data if response.ok else response.error)
asyncio.run(main())
Features
- Type-safe: All types validated with Pydantic models
- Async-first: Full async/await support with fallback to sync
- Schema validation: Runtime validation using models derived from Zod schemas
- Error handling: Structured error responses with detailed information
- Timeouts: Configurable request timeouts
- SSL verification: Configurable SSL certificate verification
Scopes API
# Get a scope
response = await client.get_scope('scope-id')
# Create a scope
response = await client.create_scope(
name='My Scope',
tag='tag',
state='active',
score=0.5,
cycles=0
)
# Update a scope
response = await client.update_scope('scope-id', score=0.75)
Models API
from sgrs_client import ConnectModelRequest
# Connect a model provider
request = ConnectModelRequest(
provider='openai',
api_key='sk-...',
model='gpt-4'
)
response = await client.connect_model(request)
# Get a connected model
response = await client.get_model('mh_xxx')
Finality API
# Get finality status
response = await client.get_finality_status('scope-id')
# Get finality certificate
response = await client.get_finality_certificate('scope-id', round=1)
Documentation (Sphinx)
From the repository root, pnpm docs:py runs scripts/docs-py.sh, which maintains packages/client-py/.venv so installs work on PEP-668–managed Pythons:
pnpm docs:py
Generated HTML: packages/client-py/docs/_build/html/ (Sphinx sources in packages/client-py/docs/).
License
MIT - see LICENSE file
Release files for sgrs-client 0.0.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 | |
|---|---|---|---|
| sgrs_client-0.0.0.tar.gz | 17.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sgrs_client-0.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.9 kB
Release files / sgrs_client-0.0.0.tar.gz
| Download URL | sgrs_client-0.0.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e40cd5e9b68dd23b67cce5132b1d26e5e36da3f014fd7af4a30436a8fb56aa4
|
|
BLAKE2b-256 checksum How to use checksums |
2a2e4f2a06f679dca71756d41f215862c6804b85b0c934f2a5c74cab66f4448f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 1, 2026.
Transparency logRelease files / sgrs_client-0.0.0-py3-none-any.whl
| Download URL | sgrs_client-0.0.0-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8d97bc964ff6c15098c7c41b31a10a5edf7de6d44d1fdf2d9a6a96447405efb
|
|
BLAKE2b-256 checksum How to use checksums |
2a5beb4f96864495490cee9672548756a1a7225b8189fd9f92e99f52b28001bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 1, 2026.
Transparency log