Skip to main content

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 completion
  • chat.stream(...) — SSE streaming iterator
  • models.list(featured=True) — list available models (350+)
  • namespaces.{create,list,get,update,delete} — memory namespace management
  • memory.{create_frame,list_frames,context,semantic,search,bridge,consolidate} — memory operations
  • knowledge_graph.{create_entity,create_relation,query} — graph operations
  • sessions.{create,list,get} — session management

Full OpenAPI spec: https://switchy.build/api/v1/openapi.json

License

MIT

Project details


Download files

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

Source Distribution

switchy_sdk-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

switchy_sdk-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

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

Hashes for switchy_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c80c99f1df1c2f79655b801eb2582ed30929f963bd3ea31ad70f5202e0a06f0c
MD5 b6c45d15e1650dcc6bf79297d7ee4efa
BLAKE2b-256 899ba5e05b9b4254a24a88e86b033cfe4ca809208a4aa53c8dcd31cf64962aa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for switchy_sdk-0.1.0.tar.gz:

Publisher: publish-sdks.yml on Switchy-AI/switchy

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

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

Hashes for switchy_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f40269182c1eabcc3de7fa4ecd39257b99241ba26fc950e23f9bdc42273cb59
MD5 c5221d604473af0fde7941018f5746b1
BLAKE2b-256 2895a5ec263e93470f584f14157fcf8329b48795ccd40f00e98f0f9708ed76f6

See more details on using hashes here.

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

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