Official Python SDK for the Graphn API: custom-model lifecycle, secrets, and OpenAI-compatible inference.
Project description
graphn — Python SDK
Official Python SDK for the Graphn API: custom-model lifecycle, secrets management, and OpenAI-compatible inference (chat completions, model listing, text-to-speech) — all behind a single typed client.
The SDK is generated from the public OpenAPI 3.1 spec served at
https://cp.graphn.ai/openapi.yaml. Inference calls delegate to the
official openai Python SDK
so you get full feature parity (tools, streaming, structured outputs,
etc.) for free.
Install
pip install graphn
Requires Python 3.10+.
Quickstart
from graphn import Client
client = Client(api_key="gn_...", workspace_id="ws_abc")
secret = client.secrets.create(name="hf-token", value="hf_...")
model = client.custom_models.create(
name="my-llama",
huggingface_model_id="meta-llama/Llama-3-8B",
hf_token_secret_id=secret.id,
)
client.custom_models.wait_until_ready(model.id, timeout=900)
resp = client.chat.completions.create(
model=model.name,
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
The async variant is identical:
import asyncio
from graphn import AsyncClient
async def main() -> None:
async with AsyncClient(api_key="gn_...", workspace_id="ws_abc") as client:
async for model in client.custom_models.list():
print(model.id, model.status)
asyncio.run(main())
What's in here
| Module | Purpose |
|---|---|
graphn.Client |
Sync entrypoint |
graphn.AsyncClient |
Async entrypoint |
client.custom_models |
Create / list / get / delete / wake / refresh / wait_until_ready |
client.secrets |
CRUD for HuggingFace tokens and similar workspace secrets |
client.chat.completions |
OpenAI-compatible chat completions (delegates to openai) |
client.models |
List models available to the workspace |
client.tts |
Text-to-speech |
client.imported_models |
Discover and test connections to imported (BYO) inference hosts |
Configuration
| Argument | Default | Notes |
|---|---|---|
api_key |
GRAPHN_API_KEY env var |
Bearer token starting with gn_. Required. |
workspace_id |
GRAPHN_WORKSPACE_ID env var |
Injected into control-plane paths and X-Workspace-Id. |
base_url |
https://cp.graphn.ai |
Control-plane host. |
inference_url |
https://model.graphn.ai |
Inference host (passed to the underlying OpenAI client). |
timeout |
60.0 seconds |
Per-request HTTPX timeout. |
max_retries |
2 |
Retries on connect / 5xx / 429. |
Generating clients in other languages
The OpenAPI spec is the source of truth. To generate a client in another language, point your favorite generator at:
https://cp.graphn.ai/openapi.yaml
We test compatibility with openapi-generator 6.0+, openapi-python-client
0.21+, and oapi-codegen 2.0+.
Development
python -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
ruff check src tests
pytest
To regenerate the typed transport layer from the upstream spec:
./scripts/regenerate.sh
License
Apache 2.0 — see LICENSE.
Project details
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 graphn-0.1.0.tar.gz.
File metadata
- Download URL: graphn-0.1.0.tar.gz
- Upload date:
- Size: 47.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
134bc63d585b450c1e200fd4dc9cdd59ed3f96205801dac57299fe99656702cb
|
|
| MD5 |
6ea38d042e84cd6cce70f83d099ae113
|
|
| BLAKE2b-256 |
2299bbb62fb3551605b45602d5ed0a21c68a63279add3c083b7ebfd16b5db9d7
|
Provenance
The following attestation bundles were made for graphn-0.1.0.tar.gz:
Publisher:
release.yml on voltagepark/graphn-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphn-0.1.0.tar.gz -
Subject digest:
134bc63d585b450c1e200fd4dc9cdd59ed3f96205801dac57299fe99656702cb - Sigstore transparency entry: 1376435348
- Sigstore integration time:
-
Permalink:
voltagepark/graphn-sdk-python@64e481d5623249f589ba60bf67d698f278b9499d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/voltagepark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64e481d5623249f589ba60bf67d698f278b9499d -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: graphn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 101.7 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 |
a1b5226f1106f71bdb2a8fa7b59d80808784b93c1216699b202f063b6b45f3bc
|
|
| MD5 |
5b5db36538c1806fe1430dd6f3a6aafe
|
|
| BLAKE2b-256 |
50c686fc9a558580cef790436eec898646194797cba086b9eb727f988bf43daf
|
Provenance
The following attestation bundles were made for graphn-0.1.0-py3-none-any.whl:
Publisher:
release.yml on voltagepark/graphn-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphn-0.1.0-py3-none-any.whl -
Subject digest:
a1b5226f1106f71bdb2a8fa7b59d80808784b93c1216699b202f063b6b45f3bc - Sigstore transparency entry: 1376435360
- Sigstore integration time:
-
Permalink:
voltagepark/graphn-sdk-python@64e481d5623249f589ba60bf67d698f278b9499d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/voltagepark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64e481d5623249f589ba60bf67d698f278b9499d -
Trigger Event:
push
-
Statement type: