docs/images/agents/en/sdk.md
Run the following command to install OpenViking:
pip install openviking --upgrade --force-reinstall
Refer to the standard write example from GitHub and fill in the API Key and domain automatically:
from openviking_sdk import SyncHTTPClient, TextPart
url = "{{OPENVIKING_BASE_URL}}"
api_key = "{{OPENVIKING_API_KEY}}"
client = SyncHTTPClient(
url=url,
api_key=api_key,
timeout=120.0,
)
client.initialize()
Refer to the standard resource write example from GitHub and fill in the API Key and domain automatically:
file_path = "[TODO]your-file-path"
resource_to = "[TODO]your-resource-path" # e.g. viking://resources
reason = "[TODO]your-reason" # e.g. External API documentation
# Reuse the initialized client.
client.add_resource(
path=file_path,
to=resource_to,
options={"reason": reason},
)
Refer to the memory write example from GitHub and fill in the API Key and domain automatically:
text = "[TODO]your-message-text" # e.g. I am a developer
# Reuse the initialized client.
session = client.create_session()
session_id = session["session_id"]
client.add_message(
session_id=session_id,
role="user",
parts=[TextPart(text=text)],
)
result = client.commit_session(session_id=session_id)