Lightweight Python HTTP SDK for OpenViking
Project description
openviking-sdk
Lightweight Python HTTP SDK for OpenViking.
openviking-sdk is the small package for users who only need to call an existing OpenViking server over HTTP. It avoids the heavier local-runtime, server, and CLI dependencies from the main openviking package.
Installation
pip install openviking-sdk
Requirements:
- Python 3.10+
- A reachable OpenViking HTTP server, for example
http://127.0.0.1:1933
Package Name vs Import Name
- PyPI package name:
openviking-sdk - Python import name:
openviking_sdk
from openviking_sdk import AsyncHTTPClient, SyncHTTPClient
Configuration Sources
You can configure the SDK in three ways, with this precedence:
- Explicit constructor arguments
- Environment variables such as
OPENVIKING_URL,OPENVIKING_API_KEY,OPENVIKING_ACCOUNT,OPENVIKING_USER,OPENVIKING_ACTOR_PEER_ID, andOPENVIKING_TIMEOUT ovcli.conf, either fromOPENVIKING_CLI_CONFIG_FILEor the default path~/.openviking/ovcli.conf
This means existing setups that relied on ovcli.conf continue to work after the SDK split.
Authentication Model
Most deployments use API key authentication.
Common client fields:
url: OpenViking server base URLapi_key: root key or user keyaccount: optional account override, usually only needed with a root keyuser: optional user override, usually only needed with a root keyuser_id: legacy alias foruseractor_peer_id: optional actor peer overrideagent_id: legacy alias foractor_peer_id
Compatibility notes:
user_idandagent_idare still accepted for legacy callersactor_peer_idandagent_idcannot be passed together
Example:
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(
url="http://127.0.0.1:1933",
api_key="your-user-or-root-key",
)
If you are using a root key and want to act as a specific tenant user:
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(
url="http://127.0.0.1:1933",
api_key="your-root-key",
account="demo-account",
user="demo-user",
)
Quick Start: Sync Client
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(
url="http://127.0.0.1:1933",
api_key="your-user-key",
)
healthy = client.health()
print("health:", healthy)
session = client.create_session("demo-session")
print("session:", session)
client.session("demo-session").add_message("user", "hello from sdk")
context = client.session("demo-session").get_session_context(token_budget=4096)
print("context:", context)
Quick Start: Async Client
import asyncio
from openviking_sdk import AsyncHTTPClient
async def main() -> None:
client = AsyncHTTPClient(
url="http://127.0.0.1:1933",
api_key="your-user-key",
)
healthy = await client.health()
print("health:", healthy)
session = await client.create_session("demo-session-async")
print("session:", session)
session_client = client.session("demo-session-async")
await session_client.add_message("user", "hello from async sdk")
context = await session_client.get_session_context(token_budget=4096)
print("context:", context)
await client.close()
asyncio.run(main())
Common Operations
Create a Session
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(url="http://127.0.0.1:1933", api_key="your-user-key")
result = client.create_session("demo-session")
print(result)
Add a Resource from a Local File
add_resource handles file upload for local paths automatically.
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(url="http://127.0.0.1:1933", api_key="your-user-key")
result = client.add_resource(
"/path/to/notes.md",
to="viking://resources/demo-notes",
reason="knowledge import",
wait=True,
)
print(result)
Filesystem Operations
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(url="http://127.0.0.1:1933", api_key="your-user-key")
client.mkdir("viking://resources/demo-dir")
print(client.ls("viking://resources"))
print(client.read("viking://resources/demo-dir/example.md"))
Retrieval
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(url="http://127.0.0.1:1933", api_key="your-user-key")
result = client.find("hello", limit=5)
print(result)
Admin Operations
If you connect with a root key, the SDK also exposes admin APIs such as:
admin_create_accountadmin_register_useradmin_list_accountsadmin_list_usersadmin_regenerate_keyadmin_delete_account
Example:
from openviking_sdk import SyncHTTPClient
root_client = SyncHTTPClient(
url="http://127.0.0.1:1933",
api_key="your-root-key",
)
result = root_client.admin_create_account(
account_id="demo-account",
admin_user_id="demo-admin",
)
print(result)
Error Handling
The SDK maps server-side error codes to Python exceptions.
from openviking_sdk import OpenVikingError, SyncHTTPClient
client = SyncHTTPClient(url="http://127.0.0.1:1933", api_key="your-user-key")
try:
print(client.read("viking://resources/not-exists.md"))
except OpenVikingError as exc:
print(type(exc).__name__, exc)
Relationship to openviking
Use openviking-sdk when you want:
- the HTTP client only
- the smallest dependency footprint
- a package suitable for application-side integration
Use openviking when you want:
- the full Python package
- local runtime integrations
- server entrypoints
- compatibility imports that re-export the HTTP clients
Development
Install from source:
cd sdk/python
pip install -e .
Build distributions:
cd sdk/python
python -m build
The SDK version is derived from git tags with this format:
python-sdk/v0.1.3
That tag namespace is independent from the main package release tags such as:
v0.3.26
Release
The repository is configured so SDK releases can be driven by SDK-only tags.
Typical flow:
- Merge SDK changes.
- Create and push a tag like
python-sdk/v0.1.3. - GitHub Actions builds
sdk/python. - GitHub Actions publishes
openviking-sdkto PyPI.
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 openviking_sdk-0.1.2.tar.gz.
File metadata
- Download URL: openviking_sdk-0.1.2.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
673370c7df89fa7f7c6708e05251450e1cb736c5b94d1ba87ff18cd40d51eff8
|
|
| MD5 |
395d7d6d35880c77b7ac0b2f8f827346
|
|
| BLAKE2b-256 |
b0d21638f2d9592a87e2350a5d663db46b2bab8fff57b79f688a3ed63da069a1
|
Provenance
The following attestation bundles were made for openviking_sdk-0.1.2.tar.gz:
Publisher:
python-sdk-release.yml on volcengine/OpenViking
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openviking_sdk-0.1.2.tar.gz -
Subject digest:
673370c7df89fa7f7c6708e05251450e1cb736c5b94d1ba87ff18cd40d51eff8 - Sigstore transparency entry: 1907767219
- Sigstore integration time:
-
Permalink:
volcengine/OpenViking@02f06488f3a2d5057db81033f781776359f6486d -
Branch / Tag:
refs/tags/python-sdk/v0.1.2 - Owner: https://github.com/volcengine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdk-release.yml@02f06488f3a2d5057db81033f781776359f6486d -
Trigger Event:
push
-
Statement type:
File details
Details for the file openviking_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: openviking_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.9 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 |
9e4c719d0f3f84dd686ffce45b80e8730c815ce6e4da94b94416307c679caa5f
|
|
| MD5 |
5a9097d4d733772891090d8d0e7b988d
|
|
| BLAKE2b-256 |
2dc7f21f7899a8902bbc9b2f8bfc6f60eb0b64addf44fc71b76f0c72241183f6
|
Provenance
The following attestation bundles were made for openviking_sdk-0.1.2-py3-none-any.whl:
Publisher:
python-sdk-release.yml on volcengine/OpenViking
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openviking_sdk-0.1.2-py3-none-any.whl -
Subject digest:
9e4c719d0f3f84dd686ffce45b80e8730c815ce6e4da94b94416307c679caa5f - Sigstore transparency entry: 1907767335
- Sigstore integration time:
-
Permalink:
volcengine/OpenViking@02f06488f3a2d5057db81033f781776359f6486d -
Branch / Tag:
refs/tags/python-sdk/v0.1.2 - Owner: https://github.com/volcengine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdk-release.yml@02f06488f3a2d5057db81033f781776359f6486d -
Trigger Event:
push
-
Statement type: