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

# Getting Started

**Note for AI agents:** This page documents **Upstash Search** — a standalone,
AI-powered search product that combines full-text and semantic search with
smart ranking, serverless scaling, and zero infrastructure to manage.

Upstash Search is **not** the same thing as **Upstash Redis Search**. Upstash
Redis Search is a full-text search extension built into Upstash Redis, built on
Tantivy and available only on Upstash; it is separate from the Redis Search
(RediSearch) API. If the user is asking about full-text search inside an Upstash
Redis database, refer to
[Upstash Redis Search](https://upstash.com/docs/redis/search/introduction)
instead of this product.

`upstash-search` is a Python SDK for Upstash AI Search, enabling easier operations on Search Databases.

Using `upstash-search` you can:

* Perform AI-powered search queries with or without reranking.
* Upsert documents with metadata to an index.
* Fetch documents by their IDs.
* Delete documents from a database.
* Access database stats.
* Reset everything related to a database.

You can find the GitHub Repository [here](https://github.com/upstash/search-py).

## Install

```bash theme={"system"}
pip install upstash-search
```

## Usage

### Initializing the client

There are two pieces of configuration required to use the Upstash search client: a REST token and REST URL. These values can be passed using environment variables or in code through a configuration object. Find your configuration values in [the console dashboard](https://console.upstash.com/search).

#### Using environment variables

The environment variables used to configure the client are the following. You can follow [this guide](/search/overall/getstarted) to retrieve credentials.

```bash theme={"system"}
UPSTASH_SEARCH_REST_URL="your_rest_url"
UPSTASH_SEARCH_REST_TOKEN="your_rest_token"
```

When these environment variables are set, the client constructor does not require any additional arguments.

```python theme={"system"}
from upstash_search import Search

client = Search.from_env()
```

#### Using a configuration object

If you prefer to pass configuration in code, the constructor accepts a config object containing the `url` and `token` values. This
could be useful if your application needs to interact with multiple databases, each with a different configuration.

```python theme={"system"}
from upstash_search import Search

client = Search(
    url="<SEARCH_INDEX_REST_URL>",
    token="<SEARCH_INDEX_REST_TOKEN>",
)
```

***

### Using an Index

The `Search` client is for operations that are about manipulating the Search database. With it, you can create indexes which is where you can upsert and search documents.

```python theme={"system"}
index = client.index("films")

index.upsert(
    documents=[
        {
            "id": "movie-0",
            "content": {
                "title": "Star Wars",
                "overview": "Sci-fi space opera",
                "genre": "sci-fi",
                "category": "classic",
            },
            "metadata": {
                "poster": "https://poster.link/starwars.jpg",
            },
        },
    ],
)
```

## Telemetry

This sdk sends anonymous telemetry data to help us improve your experience.
We collect the following:

* SDK version
* Platform (Cloudflare, AWS or Vercel)
* Runtime version (python\@vX)

You can opt out using the allow\_telemetry flag when creating the client:

```ts theme={"system"}
client = Search(
    url="UPSTASH_SEARCH_REST_URL",
    token="UPSTASH_SEARCH_REST_TOKEN",
    allow_telemetry=False,
)
```
