> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Maximem Synap is a managed memory layer for AI agents: it ingests conversations and documents, extracts structured memory, and returns scoped context to the agent at retrieval time.
> The Python and JavaScript/TypeScript SDKs are the supported way to use Synap. Write integration code with SDK calls, not raw HTTP requests.
> Start with the Quickstart: https://docs.maximem.ai/getting-started/quickstart.md. Every SDK method is documented in the SDK reference: https://docs.maximem.ai/sdk-reference/overview.md.
> For requests about adding Vity memory to OpenClaw, Hermes, an MCP client, or a browser, start with the Vity Quickstart: https://docs.maximem.ai/vity/quickstart.md.

# SDK Configuration

> Customize SDK behavior for your environment.

> [!NOTE]
>
> **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. Four differences worth
> knowing before you read them:
>
> * **Four Python-only settings do nothing here:** `storage_path`,
>   `cache_backend`, `session_timeout_minutes` and `log_level`. `configure()`
>   accepts and ignores them. The constructor does not list them, so TypeScript
>   flags them in an object literal.
> * **The stream endpoint moves.** It is set on
>   [`instance.listen({ host, port, use_tls })`](https://docs.maximem.ai/sdk-reference/instance/listen),
>   or with `SYNAP_GRPC_HOST`, `SYNAP_GRPC_PORT` and `SYNAP_GRPC_USE_TLS`, not
>   on the client.
> * **The retry policy and the read timeout work,** with the same defaults as
>   Python: read 30s, 3 attempts, backoff base 1s capped at 10s. `connect` and
>   `write` are accepted but have no effect in JavaScript.
> * **`logger`.** Pass `(level, message) => void` and the client's warnings go
>   there instead of the console. Messages from the real-time stream and the
>   event backup file still print to the console.
>
> Full surface: [JavaScript: client options](#javascript-client-options) below.

## Overview

The Synap SDK is configured via the `SDKConfig` object, which controls storage, caching, timeouts, retries, logging and endpoints. Sensible defaults are provided for all fields, so you only need to override what matters for your environment.

## SDKConfig Reference

```python Python theme={null}
from maximem_synap import SDKConfig, TimeoutConfig, RetryPolicy

config = SDKConfig(
    api_base_url=None,                    # REST endpoint; default Synap Cloud
    storage_path=None,                    # Default: ~/.synap (cache, conversation history for search, event backup)
    cache_backend="sqlite",              # "sqlite" or None
    session_timeout_minutes=30,           # Accepted, no effect today
    timeouts=TimeoutConfig(),             # Connection and read timeouts
    retry_policy=RetryPolicy(),           # Retry behavior for transient errors
    log_level="WARNING",                  # DEBUG, INFO, WARNING, ERROR, CRITICAL
    grpc_host=None,                       # Override the real-time stream host
    grpc_port=None,                       # Override the real-time stream port
    grpc_use_tls=None,                    # None = TLS on; False = plaintext
    agent_model=None,                     # Your agent's model, e.g. "gpt-4o"
    agent_context_window=None,            # Only for a model Synap does not know
    history_search_model="auto",          # Local search model; None = keywords only
    sdk_st_authoritative=False,           # Render prompts locally
    st_verbatim_overlay=True,             # See a turn you just wrote
)
```

```typescript TypeScript theme={null}
import { SynapClient } from '@maximem/synap-js-sdk';

const sdk = new SynapClient({
  apiKey: undefined,                                    // Default: SYNAP_API_KEY
  instanceId: undefined,                                // Default: resolved from the key
  baseUrl: undefined,                                   // Default: Synap Cloud
  timeouts: { connect: 5.0, read: 30.0, write: 10.0 },  // Seconds
  retryPolicy: { maxAttempts: 3 },                      // null disables retries
  keepAlive: {},                                        // Connection reuse
  heartbeat: false,                                     // Periodic /health ping
  logger: (level, message) => {},                       // Default: console.warn
  sdk_st_authoritative: false,                          // Render prompts locally
  st_verbatim_overlay: true,                            // See a turn you just wrote
  agent_model: undefined,                               // Your agent's model, e.g. 'gpt-4o'
  agent_context_window: undefined,                      // Only for a model Synap does not know
  history_search_model: 'auto',                         // Local search model; null = keywords only
});
```

### 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 from `SYNAP_API_KEY` (or the `api_key=` constructor argument) on each start. See [Storage Path](#storage-path).
* `cache_backend`: `"sqlite"` (default) for on-disk caching, or `None` to disable it. See [Cache Backend](#cache-backend).
* `session_timeout_minutes`: accepted for compatibility; it has no effect today. Default `30`, valid range `5` to `1440`. See [Session Timeout](#session-timeout).
* `timeouts`: a [TimeoutConfig](#timeoutconfig) for per-operation network timeouts.
* `retry_policy`: a [RetryPolicy](#retrypolicy) for transient-error retries, or `None` to disable retries.
* `log_level`: logging verbosity, one of `"DEBUG"`, `"INFO"`, `"WARNING"` (default), `"ERROR"`, `"CRITICAL"`. `configure()` rejects other values with `InvalidInputError`. See [Log Level](#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](#grpc-connection).
* `agent_model` / `agent_context_window`: the model your agent runs on, and its context window if Synap does not know the model. Sent with every recorded turn so Synap sizes compaction to your model: it compacts when the last compaction plus the new text reaches about 11.7% of the window (15K tokens on a 128K model), or after about 30 new messages (once they add up to about 2,000 tokens), whichever comes first. Without them Synap assumes a 128K window. The per-call `model` and `context_window` on `record_message` and `send_message` override them. Python 0.5.11 and later, JavaScript and TypeScript 0.5.9 and later.
* `history_search_model`: the local model for searching earlier turns after a compaction, and for matching a fetch to context the SDK already holds, by meaning. `"auto"` (default) uses the SDK's multilingual model when it is [installed](https://docs.maximem.ai/setup/installation.md#local-search-model); `None` keeps keyword matching only. `SYNAP_SDK_LOCAL_MODEL=off` also turns it off. Python 0.5.11 and later, JavaScript and TypeScript 0.5.9 and later.

> [card] [Full parameter reference →](https://docs.maximem.ai/sdk-reference/lifecycle/configure.md)
>
> 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.

```python Python theme={null}
from maximem_synap import TimeoutConfig

timeouts = TimeoutConfig(
    connect=5.0,       # Seconds to establish TCP connection
    read=30.0,         # Seconds to wait for response data
    write=10.0,        # Seconds to wait for request upload
    stream_idle=60.0   # Accepted, no effect today
)
```

```javascript JavaScript theme={null}
import { SynapClient } from '@maximem/synap-js-sdk';

const sdk = new SynapClient({ timeouts: { connect: 5.0, read: 30.0, write: 10.0 } }); // only read has an effect
```

```typescript TypeScript theme={null}
import { SynapClient } from '@maximem/synap-js-sdk';

const sdk = new SynapClient({ timeouts: { connect: 5.0, read: 30.0, write: 10.0 } }); // only read has an effect
```

**connect** `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. JavaScript ignores this value.

**read** `float` (default: 30.0)

Maximum time in seconds. Python: the longest wait for response data. JavaScript: the longest time to wait for the response to start, counted from when the request is sent. This should be higher than your expected query latency. For compaction of very large conversations, you may need to increase this.

**write** `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. JavaScript ignores this value.

**stream\_idle** `float` (default: 60.0)

Accepted for compatibility; it has no effect today.

## gRPC Connection

Cloud only Synap Core is REST only and has no real-time stream.

These three fields point the real-time anticipation stream ([`instance.listen()`](https://docs.maximem.ai/sdk-reference/instance/listen)) at a specific endpoint. Leave them unset for Synap Cloud; the defaults are correct and TLS is on.

```python Python theme={null}
config = SDKConfig(
    grpc_host="localhost",   # Default: Synap Cloud
    grpc_port=50051,         # Default: Synap Cloud
    grpc_use_tls=False,      # Default: None (TLS on)
)
```

```typescript TypeScript theme={null}
// listen() options here, not client configuration.
await sdk.instance.listen({
  host: 'localhost',   // Default: Synap Cloud
  port: 50051,         // Default: Synap Cloud
  use_tls: false,      // Default: TLS on
});
```

**grpc\_host** `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.

**grpc\_port** `int | None` (default: None)

Port for the real-time stream, commonly `50051` for local deployments. `None` uses the Synap Cloud default.

**grpc\_use\_tls** `bool | None` (default: None)

`None` uses the transport default (TLS **on**). If you leave a field `None`, the matching `SYNAP_GRPC_*` variable is used. Set to `False` only for a plaintext endpoint, such as a local container. Never disable TLS against a remote host.

> [!NOTE]
>
> 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. The local read cache keeps a non-empty result for its TTL (5 minutes by default), and a write does not clear it, so a fetch right after a write can return the older result.

For live agents that ingest and retrieve in the same loop, turn the local read cache off:

```python Python theme={null}
config = SDKConfig(cache_backend=None)
```

```typescript TypeScript theme={null}
// Nothing to disable: JavaScript does not keep a local read cache. Every fetch
// goes to Synap Cloud unless the real-time stream has already delivered the answer.
```

The anticipation cache is unaffected and keeps working.

## RetryPolicy

Controls automatic retry behavior for transient errors.

```python Python theme={null}
from maximem_synap import RetryPolicy

retry_policy = RetryPolicy(
    max_attempts=3,            # Total attempts (1 initial + 2 retries)
    backoff_base=1.0,          # Base delay in seconds
    backoff_max=10.0,          # Maximum delay cap
    backoff_jitter=True,       # Add randomized jitter
    retryable_errors=[         # Which error types to retry
        "NetworkTimeoutError",
        "RateLimitError",
        "ServiceUnavailableError",
        "SynapTransientError"
    ]
)
```

```typescript TypeScript theme={null}
import type { RetryPolicy } from '@maximem/synap-js-sdk';

// camelCase. JavaScript has no retryable_errors: it retries every temporary error (timeouts, 429, 5xx).
const retryPolicy: RetryPolicy = {
  maxAttempts: 3,       // Total attempts (1 initial + 2 retries)
  backoffBase: 1.0,     // Base delay in seconds
  backoffMax: 10.0,     // Maximum delay cap
  backoffJitter: true,  // Add randomized jitter
};
```

**max\_attempts** `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.

**backoff\_base** `float` (default: 1.0)

The base delay in seconds for exponential backoff. The wait after the first failure is `backoff_base`, then it doubles each time, up to `backoff_max`. A higher base means longer waits between retries, which is gentler on rate-limited endpoints.

**backoff\_max** `float` (default: 10.0)

The maximum delay in seconds between retry attempts. Prevents exponential backoff from growing unbounded for high `max_attempts` values.

**backoff\_jitter** `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.

**retryable\_errors** `List[str]` (default: \["NetworkTimeoutError", "RateLimitError", "ServiceUnavailableError", "SynapTransientError"])

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. The server's wait time is capped at `backoff_max`. A rate-limit error that says you are out of credits or at your trial limit is not retried. A write that timed out after it was sent is not retried, because it may have gone through; a context fetch that timed out is.

## Storage Path

The `storage_path` directory holds the local SQLite cache and transient state. The SDK uses your default file permissions. Put `storage_path` in a folder only your service can read. The API key is never stored here; it comes from `SYNAP_API_KEY` or the `api_key=` constructor argument.

### When to Override

| Scenario | Recommended `storage_path` |
| - | - |
| Standard deployment | `None` (use SDK default) |
| Docker container | `/var/lib/synap/` on a persistent volume (optional) |
| Serverless function | Disable the cache (`cache_backend=None`) |
| Multiple instances on the same host | The same path is fine; the SDK keeps each instance in its own folder |
| Testing | `/tmp/synap-test/` |

## Credentials

The SDK reads the API key on every start. There are exactly two sources:

| Source | Description |
| - | - |
| `api_key="..."` constructor argument | Passed directly to `MaximemSynapSDK(...)` |
| `SYNAP_API_KEY` environment variable | Read automatically when the constructor argument is omitted |

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)

```python theme={null}
config = SDKConfig(cache_backend="sqlite")
```

The SQLite cache stores recent retrieval results locally, enabling sub-millisecond cache hits for repeated queries. The cache respects TTL values from the server (`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

```python Python theme={null}
config = SDKConfig(cache_backend=None)
```

```typescript TypeScript theme={null}
// Python only: JavaScript keeps no local read cache, so there is
// nothing to disable.
```

Turns off the local read cache. A fetch goes to Synap Cloud unless the real-time stream has already delivered the answer. Use this when:

* You do not want a fetch to return an older cached result
* You are running in a read-only filesystem (and cannot use a RAM-backed path)
* You are debugging cache-related issues

## Session Timeout

`session_timeout_minutes` is accepted and validated (5 to 1440) but has no effect today. The SDK authenticates every request with your API key.

## Log Level

The SDK uses Python's standard `logging` module. The log level sets the `synap.sdk` logger. Python prints its warnings and errors to stderr without any setup; to see its INFO and DEBUG lines, your app needs a log handler, for example `logging.basicConfig()`.

```python Python theme={null}
config = SDKConfig(log_level="DEBUG")
```

```typescript TypeScript theme={null}
// JavaScript has no global logging framework, so there is no level to set.
// Pass the sink instead: the client's warnings go to it.
const sdk = new SynapClient({
  logger: (level, message) => myLogger[level](`[synap] ${message}`),
});

// Silence them entirely:
const quiet = new SynapClient({ logger: () => {} });
```

> [!NOTE]
>
> `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`.

| Level | What is Logged |
| - | - |
| `DEBUG` | Cache hits and misses, telemetry activity |
| `INFO` | Start-up and shutdown, stream connect and reconnect, cache lookups |
| `WARNING` | Retries, ignored settings, failed background work |
| `ERROR` | Stream stopped, response could not be read |

> [!WARNING]
>
> The `DEBUG` level logs cache keys, which contain user and customer ids. Do not use it where logs are shared.

## Using `configure()`

The `configure()` method allows you to update individual configuration fields after constructing the SDK but before calling `initialize()`.

```python Python theme={null}
sdk = MaximemSynapSDK(
    api_key="synap_your_key_here"
)

# Override specific fields without constructing a full SDKConfig
sdk.configure(log_level="DEBUG")
sdk.configure(session_timeout_minutes=120)
sdk.configure(cache_backend=None)

await sdk.initialize()
```

```typescript TypeScript theme={null}
const sdk = new SynapClient({ apiKey: 'synap_your_key_here' });

// Accepted and ignored:
sdk.configure({ log_level: 'DEBUG' });
sdk.configure({ session_timeout_minutes: 120 });
sdk.configure({ cache_backend: null });

// Real:
sdk.configure({ logger: (level, message) => myLogger[level](message) });

// These two are real:
sdk.configure({ timeouts: { read: 45.0 } });
sdk.configure({ retryPolicy: { maxAttempts: 5 } });

await sdk.initialize();
```

> [!WARNING]
>
> Calling `configure()` after `initialize()` raises `InvalidInputError('Cannot reconfigure after initialization')`.

## Environment Variables

These settings can come from the environment; others are set in code.

| Variable | Sets |
| - | - |
| `SYNAP_API_KEY` | API key, when no `api_key=` argument is passed |
| `SYNAP_BASE_URL` | `api_base_url`, the REST endpoint |
| `SYNAP_INSTANCE_ID` | `instance_id`, when no argument is passed |
| `SYNAP_CLIENT_ID` | Your client ID; resolved from the API key when unset |
| `SYNAP_GRPC_HOST` | `grpc_host`, the real-time stream host (JavaScript: the `host` option of `instance.listen()`) |
| `SYNAP_GRPC_PORT` | `grpc_port`, the real-time stream port |
| `SYNAP_GRPC_USE_TLS` | `grpc_use_tls`: `true` or `false` |
| `SYNAP_STORAGE_PATH` | Folder for the event backup file (not the local cache); default `~/.synap` |
| `SYNAP_SDK_LOCAL_MODEL` | `off` turns off the local search model |
| `SYNAP_SDK_ST_AUTHORITATIVE` | `sdk_st_authoritative`: `true` or `false` |
| `SYNAP_ST_VERBATIM_OVERLAY` | `st_verbatim_overlay`: `true` or `false` |

> [!NOTE]
>
> Explicit configuration wins, with these exceptions: `SYNAP_SDK_ST_AUTHORITATIVE` and `SYNAP_ST_VERBATIM_OVERLAY` override the value set in code, and `SYNAP_SDK_LOCAL_MODEL=off` turns the local search model off whatever the code says.

```python Python theme={null}
import os
from maximem_synap import MaximemSynapSDK, SDKConfig

sdk = MaximemSynapSDK(
    api_key=os.environ["SYNAP_API_KEY"],
    config=SDKConfig(log_level=os.environ.get("LOG_LEVEL", "WARNING")),
)
```

```typescript TypeScript theme={null}
import { SynapClient } from '@maximem/synap-js-sdk';

// SYNAP_API_KEY is read automatically. Route diagnostics with `logger`.
const sdk = new SynapClient({
  logger: (level, message) => myLogger[level](`[synap] ${message}`),
});
```

## Common Configurations

> [accordion] Development
>
> Verbose logging, short timeouts and quick-failing retries for fast feedback during development.
>
> ```python Python theme={null}
> from maximem_synap import SDKConfig, TimeoutConfig, RetryPolicy
>
> dev_config = SDKConfig(
>     storage_path="/tmp/synap-dev",  # Temporary path for dev
>     cache_backend="sqlite",
>     session_timeout_minutes=120,
>     timeouts=TimeoutConfig(
>         connect=3.0,
>         read=15.0,
>         write=5.0
>     ),
>     retry_policy=RetryPolicy(
>         max_attempts=2,
>         backoff_base=0.5,
>         backoff_max=3.0
>     ),
>     log_level="DEBUG"
> )
> ```
>
> ```typescript TypeScript theme={null}
> // Development
> const sdk = new SynapClient({
>   timeouts: { connect: 3.0, read: 15.0, write: 5.0 },
>   retryPolicy: { maxAttempts: 2, backoffBase: 0.5, backoffMax: 3.0 },
> });
> ```

> [accordion] Production
>
> Conservative timeouts, standard retries with jitter, minimal logging, and persistent storage.
>
> ```python Python theme={null}
> from maximem_synap import SDKConfig, TimeoutConfig, RetryPolicy
>
> prod_config = SDKConfig(
>     storage_path="/var/lib/synap",
>     cache_backend="sqlite",
>     session_timeout_minutes=30,
>     timeouts=TimeoutConfig(
>         connect=10.0,
>         read=30.0,
>         write=10.0
>     ),
>     retry_policy=RetryPolicy(
>         max_attempts=3,
>         backoff_base=1.0,
>         backoff_max=10.0,
>         backoff_jitter=True
>     ),
>     log_level="WARNING"
> )
> ```
>
> ```typescript TypeScript theme={null}
> // Production
> const sdk = new SynapClient({
>   timeouts: { connect: 10.0, read: 30.0, write: 10.0 },
>   retryPolicy: { maxAttempts: 3, backoffBase: 1.0, backoffMax: 10.0, backoffJitter: true },
>   heartbeat: true,   // Option exists in JavaScript only; Python does this automatically.
> });
> ```

> [accordion] Testing
>
> Isolated storage, disabled caching for deterministic tests, no retries for immediate failure feedback.
>
> ```python Python theme={null}
> from maximem_synap import SDKConfig, TimeoutConfig
>
> test_config = SDKConfig(
>     storage_path="/tmp/synap-test",
>     cache_backend=None,          # No caching for deterministic tests
>     session_timeout_minutes=5,
>     timeouts=TimeoutConfig(
>         connect=2.0,
>         read=5.0,
>         write=3.0
>     ),
>     retry_policy=None,           # No retries: fail fast in tests
>     log_level="DEBUG"
> )
>
> # Use _force_new to bypass singleton caching in tests
> sdk = MaximemSynapSDK(
>     api_key="synap_test_key",
>     config=test_config,
>     _force_new=True
> )
> ```
>
> ```typescript TypeScript theme={null}
> // Testing. _force_new gives this test its own client; call shutdown() in
> // teardown, because nothing else will.
> const sdk = new SynapClient({
>   timeouts: { connect: 2.0, read: 5.0, write: 3.0 },
>   retryPolicy: null,   // no retries: fail fast in tests
>   _force_new: true,
> });
> ```

> [accordion] High-Throughput
>
> Optimized for batch ingestion workloads with generous timeouts and higher retry limits.
>
> ```python Python theme={null}
> from maximem_synap import SDKConfig, TimeoutConfig, RetryPolicy
>
> throughput_config = SDKConfig(
>     storage_path="/var/lib/synap",
>     cache_backend="sqlite",
>     session_timeout_minutes=1440,  # Accepted, no effect today
>     timeouts=TimeoutConfig(
>         connect=15.0,
>         read=60.0,               # Long reads for large batch responses
>         write=30.0               # Long writes for large batch payloads
>     ),
>     retry_policy=RetryPolicy(
>         max_attempts=5,
>         backoff_base=2.0,
>         backoff_max=30.0,
>         backoff_jitter=True
>     ),
>     log_level="INFO"
> )
> ```
>
> ```typescript TypeScript theme={null}
> // High throughput
> const sdk = new SynapClient({
>   timeouts: { connect: 5.0, read: 60.0, write: 15.0 },
>   retryPolicy: { maxAttempts: 5, backoffBase: 0.5, backoffMax: 20.0, backoffJitter: true },
>   keepAlive: {},   // Option exists in JavaScript only; Python does this automatically.
> });
> ```

## Full Configuration Example

A fuller example:

```python Python theme={null}
from maximem_synap import MaximemSynapSDK, SDKConfig, TimeoutConfig, RetryPolicy

sdk = MaximemSynapSDK(
    api_key="synap_your_key_here",
    config=SDKConfig(
        storage_path="/var/lib/myapp/synap",
        cache_backend="sqlite",
        session_timeout_minutes=60,
        timeouts=TimeoutConfig(
            connect=10.0,
            read=30.0,
            write=10.0
        ),
        retry_policy=RetryPolicy(
            max_attempts=3,
            backoff_base=1.0,
            backoff_max=10.0,
            backoff_jitter=True,
            retryable_errors=[
                "NetworkTimeoutError",
                "RateLimitError",
                "ServiceUnavailableError",
                "SynapTransientError"
            ]
        ),
        log_level="WARNING"
    )
)

await sdk.initialize()
```

```typescript TypeScript theme={null}
import { SynapClient } from '@maximem/synap-js-sdk';

const sdk = new SynapClient({
  apiKey: 'synap_your_key_here',
  timeouts: { connect: 10.0, read: 30.0, write: 10.0 },
  // camelCase. JavaScript has no retryable_errors: it retries every temporary error (timeouts, 429, 5xx).
  retryPolicy: {
    maxAttempts: 3,
    backoffBase: 1.0,
    backoffMax: 10.0,
    backoffJitter: true,
  },
});

await sdk.initialize();
```

## Next Steps

> [card] [Initializing the SDK](https://docs.maximem.ai/sdk/initialization.md)
>
> Learn the full initialization lifecycle with configuration.

> [card] [API Error Reference](https://docs.maximem.ai/sdk-reference/errors.md)
>
> Understand how retry policies interact with the error hierarchy.

> [card] [Production Checklist](https://docs.maximem.ai/guides/production-checklist.md)
>
> Review configuration best practices before going live.

> [card] [Ingesting Memories](https://docs.maximem.ai/sdk/ingestion.md)
>
> Start ingesting data with your configured SDK.

## JavaScript: client options

Pass these to `new SynapClient({ ... })`:

**apiKey** `string`

Your Synap API key. Falls back to `SYNAP_API_KEY` when omitted.

**baseUrl** `string`

API base URL. Falls back to `SYNAP_BASE_URL`, then the Synap Cloud default. Set it when you run a self-hosted deployment.

**instanceId** `string`

Optional. Resolved from the API key during `initialize()` when omitted. Falls back to `SYNAP_INSTANCE_ID`.

**clientId** `string`

Optional. Resolved from the API key during `initialize()` when omitted. Falls back to `SYNAP_CLIENT_ID`.

**timeouts** `object`

`{ connect, read, write }` in seconds. Only `read` (default 30) has an effect.

**retryPolicy** `object`

`{ maxAttempts, backoffBase, backoffMax, backoffJitter }`. Defaults to 3 attempts with jittered exponential backoff.

**keepAlive** `object`

`{ keepAliveExpiryMs, maxConnections, heartbeatIntervalMs }`. Connection reuse on Node: idle connections are kept for 5 minutes (`keepAliveExpiryMs`, in milliseconds) and up to 20 are open at once. `heartbeatIntervalMs` (default 4 minutes) sets the ping interval used when `heartbeat` is `true`.

**heartbeat** `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.

**fetchImpl** `function`

Supply your own `fetch`. Useful for testing or for routing through a proxy.

**logger** `function`

`(level, message) => void`. Receives the client's warnings. Defaults to `console.warn` with a `[synap]` prefix.

**agent\_model** `string`

The model your agent runs on, for example `'gpt-4o'`. Sent with every recorded turn so Synap sizes compaction to it. Also accepted as `agentModel`.

**agent\_context\_window** `number`

Your model's context window in tokens. Only needed for a model Synap does not know. Also accepted as `agentContextWindow`.

**history\_search\_model** `string | null` (default: 'auto')

The local model for searching earlier turns after a compaction, and for matching a fetch to context the client already holds. `'auto'` uses the SDK's multilingual model when it is [installed](https://docs.maximem.ai/setup/installation.md#local-search-model); `null` keeps keyword matching only. Also accepted as `historySearchModel`.

**sdk\_st\_authoritative** `boolean` (default: false)

Render prompts locally: answer prompt and compacted-context requests from turns the client already holds, when it holds the whole conversation. `SYNAP_SDK_ST_AUTHORITATIVE` overrides it. Also accepted as `sdkStAuthoritative`.

**st\_verbatim\_overlay** `boolean` (default: true)

Show a turn you just wrote in the next conversation fetch, before the server has processed it. `SYNAP_ST_VERBATIM_OVERLAY` overrides it. Also accepted as `stVerbatimOverlay`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.