Official Python SDK for the Switchy AI memory and chat API
Project description
switchy-sdk
Official Python SDK for the Switchy AI memory, knowledge-graph, and multi-model chat API.
Install
pip install switchy-sdk
Quick start
from switchy import Switchy
client = Switchy(api_key="switchy_...")
response = client.chat.complete(
model="anthropic/claude-sonnet-4",
message="Summarise my recent project notes",
memory={"enabled": True, "extractMemories": True},
)
print(response["message"]["content"])
Streaming
for chunk in client.chat.stream(
model="openai/gpt-5",
message="Write a haiku about memory",
):
if chunk.get("type") == "token":
print(chunk.get("content", ""), end="", flush=True)
Async
import asyncio
from switchy import AsyncSwitchy
async def main():
async with AsyncSwitchy(api_key="switchy_...") as client:
res = await client.chat.complete(
model="anthropic/claude-sonnet-4",
message="Hello",
)
print(res["message"]["content"])
asyncio.run(main())
Memory
# Create a namespace
client.namespaces.create(name="my-project")
# Store a memory frame
client.memory.create_frame(
"my-project",
content="User prefers dark mode and TypeScript",
metadata={"source": "onboarding"},
)
# Contextual retrieval
relevant = client.memory.context("my-project", query="user preferences", limit=5)
Knowledge graph
client.knowledge_graph.create_entity(
"my-project", name="AuthService", type="service"
)
client.knowledge_graph.create_relation(
"my-project", source="AuthService", target="User", type="authenticates"
)
Error handling
from switchy import Switchy, SwitchyError, RateLimitError
try:
client.chat.complete(model="openai/gpt-5", message="hi")
except RateLimitError as e:
print(f"Rate limited, retry in {e.retry_after}s (limit={e.limit})")
except SwitchyError as e:
print(f"API error: {e.code} — {e}")
API reference
chat.complete(...)— single-turn completionchat.stream(...)— SSE streaming iteratormodels.list(featured=True)— list available models (350+)namespaces.{create,list,get,update,delete}— memory namespace managementmemory.{create_frame,list_frames,context,semantic,search,bridge,consolidate}— memory operationsknowledge_graph.{create_entity,create_relation,query}— graph operationssessions.{create,list,get}— session management
Full OpenAPI spec: https://switchy.build/api/v1/openapi.json
License
MIT
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 switchy_sdk-0.1.0.tar.gz.
File metadata
- Download URL: switchy_sdk-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c80c99f1df1c2f79655b801eb2582ed30929f963bd3ea31ad70f5202e0a06f0c
|
|
| MD5 |
b6c45d15e1650dcc6bf79297d7ee4efa
|
|
| BLAKE2b-256 |
899ba5e05b9b4254a24a88e86b033cfe4ca809208a4aa53c8dcd31cf64962aa8
|
Provenance
The following attestation bundles were made for switchy_sdk-0.1.0.tar.gz:
Publisher:
publish-sdks.yml on Switchy-AI/switchy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
switchy_sdk-0.1.0.tar.gz -
Subject digest:
c80c99f1df1c2f79655b801eb2582ed30929f963bd3ea31ad70f5202e0a06f0c - Sigstore transparency entry: 1338362059
- Sigstore integration time:
-
Permalink:
Switchy-AI/switchy@8f1869f680136d718d6d8be6ae4bf8f7397a4f66 -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/Switchy-AI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdks.yml@8f1869f680136d718d6d8be6ae4bf8f7397a4f66 -
Trigger Event:
push
-
Statement type:
File details
Details for the file switchy_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: switchy_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 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 |
6f40269182c1eabcc3de7fa4ecd39257b99241ba26fc950e23f9bdc42273cb59
|
|
| MD5 |
c5221d604473af0fde7941018f5746b1
|
|
| BLAKE2b-256 |
2895a5ec263e93470f584f14157fcf8329b48795ccd40f00e98f0f9708ed76f6
|
Provenance
The following attestation bundles were made for switchy_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish-sdks.yml on Switchy-AI/switchy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
switchy_sdk-0.1.0-py3-none-any.whl -
Subject digest:
6f40269182c1eabcc3de7fa4ecd39257b99241ba26fc950e23f9bdc42273cb59 - Sigstore transparency entry: 1338362208
- Sigstore integration time:
-
Permalink:
Switchy-AI/switchy@8f1869f680136d718d6d8be6ae4bf8f7397a4f66 -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/Switchy-AI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdks.yml@8f1869f680136d718d6d8be6ae4bf8f7397a4f66 -
Trigger Event:
push
-
Statement type: