Skip to main content

Golem SDK

Python SDK for creating Golem extensions. This includes adding new channels, providers, and other long-running processes.

Installation

This package is available on PyPI:

pip install golem-agent-sdk

Usage

Import as golem. Golem injects GOLEM_URL and GOLEM_TOKEN into the process. The wire protocol is docs/extensions.md.

The smallest extension registers, prints a line, and stays alive until it is stopped:

from golem import Extension


def hello(client, stop):
    print("hello world")
    stop.wait()


Extension.from_env("echo").task(hello).run()

Provider Extensions

A provider is a model backend. Golem calls your process for chat, structured output, and/or embeddings. Implement at least one of those methods; run() binds a loopback callback, registers, and heartbeats.

from golem import Extension, Message, Provider


class Echo(Provider):
    def chat(self, model, messages, tools=None) -> Message:
        return Message(role="assistant", content=messages[-1].content)


Extension.from_env("golem-echo").provider("echo", Echo()).run()

The id passed to provider() is the name used in Golem conf (default_model.provider or memory.embedding.provider). Override chat_structured or embed to advertise those routes. An embeddings-only class can omit chat:

class Embed(Provider):
    def embed(self, model, texts):
        return [[0.1] for _ in texts]


Extension.from_env("golem-embed").provider("local-embed", Embed()).run()

Channel Extensions

A channel feeds messages into Golem (Telegram, CLI, and so on). task() runs your loop; client.send() posts a turn and returns the assistant reply. capability() advertises the channel.

from golem import Extension


def cli(client, stop):
    while not stop.is_set():
        line = input("you: ").strip()
        if not line:
            continue
        print(client.send("local", "cli", line))


(
    Extension.from_env("golem-cli")
    .capability({"kind": "channel", "id": "cli"})
    .task(cli)
    .run()
)

post_turn and stream_turn expose the same flow as SSE events (log, done, error).

Packaging Extensions

Ship the extension as a Python package. Golem takes the name and description from pyproject.toml, then runs the first [project.scripts] entry whose name matches the package:

[project]
name = "golem-openrouter"
description = "OpenRouter provider for Golem"

[project.scripts]
golem-openrouter = "golem_openrouter:main"

Development

Using uv is strongly recommended. From this directory:

uv sync --dev
uv run pytest

From the Golem repo root, make test-sdk runs ruff and pytest.

Releasing

PyPI publishes happen from this repo on sdk-v* tags:

  1. Bump the version in pyproject.toml.
  2. Commit that change on main.
  3. Tag the same version and push the tag:
git tag sdk-v0.1.2
git push origin sdk-v0.1.2

The tag must match pyproject.toml (sdk-v0.1.2 for version = "0.1.2"). GitHub Actions builds from sdk/ and uploads to PyPI.

Release files for golem-agent-sdk 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for golem-agent-sdk 0.1.2
File Size Uploaded
golem_agent_sdk-0.1.2.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for golem-agent-sdk 0.1.2
File Interpreter ABI Platform
golem_agent_sdk-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / golem_agent_sdk-0.1.2.tar.gz

Download URL golem_agent_sdk-0.1.2.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f0eb01c6e8d324e679e231017f790f6fd3f54a3ad8aa71342fbb697e8ade0ef7
BLAKE2b-256 checksum
How to use checksums
8ea5b7021758cb122f6c514e9ae91579fde554712c05dac7b337315a7fb322bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / golem_agent_sdk-0.1.2-py3-none-any.whl

Download URL golem_agent_sdk-0.1.2-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96036d73bae272c90f86603a1bd600fe4469b751d632ed75df9882bd6e9eca83
BLAKE2b-256 checksum
How to use checksums
4ad50cf787dd1a67a42b44fc65fbd3add1534433783757a24c1bc5704b96d117
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page