Skip to content

API Overview

This page covers how to connect to OpenViking and the conventions shared across all API endpoints.

Connecting to OpenViking

OpenViking supports three connection modes:

ModeUse CaseDescription
EmbeddedLocal development, single processRuns locally with local data storage
HTTPConnect to OpenViking ServerConnects to a remote server via HTTP API
CLIShell scripting, agent tool-useConnects to server via CLI commands

Embedded Mode

python
import openviking as ov

client = ov.OpenViking(path="./data")
client.initialize()

Embedded mode uses ov.conf to configure embedding, vlm, storage, and other modules. Default path: ~/.openviking/ov.conf. You can also specify the path via environment variable:

bash
export OPENVIKING_CONFIG_FILE=/path/to/ov.conf

Minimal configuration example:

json
{
  "embedding": {
    "dense": {
      "api_base": "<api-endpoint>",
      "api_key": "<your-api-key>",
      "provider": "<volcengine|openai|jina|...>",
      "dimension": 1024,
      "model": "<model-name>"
    }
  },
  "vlm": {
    "api_base": "<api-endpoint>",
    "api_key": "<your-api-key>",
    "provider": "<volcengine|openai|openai-codex|kimi|glm>",
    "model": "<model-name>"
  }
}

For provider: "openai-codex", vlm.api_key is optional once Codex OAuth is available through openviking-server init.

For full configuration options and provider-specific examples, see the Configuration Guide.

HTTP Mode

python
client = ov.SyncHTTPClient(
    url="http://localhost:1933",
    api_key="your-key",
    agent_id="my-agent",
    timeout=120.0,
)
client.initialize()

When url is not explicitly provided, the HTTP client automatically loads connection info from ovcli.conf. This config file is shared between the HTTP client and CLI. Default path: ~/.openviking/ovcli.conf. You can also specify the path via environment variable:

bash
export OPENVIKING_CLI_CONFIG_FILE=/path/to/ovcli.conf
json
{
  "url": "http://localhost:1933",
  "api_key": "your-key",
  "account": "acme",
  "user": "alice",
  "agent_id": "my-agent"
}
FieldDescriptionDefault
urlServer address(required)
api_keyAPI keynull (no auth)
accountDefault account header for tenant-scoped requestsnull
userDefault user header for tenant-scoped requestsnull
agent_idAgent identifier headernull
timeoutHTTP request timeout in seconds60.0
outputDefault output format: "table" or "json""table"

See the Configuration Guide for details.

Local files in HTTP mode

  • CLI, SyncHTTPClient, and AsyncHTTPClient automatically upload local files and directories before calling the server API.
  • Raw HTTP callers do not get this convenience layer. When using curl or another HTTP client, upload the file with POST /api/v1/resources/temp_upload first, then call the target API with the returned temp_file_id.
  • For local directories in raw HTTP mode, zip the directory first and upload the .zip file; the server does not accept direct host directory paths.
  • POST /api/v1/resources accepts remote URLs directly, but does not accept direct host filesystem paths such as ./doc.md or /tmp/doc.md.

Direct HTTP (curl)

bash
curl http://localhost:1933/api/v1/fs/ls?uri=viking:// \
  -H "X-API-Key: your-key"

CLI Mode

The CLI connects to an OpenViking server and exposes all operations as shell commands. The CLI also loads connection info from ovcli.conf (shared with the HTTP client).

Basic Usage

bash
openviking [global options] <command> [arguments] [command options]

Global Options (must be placed before the command name)

OptionDescription
--output, -oOutput format: table (default), json
--versionShow CLI version

Example:

bash
openviking -o json ls viking://resources/

Lifecycle

Embedded Mode

python
import openviking as ov

client = ov.OpenViking(path="./data")
client.initialize()

# ... use client ...

client.close()

HTTP Mode

python
import openviking as ov

client = ov.SyncHTTPClient(url="http://localhost:1933")
client.initialize()

# ... use client ...

client.close()

Authentication

See Authentication Guide for full details.

  • X-API-Key header: X-API-Key: your-key
  • Bearer header: Authorization: Bearer your-key
  • If no API key is configured on the server, authentication is skipped.
  • The /health endpoint never requires authentication.

Response Format

All HTTP API responses follow a unified format:

Success

json
{
  "status": "ok",
  "result": { ... },
  "time": 0.123
}

The top-level status describes whether the HTTP API request succeeded. Some successful operations return domain-level status fields inside result, such as "status": "success", "status": "accepted", or task states. Those fields are not API transport errors.

Error

json
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "message": "Resource not found: viking://resources/nonexistent/"
  },
  "time": 0.01
}

HTTP errors always use the top-level error envelope. Synchronous processing failures, such as resource parsing or synchronous reindex failures, are returned as non-2xx responses with status="error" and an error object. Clients should not look for result.status="error" to detect request failure.

Request validation failures, including malformed JSON, missing required fields, and invalid parameter values, return HTTP 400 with error.code="INVALID_ARGUMENT". The response never uses FastAPI's raw {"detail": ...} error format; when field-level validation information is available, it is exposed under error.details.validation_errors.

Python HTTP SDKs (SyncHTTPClient and AsyncHTTPClient) raise the corresponding OpenVikingError subclass for this envelope. For example, PROCESSING_ERROR is raised as ProcessingError.

CLI Output Format

Table Mode (default)

List data is rendered as tables; non-list data falls back to formatted JSON:

bash
openviking ls viking://resources/
# name          size  mode  isDir  uri
# .abstract.md  100   420   False  viking://resources/.abstract.md

JSON Mode (--output json)

