Skip to main content

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:

  1. Explicit constructor arguments
  2. Environment variables such as OPENVIKING_URL, OPENVIKING_API_KEY, OPENVIKING_ACCOUNT, OPENVIKING_USER, OPENVIKING_ACTOR_PEER_ID, and OPENVIKING_TIMEOUT
  3. ovcli.conf, either from OPENVIKING_CLI_CONFIG_FILE or 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 URL
  • api_key: root key or user key
  • account: optional account override, usually only needed with a root key
  • user: optional user override, usually only needed with a root key
  • user_id: legacy alias for user
  • actor_peer_id: optional actor peer override
  • agent_id: legacy alias for actor_peer_id
  • event_hooks: optional httpx.AsyncClient event hooks, such as async request or response hooks

Compatibility notes:

  • user_id and agent_id are still accepted for legacy callers
  • actor_peer_id and agent_id cannot 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",
)

Request-Scoped Actor Peer

Applications can reuse one initialized, credential-bound client while selecting the active actor peer for each request:

from openviking_sdk import (
    SyncHTTPClient,
    use_actor_peer,
)

client = SyncHTTPClient(
    url="http://127.0.0.1:1933",
    api_key="your-user-key",
)
client.initialize()

with use_actor_peer("assistant-a"):
    memories = client.find("deployment preference")

The scope is isolated with Python ContextVar, so concurrent async tasks and sync calls dispatched through the SDK worker loop do not overwrite each other. Nested scopes restore the previous actor peer automatically.

This scope does not change authentication or tenant ownership. Account and user identity remain bound to the API key or OAuth credential. Use a separate credential-bound client for each OpenViking user, and derive actor peer values only from authenticated application state. The server applies the actor peer only to endpoints that accept an actor-peer view; session APIs remain user-scoped.

Quick Start: Sync Client

from openviking_sdk import SyncHTTPClient

client = SyncHTTPClient(
    url="http://127.0.0.1:1933",
    api_key="your-user-key",
)
client.initialize()

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)

client.close()

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",
    )
    await client.initialize()

    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")
client.initialize()
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")
client.initialize()

result = client.add_resource(
    "/path/to/notes.md",
    to="viking://resources/demo-notes",
    reason="knowledge import",
    wait=True,
)
print(result)

To ingest content without VLM semantic understanding, pass processing_mode="vectors_only". This writes/syncs the resource tree and vectorizes current files, but does not generate or refresh .abstract.md / .overview.md.

result = client.add_resource(
    "/path/to/notes.md",
    to="viking://resources/demo-notes",
    processing_mode="vectors_only",
    wait=True,
)

Filesystem Operations

from openviking_sdk import SyncHTTPClient

client = SyncHTTPClient(url="http://127.0.0.1:1933", api_key="your-user-key")
client.initialize()

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")
client.initialize()

result = client.find("hello", limit=5)
print(result)

Image search uses the same methods. Pass a local path, bytes, data URI, HTTP URL, or viking:// URI with image. The server must use a multimodal embedding model.

result = client.find(image="/path/to/photo.png", limit=5)
result = client.search("similar poster", image="viking://resources/poster.png")

Admin Operations

If you connect with a root key, the SDK also exposes admin APIs such as:

  • admin_create_account
  • admin_register_user
  • admin_list_accounts
  • admin_list_users
  • admin_regenerate_key
  • admin_delete_account

Example:

from openviking_sdk import SyncHTTPClient

root_client = SyncHTTPClient(
    url="http://127.0.0.1:1933",
    api_key="your-root-key",
)
root_client.initialize()

result = root_client.admin_create_account(
    account_id="demo-account",
    admin_user_id="demo-admin",
    seed="demo-admin-seed",
)
print(result)

root_client.admin_register_user(
    account_id="demo-account",
    user_id="alice",
    role="user",
    seed="alice-seed",
    user_config={
        "add_targets": {
            "resource_uri": "viking://user/resources/project-a",
            "skill_uri": "viking://user/skills",
        }
    },
)

root_client.admin_regenerate_key(
    account_id="demo-account",
    user_id="alice",
    seed="alice-new-seed",
)

admin_create_account also accepts user_config with the same shape. These fields initialize server-side user config; ordinary add calls still just omit to / parent / target_uri and let the server resolve defaults. When seed is set, the returned API key is derived from sha256(user_id + "\0" + seed); omit it for random key generation.

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")
client.initialize()

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@0.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:

  1. Merge SDK changes.
  2. Create and push a tag like python-sdk@0.1.3.
  3. GitHub Actions builds sdk/python.
  4. GitHub Actions publishes openviking-sdk to PyPI.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openviking_sdk-0.1.7.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openviking_sdk-0.1.7-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file openviking_sdk-0.1.7.tar.gz.

File metadata

  • Download URL: openviking_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 43.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for openviking_sdk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 90b1c3025c9b1192e549421b8d181855bb722e57e14f785a1a31a5eec4151bed
MD5 8a4bc425a7f6e25bd16b039b6353952f
BLAKE2b-256 c24bcbd1a866deb35f9b8986904260d8fb99d769e7f47b91bbb2ca85b8e36341

See more details on using hashes here.

Provenance

The following attestation bundles were made for openviking_sdk-0.1.7.tar.gz:

Publisher: python-sdk-release.yml on volcengine/OpenViking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openviking_sdk-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: openviking_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for openviking_sdk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f4bc373ce2f4ebf93216b3fbc8c33b8e3c39e852e451ade1b95b102886652847
MD5 505e47be7368d6876f6bcb646391481b
BLAKE2b-256 ba1578fe7434da25b3327cea1e7682cb20a8532e9a94faf33832b5560ae7d8f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for openviking_sdk-0.1.7-py3-none-any.whl:

Publisher: python-sdk-release.yml on volcengine/OpenViking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page