Sokel Plugin SDK — Python
Write Sokel plugins in Python. The contract lives in a
language-neutral manifest.yml; sokel-gen turns it into pydantic models and typed registration
functions, and the SDK handles registration, transport, credentials, files, heartbeats and
reconnects.
async def issues_list(ctx: Ctx, in_: IssuesListIn) -> IssuesListOut:
issues = await client.list_issues(in_.project, in_.state)
return IssuesListOut(issues=issues, count=len(issues))
on_issues_list(p, issues_list)
A typo in in_.project is a red squiggle in your editor, not a failed call in production — there is
no dict["key"] anywhere in your code.
Install
pip install sokel-plugin-sdk
go install github.com/sokel-dev/sokel-plugin-sdk/cmd/sokel-gen@latest # the generator
sokel-gen is a single binary (written in Go) used only at generation time; running a plugin
does not need it.
Four steps
sokel-gen init -lang python ./my-plugin
cd my-plugin
pip install -r requirements.txt
sokel-gen generate . # manifest.yml → sokel_gen.py
python main.py
- Declare —
manifest.yml: operations, events, credentials, authentication. Format: docs/manifest.md, or runsokel-gen docs. - Generate —
sokel-gen generate .writessokel_gen.py: anXxxIn/XxxOutmodel pair and anon_xxx(p, fn)per operation; a payload model and atrigger_xxx(ctx, event_id, payload)per event. - Implement — handler signatures are fully concrete.
async defor a plain function, both work. - Connect —
asyncio.run(p.run()). A plugin dials out: no inbound port, no public IP, no firewall hole.
What you can do
| Task | How |
|---|---|
| Read credentials | credential(ctx) → the generated Credential model |
| Read an input file's bytes | await ctx.fetch(in_.file) |
| Produce a file | await ctx.upload(name, mime, data), or await ctx.upload_file(path) for large files |
| Stream output | out.text(...) frame by frame for humans, out.vars(Out(...)) for downstream nodes |
| Push an event | await trigger_message(ctx, event_id, MessageEvent(...)) |
| Long-running event source | p.register_source(id, label, fn); loop while not ctx.stopping.is_set() |
| Handle a platform-relayed webhook | p.register_webhook(fn), return ok() / text(401, "...") |
| Collaborative authentication | p.register_auth(start=…, poll=…, submit=…) |
| Refresh a session credential | await ctx.update_credential({"session": "…"}) |
| Report runtime state | ctx.report_status("auth_required", "…") |
upload_file(path) streams from disk: memory stays at one chunk (1 MiB) regardless of file size.
Anything above a few hundred megabytes should use it — upload(bytes) reads the whole file into
memory first, and the symptom of that is a container mysteriously killed by the OOM reaper.
Configuration
The SDK reads SOKEL_-prefixed environment variables:
| Variable | Required | Meaning |
|---|---|---|
SOKEL_ENDPOINT |
yes | nats://broker:4222, or an https:// platform URL to discover the broker from |
SOKEL_TOKEN |
yes | Access-group token (skp_…) identifying plugin + workspace |
SOKEL_NATS_TOKEN |
no | Broker-level auth |
SOKEL_NATS_CA |
no | Custom CA bundle for tls:// brokers |
SOKEL_INSTANCE_ID |
no | Pin a replica identity (otherwise derived from the token and cached on disk) |
SOKEL_REGION |
no | Region label for the replica |
Credentials are never stored by the plugin: the platform injects the resolved fields with each call.
Example
examples/kitchen-sink covers every shape — each field type, files,
streaming, events, webhooks, collaborative auth — and the Python and Node implementations share one
declaration.
cd examples/kitchen-sink/python
pip install -r requirements.txt
SOKEL_ENDPOINT=nats://localhost:4222 SOKEL_TOKEN=skp_xxx python main.py
Developing this SDK
uv venv && uv pip install -e '.[dev]'
python -m pytest -q
License
Apache-2.0.
Metadata
Release files for sokel-plugin-sdk 0.7.3
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 |
|---|---|---|---|---|
| sokel_plugin_sdk-0.7.3.tar.gz | 36.1 kB | With provenance | Details for sokel_plugin_sdk-0.7.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sokel_plugin_sdk-0.7.3-py3-none-any.whl | Python 3 | none | any | Details for sokel_plugin_sdk-0.7.3-py3-none-any.whl |
Total release size: 68.7 kB
Release files / sokel_plugin_sdk-0.7.3.tar.gz
| Download URL | sokel_plugin_sdk-0.7.3.tar.gz |
|---|---|
| Size | 36.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7111f720dac4f295382c065b9efb605e47a4dfea14785e6184308a55115ed0b
|
|
BLAKE2b-256 checksum How to use checksums |
9daf1e13d937b34e91db077e7c7514bbef467ac8b58f455b343eae964b9d3ffb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 3, 2026.
Transparency logRelease files / sokel_plugin_sdk-0.7.3-py3-none-any.whl
| Download URL | sokel_plugin_sdk-0.7.3-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6023f16c9d4d157d14b6e36a255481118aad576efb88650b926ea08114b78808
|
|
BLAKE2b-256 checksum How to use checksums |
140ea290b9ce8f1a40d014d257348dd65f372161741d04dfcce3570cd356f897
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 3, 2026.
Transparency logSecurity for sokel-plugin-sdk 0.7.3
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
Both files in this release have been uploaded with provenance metadata.
Attestation for sokel_plugin_sdk-0.7.3.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 Oct 3, 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.