JavaScript and TypeScript are served by the same npm package. TypeScript is not a separate SDK and needs no separate installation: types ship with the package.
In Synap Core: install the same package. Instead of an API key, set
SYNAP_BASE_URL=http://127.0.0.1:8000 to point the SDK at your own server. A local server needs no API key and no instance id. See the Core quickstart.Python SDK
Requirements
- Python 3.11+: the SDK uses modern Python features including
asyncio, type hints, and structural pattern matching - pip 21.0+, Poetry 1.2+, or uv 0.4+ for package management
- An active Synap account: Sign up at synap.maximem.ai
Install
The package name uses a hyphen (
maximem-synap) but the import name uses an underscore (maximem_synap). Install with pip install maximem-synap, then from maximem_synap import MaximemSynapSDK in your code.httpx: async HTTP client used by the SDKpydantic: data validation and settings managementcryptography: credential handling- Additional transport dependencies pulled in automatically; no extra install needed.
Local search model
After a compaction, the SDK can search the earlier turns of a conversation on your machine, and match a fetch to context it already holds. Without the local search model it matches words. To also match meaning, across many languages, install the extra:onnxruntime, tokenizers, huggingface_hub and numpy. The model, about 135 MB, is downloaded once into ~/.synap/models. The download starts in the background when you call initialize(), so no request waits for it. Set SYNAP_MODELS_DIR to use another folder (Python 0.6.6 and later). Python 0.5.11 and later. To turn it off, set history_search_model=None.
Configure
Set your API key. See environment variables for all options.Verify
Run this script to verify your installation and connectivity:verify_synap.py
Async-first design
The Python SDK is async-first. All SDK methods that interact with Synap Cloud are On a B2C instance, drop
async and must be called with await inside an async function.If you’re integrating with a synchronous codebase, use asyncio.run() to bridge the gap:customer_id.For frameworks that already run an event loop (FastAPI, Sanic, aiohttp), use the SDK directly without wrapping.JavaScript and TypeScript SDK
One package serves both:@maximem/synap-js-sdk. Type definitions ship with it, so TypeScript is typed the moment you install and needs no extra step.
Requirements
- Node.js 20+
- An active Synap account: Sign up at synap.maximem.ai
Install
The model itself, about 135 MB, is downloaded into
~/.synap/models the first time it is needed, not at install. Set SYNAP_MODELS_DIR to use another folder. It is skipped outside Node.js.
To leave all four out, for example to keep a serverless bundle small:
instance.listen() fails with a SynapError saying it could not open the stream because @grpc/grpc-js is missing. If you use the stream, do not pass --omit=optional.
Writing plain JavaScript, not TypeScript?
Writing plain JavaScript, not TypeScript?
Nothing changes. There is no separate JavaScript build, no
typescript
dependency to add, no tsconfig.json to create, and no compile step.
npm install and you are done.The bundled type definitions are inert at runtime, so they cost you nothing.
Most editors read them anyway, which means you get autocomplete and inline
parameter help in a plain .js file without opting into TypeScript.Use require() or import depending on how your project is written; see
module format. The examples below are labelled ts, but
they use no type annotations, so they are valid JavaScript exactly as written.
Swap the import line for a require() if your project is CommonJS. The one
section that is genuinely TypeScript-only is
exported types, which you can skip.Configure
Set your API key. See environment variables for all options.client_id and instance_id are resolved from the key when you call initialize(), so you do not need to plumb them separately.
Verify
Check the install and your credentials in one go:verify-synap.mjs
Module format
The package ships both ES modules and CommonJS, with types for each. Import it whichever way your project is written:Because a dual-format dependency graph can hand you two copies of the same class, every error also carries a stable
.code string. Branch on error.code rather than instanceof when you cannot guarantee a single copy. See typed error handling.Where it runs
The anticipation stream needs raw TCP and
node:http2, which Edge runtimes and Workers do not provide. Importing the SDK there is safe: the stream lives behind the @maximem/synap-js-sdk/grpc subpath and is only ever loaded lazily, so it never enters an Edge bundle.
Bun and Deno have both, so the stream is plausible on each, but bidirectional streaming has not been verified there.
tsconfig requirements
None specific to this package. It is verified against TypeScript 5.7 and 7.0 withmoduleResolution set to node, node16, nodenext and bundler, and it typechecks under strict, exactOptionalPropertyTypes and noUncheckedIndexedAccess.
A minimal configuration:
tsconfig.json
Next: using it
Installation is done. For the client surface, the cross-scope fetch, LLM tool definitions, typed errors and the anticipation stream, see Using the JavaScript SDK.Vercel AI SDK Middleware
If your application uses the Vercel AI SDK, the@maximem/synap-vercel-adk middleware wraps any compatible model and injects Synap context automatically, with no changes to your existing generateText / streamText calls.
ai >=3.0.0 as a peer dependency. TypeScript types are included.
It runs on the Next.js Edge Runtime for context fetching and memory writes, which use
fetch only. You do not need to pin export const runtime = "nodejs" for those.The one exception is the optional gRPC anticipation stream, which needs @grpc/grpc-js and therefore a Node.js runtime. It is loaded lazily, so importing the package on Edge is safe; only enabling the stream requires Node.js.Environment variables
The SDK reads configuration from environment variables. This is the recommended approach for production deployments.All languages
Your API key for SDK authentication. Generated in the Dashboard: navigate to your instance and click Generate API Key. Starts with
synap_.Records which instance you are on. Optional; the dashboard gives you it alongside the API key so you can paste both in one go. Starts with
inst_.Logging verbosity for the SDK. Accepts standard logging levels:
DEBUG, INFO, WARNING, ERROR, CRITICAL. Defaults to INFO.Multiple instances
The CLI can writeSYNAP_API_KEY_<NAME> and SYNAP_INSTANCE_ID_<NAME> with api-keys create --write-env --env-suffix <NAME>. Those suffixed names are a .env convention; the SDK reads only SYNAP_API_KEY and SYNAP_INSTANCE_ID. Choose one pair before starting each process:
API base URL. Set it when you run a self-hosted deployment; otherwise leave it unset and the SDK uses Synap Cloud.
Optional. Skips one identity round trip during
initialize(). Resolved from the API key when omitted.Anticipation stream
Only needed when you use the anticipation stream, and only when your deployment is not the default.Setting them
Credential storage
The SDK reads the API key fromSYNAP_API_KEY (or the api_key / apiKey constructor argument) on every startup. There is no on-disk credential cache; the key lives wherever your secrets manager or environment configuration puts it.
Troubleshooting
Python: ImportError: No module named 'maximem_synap'
Python: ImportError: No module named 'maximem_synap'
Verify the package is installed in your active Python environment:If using a virtual environment, make sure it’s activated. If using Poetry, prefix commands with
poetry run.JS/TS: No Synap API key found
JS/TS: No Synap API key found
The client could not resolve a credential. Set
SYNAP_API_KEY in the
environment, or pass apiKey to the constructor:JS/TS: Cannot find module '@grpc/grpc-js'
JS/TS: Cannot find module '@grpc/grpc-js'
The anticipation stream needs
@grpc/grpc-js and @grpc/proto-loader.
They are optional dependencies that npm installs by default, so this error
means they were left out: you installed with --omit=optional (or set
omit=optional in .npmrc), or npm could not install them on your
platform. Reinstall
@maximem/synap-js-sdk without omitting optional dependencies, then run
instance.listen() again. instance.listen() is the only call that needs
them; everything else works without.JS/TS: the stream will not open on Edge or Workers
JS/TS: the stream will not open on Edge or Workers
It cannot. The stream needs raw TCP and
node:http2, which those runtimes
do not provide. Context fetching and memory writes work there normally; only
the stream is unavailable. See where it runs.JS/TS: requests are going to the wrong deployment
JS/TS: requests are going to the wrong deployment
Check
SYNAP_BASE_URL. When it is unset the SDK uses Synap Cloud, and an
explicit baseUrl in the constructor beats the environment. If you point
the HTTP base at one deployment, point SYNAP_GRPC_HOST at the same one.Connection refused or timeout during initialization
Connection refused or timeout during initialization
Check that:
- Your outbound network connectivity to Synap Cloud is permitted.
- If behind a corporate proxy, configure
HTTPS_PROXYin your environment. - Your
SYNAP_API_KEYis correct and the key is active in the dashboard.
API key rejected
API key rejected
If the SDK reports an authentication failure:
- Confirm
SYNAP_API_KEYstarts withsynap_and is not wrapped in quotes in your shell - Check the key is still active in the Dashboard (Instance → API Keys)
- If the key was revoked, generate a new one and update your
.envor secrets manager
Next steps
Authentication
Configure API key authentication, multiple keys per instance, and key rotation.
Integration
Connect Synap to your application framework and infrastructure.
SDK Initialization
Explore all SDK initialization options, including custom credential providers.