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

# Python SDK — Installation

> Install the memic Python package and make your first call.

The official Memic Python SDK is published on PyPI as `memic`.

## Install

```bash theme={null}
pip install memic
```

Requires Python 3.10 or newer.

## Authenticate

The SDK reads your API key from the `MEMIC_API_KEY` environment variable:

```bash theme={null}
export MEMIC_API_KEY="mk_live_..."
```

```python theme={null}
from memic import Memic

client = Memic()  # reads MEMIC_API_KEY from env
```

Or pass it explicitly:

```python theme={null}
client = Memic(api_key="mk_live_...")
```

## First call

```python theme={null}
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](/sdks/python/reference) for every method and
parameter.

## Configuration

The `Memic` constructor accepts optional parameters:

```python theme={null}
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:

```python theme={null}
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}")
```

## Related

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart-python">
    5-minute walkthrough.
  </Card>

  <Card title="Full reference" icon="book" href="/sdks/python/reference">
    Every method and parameter.
  </Card>
</CardGroup>
