This page is the Python shape. The JavaScript SDK takes the same settings
as plain options on the constructor rather than an
SDKConfig object, so the
TypeScript tabs differ in shape, not just in syntax. Three differences worth
knowing before you read them:-
Three keys do nothing here.
storage_path,cache_backendandsession_timeout_minutesare accepted and ignored, so one config object can be shared between the two SDKs. The cache is in memory, so there is no path to point at and no backend to swap.log_levelis ignored too, butloggeris real: see below. -
The stream endpoint moves.
grpc_host,grpc_portandgrpc_use_tlsare options oninstance.listen(), not on the client. - Timeouts and the retry policy are real, and their defaults match Python exactly: connect 5s, read 30s, write 10s, 3 attempts, backoff base 1s capped at 10s.
-
loggerworks. Pass(level, message) => voidand every diagnostic the SDK emits routes there instead of the console. JavaScript has no global logging framework whose level there would be to set, so the SDK takes the sink directly rather than a level plus a framework.
Overview
The Synap SDK is configured via theSDKConfig object, which controls storage, credentials, caching, timeouts, retries, and logging. Sensible defaults are provided for all fields, so you only need to override what matters for your environment.
SDKConfig Reference
Field Reference
At a glance,SDKConfig accepts:
storage_path: directory for the local SQLite cache and transient state. Defaults to an SDK-managed directory. The API key is never written here; it is read fromSYNAP_API_KEY(or theapi_key=constructor argument) on each start. See Storage Path.cache_backend:"sqlite"(default) for on-disk caching, orNoneto disable it. See Cache Backend.session_timeout_minutes: how long a session stays active before re-authentication. Default30, valid range5to1440. See Session Timeout.timeouts: a TimeoutConfig for per-operation network timeouts.retry_policy: a RetryPolicy for transient-error retries, orNoneto disable retries.log_level: logging verbosity, one of"DEBUG","INFO","WARNING"(default),"ERROR". See Log Level.grpc_host/grpc_port/grpc_use_tls: endpoint overrides for the real-time anticipation stream. Only needed for self-hosted or local deployments. See gRPC Connection.
Full parameter reference →
The complete field list, types, accepted ranges, and the
configure() rules (including the logger override).TimeoutConfig
Controls how long the SDK waits for individual network operations.float
default:"5.0"
Maximum time in seconds to establish a TCP connection to Synap Cloud. Increase this if your network has high latency or unreliable DNS resolution.
float
default:"30.0"
Maximum time in seconds to wait for a complete response after sending a request. This should be higher than your expected query latency. For compaction of very large conversations, you may need to increase this.
float
default:"10.0"
Maximum time in seconds to upload request data. Relevant for large batch ingestion payloads. Increase if you are sending very large documents.
float
default:"60.0"
Maximum idle time in seconds for the SDK’s real-time event stream (used by
sdk.instance.listen()). If no data is received within this window, the stream is considered stale and reconnected. Increase for low-traffic instances where events are infrequent.gRPC Connection
These three fields point the real-time anticipation stream (instance.listen()) at a specific endpoint. Leave them unset for Synap Cloud; the defaults are correct and TLS is on.
string | None
default:"None"
Hostname for the real-time stream.
None uses the Synap Cloud endpoint. Set this when running against a self-hosted or local Synap deployment.int | None
default:"None"
Port for the real-time stream, commonly
50051 for local deployments. None uses the Synap Cloud default.bool | None
default:"None"
None uses the transport default (TLS on). Set to False only for a plaintext endpoint, such as a local container. Never disable TLS against a remote host.These fields affect only the streaming transport. REST calls use the separate
api_base_url. Point both at the same deployment or the SDK will authenticate against one environment and stream against another.Caching and async ingestion
Ingestion is asynchronous: memories from a turn are not immediately retrievable. If you fetch right after writing, an empty result is a legitimate response, and withcache_backend="sqlite" the local read cache will hold onto that empty result for its TTL, so later turns keep seeing nothing.
For live agents that ingest and retrieve in the same loop, disable the local read cache:
RetryPolicy
Controls automatic retry behavior for transient errors.int
default:"3"
The total number of attempts including the initial request. Setting this to
1 means no retries (only the initial attempt). Setting to 5 means up to 4 retries after the initial failure.float
default:"1.0"
The base delay in seconds for exponential backoff. The delay for attempt N is
backoff_base * 2^(N-2), capped at backoff_max. A higher base means longer waits between retries, which is gentler on rate-limited endpoints.float
default:"10.0"
The maximum delay in seconds between retry attempts. Prevents exponential backoff from growing unbounded for high
max_attempts values.bool
default:"True"
When enabled, adds a random component to the backoff delay. This prevents the “thundering herd” problem where multiple SDK instances retry at the exact same time after a shared failure. Strongly recommended for production deployments.
List[str]
The list of error type names that should be automatically retried. Only errors in this list trigger the retry policy. All other errors are raised immediately.For
RateLimitError, the SDK uses the server-provided retry_after_seconds value instead of the exponential backoff calculation.Storage Path
Thestorage_path directory holds the local SQLite cache and transient state. The SDK sets restrictive filesystem permissions on this directory on creation. The API key is never stored here; it comes from SYNAP_API_KEY or the api_key= constructor argument.
When to Override
Credentials
The SDK reads the API key on every start. There are exactly two sources:
The SDK uses your API key for every call. The instance ID is resolved automatically from the API key; you do not need to set it manually.
Cache Backend
SQLite (Default, Recommended)
ttl_seconds in response metadata) and evicts stale entries automatically.
Benefits:
- Sub-millisecond cache hits for repeated context fetches
- Persists across SDK restarts (within TTL)
- Automatic size management and TTL-based eviction
- Zero configuration (SQLite is bundled with Python)
Disabled
conversation.context.fetch() call goes to Synap Cloud. Use this when:
- You need guaranteed freshness on every call
- You are running in a read-only filesystem (and cannot use a RAM-backed path)
- You are debugging cache-related issues
Session Timeout
Log Level
The SDK uses Python’s standardlogging module. The log level controls verbosity of the synap logger.
log_level is accepted and ignored in JavaScript, so a shared config object
still works. Filter by the level argument in your own sink instead: it is
one of debug, info, warn, error.Using configure()
The configure() method allows you to update individual configuration fields after constructing the SDK but before calling initialize().
Environment Variables
A small set of connection settings can come from the environment. Everything else must be set in code viaSDKConfig; pass it to the constructor (or configure()) before initialize().
Explicit configuration always wins. Each variable is consulted only when the corresponding
SDKConfig field is left as None, so setting a value in code makes the environment variable inert.Common Configurations
Development
Development
Verbose logging, short timeouts, and aggressive retries for fast feedback during development.
Production
Production
Conservative timeouts, standard retries with jitter, minimal logging, and persistent storage.
Testing
Testing
Isolated storage, disabled caching for deterministic tests, no retries for immediate failure feedback.
High-Throughput
High-Throughput
Optimized for batch ingestion workloads with generous timeouts, higher retry limits, and long sessions.
Full Configuration Example
Putting it all together with explicit values for every field:Next Steps
Initializing the SDK
Learn the full initialization lifecycle with configuration.
API Error Reference
Understand how retry policies interact with the error hierarchy.
Production Checklist
Review configuration best practices before going live.
Ingesting Memories
Start ingesting data with your configured SDK.
JavaScript: client options
Pass these tonew SynapClient({ ... }):
string
Your Synap API key. Falls back to
SYNAP_API_KEY when omitted.string
API base URL. Falls back to
SYNAP_BASE_URL, then the Synap Cloud default. Set it when you run a self-hosted deployment.string
Optional. Resolved from the API key during
initialize() when omitted. Falls back to SYNAP_INSTANCE_ID.object
{ connect, read, write } in seconds. Defaults to 5s connect and 30s read.object
{ maxAttempts, backoffBase, backoffMax, backoffJitter }. Defaults to 3 attempts with jittered exponential backoff.boolean
default:"false"
Keep the connection warm with a periodic health ping. Worth it for a long-lived process, pointless in serverless where the container is frozen between requests.
function
Supply your own
fetch. Useful for testing or for routing through a proxy.