ghostlink-client
Python client for a Ghostlink Studio API server — the OpenAI-compatible REST endpoints (/v1/chat/completions, /v1/completions, /v1/embeddings, /v1/models) plus Ghostlink's native /api/* surface (workers, sessions, settings, metrics, and real token-by-token streaming chat).
Install
pip install -e ./sdks/python
(Not yet published to PyPI — install from a local checkout or a Git URL.)
Quick start
from ghostlink_client import GhostlinkClient
client = GhostlinkClient("http://127.0.0.1:8003", api_key="<your api key>")
resp = client.chat.completions.create(
model="llama3.2:3b",
messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(resp.content)
The API key is the one Ghostlink generates on first run (printed at startup, persisted to api_key.txt by default — see GHOSTLINK_API_KEY_PATH).
OpenAI-compatible endpoints
# Chat
resp = client.chat.completions.create(model="llama3.2:3b", messages=[...])
# Legacy text completion
resp = client.completions.create(model="llama3.2:3b", prompt="Once upon a time")
print(resp.text)
# Embeddings
resp = client.embeddings.create(model="nomic-embed-text", input="hello world")
# List models
for m in client.list_models():
print(m.id)
Real streaming chat
/v1/chat/completions accepts a stream field but Ghostlink doesn't act on it yet — real token-by-token streaming is only available today through Ghostlink Studio's native chat endpoint:
for chunk in client.stream_chat("Tell me a short story"):
if chunk.error:
print(f"\n[error: {chunk.token}]")
elif not chunk.done:
print(chunk.token, end="", flush=True)
Cluster, metrics, settings
client.workers.list()
client.workers.discover() # UDP broadcast + mDNS sweep
client.workers.connect("192.168.1.42", 8003)
client.metrics() # JSON snapshot
client.metrics_prometheus() # Prometheus exposition format
client.settings.get()
client.settings.update(inference_backend="ollama")
Error handling
from ghostlink_client import GhostlinkAPIError, GhostlinkAuthError, GhostlinkConnectionError
try:
client.chat.completions.create(model="x", messages=[])
except GhostlinkAuthError as err:
print("bad or missing API key:", err)
except GhostlinkAPIError as err:
print(f"server rejected the request: HTTP {err.status_code}: {err.message}")
except GhostlinkConnectionError as err:
print("could not reach the server:", err)
Context manager
with GhostlinkClient("http://127.0.0.1:8003", api_key=key) as client:
client.health()
Custom inference backends
If the server has a custom backend plugin registered (see backend_plugin.rs / GHOSTLINK_OPENAI_COMPAT_BASE_URL in the main project), select it the same way as any built-in backend:
client.settings.update(inference_backend="my_custom_backend")
resp = client.chat.completions.create(model="anything", messages=[...])
Development
pip install -e ".[test]"
pytest
Metadata
Release files for ghostlink-client 2.6.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 | Provenance | Actions |
|---|---|---|---|---|
| ghostlink_client-2.6.0.tar.gz | 11.3 kB | Without provenance | Details for ghostlink_client-2.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ghostlink_client-2.6.0-py3-none-any.whl | Python 3 | none | any | Details for ghostlink_client-2.6.0-py3-none-any.whl |
Total release size: 21.6 kB
Release files / ghostlink_client-2.6.0.tar.gz
| Download URL | ghostlink_client-2.6.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b532f899cbea16f094c7aeb4a7d623103952fe15bb9fc313d7d7c663e37a50f
|
|
BLAKE2b-256 checksum How to use checksums |
dc925c310c12f2fe16732ae17861dd414eefc7f32f1331cc33901994e7e43a80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Release files / ghostlink_client-2.6.0-py3-none-any.whl
| Download URL | ghostlink_client-2.6.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0f7035abab2ca4f759a429f2478350b676caa8fa4a71382cc5c07820029ffb0
|
|
BLAKE2b-256 checksum How to use checksums |
90d02338ceb4079a83d329b8889871d9bac520d8bc99a96d630f4289964523a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Security for ghostlink-client 2.6.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.