Python SDK for Snowcell inference
Project description
Snowcell Python SDK
Python SDK for the Snowcell API.
This is a lightweight alternative to the OpenAI SDK that can be integrated into your applications.
Install
pip install snowcell
Quickstart
import os
from snowcell import Snowcell
client = Snowcell(api_token=os.environ["SNOWCELL_API_TOKEN"])
res = client.chat.create(
model="Meditron3-8B",
messages=[{"role": "user", "content": "Say hello."}],
max_tokens=50,
)
print(res.choices[0].message.content)
Streaming
from snowcell import Snowcell
client = Snowcell(api_token="YOUR_API_TOKEN")
for event in client.chat.stream(
model="Meditron3-8B",
messages=[{"role": "user", "content": "Write one short sentence."}],
max_tokens=40,
):
# Each `event` is a dict parsed from SSE "data:" lines
print(event)
API
Client
from snowcell import Snowcell
client = Snowcell(
api_token="...", # or set SNOWCELL_API_TOKEN env var
)
Chat
res = client.chat.create(
model="Meditron3-8B",
messages=[{"role": "user", "content": "Explain attention in one line."}],
max_tokens=80,
)
print(res.choices[0].message.content)
Async:
res = await client.chat.acreate(model="Meditron3-8B", messages=[{"role":"user","content":"Hi"}], max_tokens=80)
Streaming:
for evt in client.chat.stream(model="Meditron3-8B", messages=[{"role":"user","content":"Hi"}], max_tokens=80):
print(evt)
Completions
res = client.completions.create(
model="Meditron3-8B",
prompt="Hello world!",
max_tokens=32,
)
print(res.choices[0].text)
Async:
res = await client.completions.acreate(model="Meditron3-8B", prompt="Hello world!", max_tokens=32)
Configuration
You can set these environment variables instead of passing args:
SNOWCELL_API_TOKEN– bearer token for authenticationSNOWCELL_INFERENCE_BASE_URL– override the inference origin (e.g.,http://127.0.0.1:11434for local testing)
The SDK sends User-Agent: snowcell-python/<version> and uses timeouts tuned for LLMs: connect=5s, write=30s, read=300s.
Errors
The SDK raises SnowcellError for 4xx/5xx responses with server details included. Common cases:
401/403– check your token / project permissions422– request validation error (inspect the server message)429– rate limited; retry after the indicated delay5xx– transient server error; try again later
Versioning
- Initial public release: 0.1.0 (chat, completions; sync/async; streaming for chat)
- Backwards-compatible fixes → patch bump (
0.1.x) - New features/endpoints → minor bump (
0.x.y)
See CHANGELOG.md.
License
MIT – see LICENSE.
Project details
Release history Release notifications | RSS feed
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 snowcell-0.1.0.tar.gz.
File metadata
- Download URL: snowcell-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f40bf537b12cd496ca9093c0c3dedb56c6eb0883e6932047885e8765b724fd20
|
|
| MD5 |
5636ff265060f7678fac51dd4f36a915
|
|
| BLAKE2b-256 |
907142cb9f69b798de810ad19d18d3ff2230994d62190eafaf53ee3029581fbb
|
File details
Details for the file snowcell-0.1.0-py3-none-any.whl.
File metadata
- Download URL: snowcell-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4b1f075a781951f692d74c7ef808ae4edbc15d1147eeeddcb43b060d246bbf1
|
|
| MD5 |
c106874ed0f837bc896bef85fed814c8
|
|
| BLAKE2b-256 |
d64c6d9cc566579d3a3c8240e163215da3b6bb320c5454f3e7de555aaa293d8d
|