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

# Cloud SDK

> Connect to Cognee Cloud programmatically using the Cognee Python SDK

The Cognee Python SDK connects to Cognee Cloud via `cognee.serve()`. Once connected, all operations (`remember`, `recall`, `forget`, `improve`) route to your cloud tenant.

<Note>
  The same `cognee` package is used for both local and cloud workflows. The only difference is calling `cognee.serve()` to connect to a remote instance.
</Note>

## Install

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

## Complete example

```python theme={null}
import asyncio
import cognee

async def main():
    # Connect to Cognee Cloud
    await cognee.serve(
        url="https://your-tenant.aws.cognee.ai",
        api_key="your-api-key"
    )

    # Store content in memory — ingests, builds knowledge graph, enriches
    await cognee.remember(
        "Cognee Cloud automates knowledge graph creation in the cloud.",
        dataset_name="default_dataset",
    )

    # Retrieve from memory
    results = await cognee.recall(
        query_text="What does Cognee Cloud automate?",
    )
    for result in results:
        print(result)

    # Disconnect when done
    await cognee.disconnect()

asyncio.run(main())
```

## What just happened

### Connecting to cloud

Pass your tenant URL and API key to `cognee.serve()`:

```python theme={null}
await cognee.serve(
    url="https://your-tenant.aws.cognee.ai",
    api_key="your-api-key"
)
```

Create an API key from the [API Keys](/cognee-cloud/ui/api-keys) page in the Cognee Cloud console. You can find your tenant URL there as well.

To verify the remote connection, check the tenant health endpoint and then confirm authentication against the datasets API:

```bash theme={null}
curl https://your-tenant.aws.cognee.ai/health
curl https://your-tenant.aws.cognee.ai/api/v1/datasets/ \
  -H "X-Api-Key: your-api-key"
```

A `200 OK` from `/health` confirms the service is up. For `GET /api/v1/datasets/`, a `200` means the URL and key are working, `401` means the key is wrong, and `404` or a `5xx` usually means the URL or service is unavailable.

### Storing data

```python theme={null}
await cognee.remember(
    "Cognee Cloud automates knowledge graph creation in the cloud.",
    dataset_name="default_dataset",
)
```

[`remember`](/core-concepts/main-operations/remember) ingests data and builds the knowledge graph in a single call. Data is organized by [dataset](/core-concepts/further-concepts/datasets) for isolation and permissions.

For more control, use the lower-level [`add`](/core-concepts/main-operations/legacy-operations/add) and [`cognify`](/core-concepts/main-operations/legacy-operations/cognify) operations separately.

### Retrieving data

```python theme={null}
results = await cognee.recall(
    query_text="What does Cognee Cloud automate?",
)
```

[`recall`](/core-concepts/main-operations/recall) auto-routes the query to the best retrieval strategy. For direct control over search types, see [Search Basics](/guides/search-basics).

### Disconnecting

```python theme={null}
await cognee.disconnect()
```

Closes the connection to the cloud tenant. Credentials remain cached for the next session.

## Next steps

<CardGroup cols={2}>
  <Card title="Cloud functionality" href="/cognee-cloud/functionality/data-ingestion" icon="cloud">
    Explore the full API surface available in Cognee Cloud.
  </Card>

  <Card title="Cloud MCP" href="/cognee-cloud/connections/cloud-mcp" icon="plug">
    Connect MCP-compatible clients to Cognee Cloud.
  </Card>
</CardGroup>