All commands output formatted JSON matching the API response result structure:

bash
openviking -o json ls viking://resources/
# [{ "name": "...", "size": 100, ... }, ...]

The default output format can be set in ovcli.conf:

json
{
  "url": "http://localhost:1933",
  "output": "json"
}

Script Mode (-o json)

Compact JSON with status wrapper (when --compact is true, which is the default), suitable for scripting:

Success

json
{"ok": true, "result": ...}

Error

json
{"ok": false, "error": {"code": "NOT_FOUND", "message": "Resource not found", "details": {}}}

Special Cases

  • String results (read, abstract, overview): printed directly as plain text
  • None results (mkdir, rm, mv): no output

Exit Codes

CodeMeaning
0Success
1General error
2Configuration error
3Connection error

Error Codes

CodeHTTP StatusDescription
OK200Success
INVALID_ARGUMENT400Invalid parameter
INVALID_URI400Invalid Viking URI format
NOT_FOUND404Resource not found
ALREADY_EXISTS409Resource already exists
UNAUTHENTICATED401Missing or invalid API key
PERMISSION_DENIED403Insufficient permissions
RESOURCE_EXHAUSTED429Rate limit exceeded
FAILED_PRECONDITION412Precondition failed
CONFLICT409Operation conflicts with an in-progress task or existing state
DEADLINE_EXCEEDED504Operation timed out
UNAVAILABLE503Service unavailable
PROCESSING_ERROR500Resource or semantic processing failed
INTERNAL500Internal server error
UNIMPLEMENTED501Feature not implemented
EMBEDDING_FAILED500Embedding generation failed
VLM_FAILED500VLM call failed
SESSION_EXPIRED410Session no longer exists

API Endpoints

System

MethodPathDescription
GET/healthHealth check (no auth)
GET/readyReadiness probe (no auth)
GET/metricsPrometheus metrics export
GET/api/v1/system/statusSystem status
POST/api/v1/system/waitWait for processing

Resources

MethodPathDescription
POST/api/v1/resources/temp_uploadUpload local file for raw HTTP resource / pack import
POST/api/v1/resourcesAdd resource
POST/api/v1/skillsAdd skill
POST/api/v1/pack/exportExport .ovpack
POST/api/v1/pack/importImport .ovpack

File System

MethodPathDescription
GET/api/v1/fs/lsList directory
GET/api/v1/fs/treeDirectory tree
GET/api/v1/fs/statResource status
POST/api/v1/fs/mkdirCreate directory
DELETE/api/v1/fsDelete resource
POST/api/v1/fs/mvMove resource

Content

MethodPathDescription
GET/api/v1/content/readRead full content (L2)
GET/api/v1/content/abstractRead abstract (L0)
GET/api/v1/content/overviewRead overview (L1)
GET/api/v1/content/downloadDownload raw file bytes
POST/api/v1/content/writeUpdate an existing file and refresh semantics/vectors
POST/api/v1/content/reindexRebuild semantic/vector index for existing content
MethodPathDescription
POST/api/v1/search/findSemantic search
POST/api/v1/search/searchContext-aware search
POST/api/v1/search/grepPattern search
POST/api/v1/search/globFile pattern matching

Relations

MethodPathDescription
GET/api/v1/relationsGet relations
POST/api/v1/relations/linkCreate link
DELETE/api/v1/relations/linkRemove link

Sessions

MethodPathDescription
POST/api/v1/sessionsCreate session
GET/api/v1/sessionsList sessions
GET/api/v1/sessions/{id}Get session
GET/api/v1/sessions/{id}/contextGet assembled session context
DELETE/api/v1/sessions/{id}Delete session
POST/api/v1/sessions/{id}/commitCommit session
POST/api/v1/sessions/{id}/extractExtract memories from a session
POST/api/v1/sessions/{id}/messagesAdd message
POST/api/v1/sessions/{id}/usedRecord contexts / skills actually used
GET/api/v1/sessions/{id}/archives/{archive_id}Get a specific session archive

Tasks

MethodPathDescription
GET/api/v1/tasks/{task_id}Get background task status
GET/api/v1/tasksList background tasks

Observer

MethodPathDescription
GET/api/v1/observer/queueQueue status
GET/api/v1/observer/vikingdbVikingDB status
GET/api/v1/observer/modelsModels status (VLM / embedding / rerank)
GET/api/v1/observer/lockLock subsystem status
GET/api/v1/observer/retrievalRetrieval subsystem status
GET/api/v1/observer/systemSystem status

Debug

MethodPathDescription
GET/api/v1/debug/healthQuick health check
GET/api/v1/debug/vector/scrollPaginated vector record inspection
GET/api/v1/debug/vector/countCount vector records

Admin (Multi-tenant)

MethodPathDescription
POST/api/v1/admin/accountsCreate workspace + first admin (ROOT)
GET/api/v1/admin/accountsList workspaces (ROOT)
DELETE/api/v1/admin/accounts/{account_id}Delete workspace (ROOT)
POST/api/v1/admin/accounts/{account_id}/usersRegister user (ROOT, ADMIN)
GET/api/v1/admin/accounts/{account_id}/usersList users (ROOT, ADMIN)
DELETE/api/v1/admin/accounts/{account_id}/users/{user_id}Remove user (ROOT, ADMIN)
PUT/api/v1/admin/accounts/{account_id}/users/{user_id}/roleChange user role (ROOT)
POST/api/v1/admin/accounts/{account_id}/users/{user_id}/keyRegenerate user key (ROOT, ADMIN)

Released under the Apache-2.0 License.