Skip to main content
The official Memic Python SDK is published on PyPI as memic.

Install

pip install memic
Requires Python 3.10 or newer.

Authenticate

The SDK reads your API key from the MEMIC_API_KEY environment variable:
export MEMIC_API_KEY="mk_live_..."
from memic import Memic

client = Memic()  # reads MEMIC_API_KEY from env
Or pass it explicitly:
client = Memic(api_key="mk_live_...")

First call

print(client.me())
If this prints your org and project info, you’re good.

What’s in the SDK

The Memic client exposes these resources:
  • client.me() — return the context resolved from your API key
  • client.projects — list projects
  • client.files — upload, list, delete, status
  • client.search(query) — semantic search
  • client.chat(messages) — grounded chat with citations
  • client.prompts — fetch managed prompts
See the full reference for every method and parameter.

Configuration

The Memic constructor accepts optional parameters:
client = Memic(
    api_key="mk_live_...",           # default: MEMIC_API_KEY env var
    base_url="https://api.memic.ai/api/v1",  # default
    timeout=30.0,                    # default, in seconds
    max_retries=3,                   # default
)

Error handling

The SDK raises typed exceptions for common failures:
from memic import Memic, AuthenticationError, NotFoundError, RateLimitError

client = Memic()

try:
    client.search("test")
except AuthenticationError:
    print("Check your API key")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except NotFoundError as e:
    print(f"Not found: {e}")

Quickstart

5-minute walkthrough.

Full reference

Every method and parameter.