Official Cogspace SDK — add a knowledge layer to any AI agent
Project description
cogspace
Official Python SDK for Cogspace — add a persistent knowledge layer to any AI agent.
Install
pip install cogspace
Quickstart
from cogspace import Cogspace
cog = Cogspace(api_key="cs-...")
# Get a space-scoped client
space = cog.space("my-agent")
# Search
results = space.search("retry logic with backoff")
for r in results.results:
print(r.file_path, r.score)
# Write knowledge
space.write("expertise/retry.md", """
# Retry patterns
Always use exponential backoff with jitter.
""")
# Read the hot layer (always-injected context)
context = space.hot_layer()
# Memory
space.write_memory("Currently working on the payment service refactor.")
memory = space.read_memory()
Async
from cogspace import AsyncCogspace
async def main():
cog = AsyncCogspace(api_key="cs-...")
space = await cog.space("my-agent")
results = await space.search("retry logic")
await cog.aclose()
Or use as a context manager:
async with AsyncCogspace(api_key="cs-...") as cog:
space = await cog.space("my-agent")
await space.write("expertise/notes.md", "...")
API Reference
Cogspace(api_key, base_url, timeout, max_retries)
| Method | Description |
|---|---|
cog.space(name_or_id) |
Get a space client |
cog.list_spaces() |
List all your spaces |
cog.create_space(name) |
Create a new space |
SpaceClient
| Method | Description |
|---|---|
space.search(query, mode, top_k, layer) |
Hybrid / vector / keyword search |
space.read(path) |
Read a file by path |
space.write(path, content, metadata) |
Write or update a file |
space.list(folder) |
List files in a folder |
space.read_memory() |
Read memory.md |
space.write_memory(content, confidence) |
Update memory.md |
space.read_context() |
Read memory/user/ context files |
space.hot_layer() |
Get full hot layer injection string |
space.graph_traverse(path, depth, rel_type) |
Traverse knowledge graph |
space.health() |
Space health and storage stats |
Errors
All exceptions inherit from CogspaceError:
from cogspace.exceptions import AuthError, NotFoundError, RateLimitError
try:
space.search("query")
except AuthError:
print("Invalid API key")
except NotFoundError:
print("Space not found")
Get an API key
Sign in at platform.cogspace.ai, go to Settings → API keys, and create a key.
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
cogspace-0.1.0.tar.gz
(7.7 kB
view details)
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
cogspace-0.1.0-py3-none-any.whl
(10.0 kB
view details)
File details
Details for the file cogspace-0.1.0.tar.gz.
File metadata
- Download URL: cogspace-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8234278b71469a9ad7725983f834ecc1941db704960b3e1fa4f6a5f1f9dc6ab9
|
|
| MD5 |
793d38bc679517e8395b303c51c1af70
|
|
| BLAKE2b-256 |
96dbfe8f4e1c5fc408267bc1723d777463d7e258c192286777b36a3fdf596d16
|
File details
Details for the file cogspace-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cogspace-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.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cf202ccddba85475ae42ffd8f53c23151a425f1b6a73b18e655da2cf613f9f2
|
|
| MD5 |
349c6ebf21d18096cbbab5269fc98092
|
|
| BLAKE2b-256 |
ecb72d97c5615eb415f6577bfca78bbaceca7b9aaf8d362fa20336323b9e186f
|