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

# SDKs and CLI

> Install and use the Mixpeek Python SDK, JavaScript SDK and mixpeek CLI, or call the REST API directly. One section per tool, each with a working example.

Mixpeek ships two SDKs generated from the OpenAPI spec, a command-line tool for Apps, and a plain REST API that every tool wraps.

| Tool | Install | Use it for | Version checked |
| - | - | - | - |
| [Python SDK](#python-sdk) | `pip install mixpeek` | Scripts, notebooks and backends in Python 3.9 or later | 1.3.783 |
| [JavaScript SDK](#javascript-sdk) | `npm install mixpeek` | Node.js and TypeScript backends | 0.81.470 |
| [REST API](#rest-api) | none | Any language, or when you want no dependency | v1 |
| [mixpeek CLI](#mixpeek-cli) | `npm install -g @mixpeek/cli` | Building and deploying [Apps](https://docs.mixpeek.com/docs/tools/apps.md) | 0.1.1 |
| [MCP server](#mcp-server) | none (hosted) | AI agents such as Claude Code and Cursor | n/a |

Every tool sends the same two headers: `Authorization: Bearer $MIXPEEK_API_KEY` and, for anything inside a namespace, `X-Namespace: $NAMESPACE_ID`. The examples below read both from the environment.

```bash Shell title="Set credentials once" theme={null}
export MIXPEEK_API_KEY="mxp_sk_replace_me"
export NAMESPACE_ID="ns_replace_me"
export RETRIEVER_ID="ret_replace_me"
```

## Python SDK

The `mixpeek` package has two layers. The `Mixpeek` client covers the common resources with short method names and returns plain dicts. The generated API classes (`mixpeek.RetrieversApi`, `mixpeek.CollectionsApi` and so on) cover every endpoint with typed request models. Start with `Mixpeek` and drop to the generated classes for endpoints it does not wrap.

```bash Shell theme={null}
pip install mixpeek
```

```python Python title="Run a retriever" theme={null}
import os
from mixpeek import Mixpeek

client = Mixpeek(namespace=os.environ["NAMESPACE_ID"])  # reads MIXPEEK_API_KEY

run = client.retrievers.execute(os.environ["RETRIEVER_ID"], inputs={"query": "a dark city street at night"})
print(run["status"], run["warnings"])
for doc in run["documents"]:
    print(doc["document_id"], doc["score"])
```

| Constructor argument | Environment variable | Default |
| - | - | - |
| `api_key` | `MIXPEEK_API_KEY` | required; raises `ValueError` when missing |
| `namespace` | `MIXPEEK_NAMESPACE` | none; sent as `X-Namespace` on every call |
| `base_url` | none | `https://api.mixpeek.com/v1` |
| `timeout` | none | 30 seconds per read |

The client retries a 429 or 503 response after the wait the server advises (`Retry-After`), or a backoff from 2 seconds that doubles; other errors raise at once. Responses support both `run["documents"]` and `run.documents`.

> [accordion] Resources on the Mixpeek client
>
> | Resource | Methods |
> | - | - |
> | `client.namespaces` | `list`, `get`, `create`, `delete`, `clone`, `promote`, `documents.upsert` |
> | `client.buckets` | `list`, `get`, `create`, `delete`, `upload`, `list_objects` |
> | `client.collections` | `list`, `get`, `create`, `update`, `delete`, `trigger`, `clone` |
> | `client.retrievers` | `list`, `get`, `create`, `update`, `delete`, `execute`, `execute_batch`, `clone`, `publish`, `run_evaluation`, `create_interaction` |
> | `client.documents` | `list`, `get`, `update`, `delete` |
> | `client.batches` | `get`, `audit`, `failed_documents` |
> | `client.tasks` | `get`, `list`, `delete` |
> | `client.evaluations` | `create_dataset`, `list_datasets`, `get_dataset`, `generate_from_interactions`, `run`, `list`, `get` |
>
> A method's keyword arguments become the JSON body, so `client.collections.create(collection_name="scenes", source={"type": "bucket", "bucket_ids": ["bkt_replace_me"]}, features=["video_search"])` sends those three fields. A `namespace_id=` or `namespace=` keyword is moved to the `X-Namespace` header for that call.

> [accordion] Create a namespace: managed or standalone
>
> `client.namespaces.create` picks the mode from its arguments. `vector_configs=` creates a standalone namespace for your own vectors. `feature_extractors=`, or just a name (`name=` or `namespace_name=`), creates a managed namespace. Pass `mode="managed"` or `mode="standalone"` to choose it yourself.
>
> ```python Python title="Both kinds of namespace" theme={null}
> from mixpeek import Mixpeek
>
> client = Mixpeek()
> managed = client.namespaces.create(name="product-search")
> standalone = client.namespaces.create(
>     name="my-vectors",
>     vector_configs=[{"name": "embedding", "dimension": 768, "metric": "cosine"}],
> )
> print(managed["namespace_id"], standalone["namespace_id"])
> ```
>
> Writing and searching your own vectors is covered in [Bring your own vectors](https://docs.mixpeek.com/docs/manage/vector-store.md).

> [accordion] Errors
>
> The `Mixpeek` client raises `MixpeekAPIError` (`from mixpeek import MixpeekAPIError`) for a non-2xx response it did not retry away.
>
> | Attribute | Meaning |
> | - | - |
> | `status` | HTTP status code |
> | `detail` | The error body: message, error code and details |
> | `retryable` | `True` for 429 and 503 |
> | `retry_after` | Seconds the server advised waiting, when it said |
>
> The generated API classes raise `mixpeek.rest.ApiException` with `status`, `reason` and `body`.

> [accordion] Generated API classes
>
> ```python Python title="List collections with the generated client" theme={null}
> import os
> import mixpeek
>
> configuration = mixpeek.Configuration(host="https://api.mixpeek.com")
> with mixpeek.ApiClient(configuration) as api_client:
>     collections = mixpeek.CollectionsApi(api_client).list_collections(
>         authorization=f"Bearer {os.environ['MIXPEEK_API_KEY']}",
>         x_namespace=os.environ["NAMESPACE_ID"],
>     )
>     print(collections)
> ```
>
> Each class matches one group in the [API reference](https://docs.mixpeek.com/docs/overview/api-basics.md), and each method takes the path, query and body fields that endpoint declares. Set `configuration.timeout` for a longer request timeout.

Source and issues: [github.com/mixpeek/python-sdk](https://github.com/mixpeek/python-sdk). Package: [pypi.org/project/mixpeek](https://pypi.org/project/mixpeek/).

## JavaScript SDK

The `mixpeek` npm package is a TypeScript client generated from the OpenAPI spec, with CommonJS and ES module builds. `new Mixpeek()` exposes one typed sub-client per API group, such as `client.retrievers`, `client.collections`, `client.buckets` and `client.tasks`. Each method takes one object of named parameters and returns an Axios response, so read the body from `.data`.

```bash Shell theme={null}
npm install mixpeek
```

```javascript JavaScript title="Run a retriever" theme={null}
import { Mixpeek } from "mixpeek";

const client = new Mixpeek({
  apiKey: process.env.MIXPEEK_API_KEY,
  namespace: process.env.NAMESPACE_ID,
});

const { data: run } = await client.retrievers.executeRetriever({
  retrieverId: process.env.RETRIEVER_ID,
  executeRetrieverRequest: { inputs: { query: "a dark city street at night" } },
});
console.log(run.status, run.warnings);
for (const doc of run.documents) console.log(doc.document_id, doc.score);
```

| Option | Default | Notes |
| - | - | - |
| `apiKey` | `MIXPEEK_API_KEY` | Required |
| `namespace` | `default` | Sent as `X-Namespace` |
| `baseUrl` | `https://api.mixpeek.com` | Set for a dedicated or customer-hosted deployment |
| `timeout` | 30000 ms | Per request |
| `axiosConfig` | none | Passed through to Axios |

`client.setApiKey()` and `client.setNamespace()` change the credentials on an existing client. Method names follow the API reference titles in camel case, for example `listCollections`, `createRetriever` and `getTask`.

> [accordion] Sub-clients
>
> `collections`, `collectionDocuments`, `collectionSchema`, `collectionLifecycle`, `collectionTaxonomies`, `retrievers`, `retrieverStages`, `retrieverInteractions`, `publishedRetrievers`, `adhocRetrievers`, `documents`, `buckets`, `bucketObjects`, `bucketUploads`, `bucketSyncs`, `bucketBatches`, `batches`, `namespaces`, `organizations`, `organizationApiKeys`, `taxonomies`, `clusters`, `clusterExecutions`, `alerts`, `agents`, `apps`, `featureExtractors`, `webhooks`, `tasks`, `health`, `analytics`.

Package: [npmjs.com/package/mixpeek](https://www.npmjs.com/package/mixpeek).

## REST API

Every endpoint takes JSON over HTTPS at `https://api.mixpeek.com/v1`. Use it from any language, or when an SDK does not yet wrap an endpoint. The OpenAPI spec is at `https://api.mixpeek.com/docs/openapi.json`.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/retrievers/$RETRIEVER_ID/execute" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"query": "a dark city street at night"}}'
```

```python Python theme={null}
import os
import requests

run = requests.post(
    f"https://api.mixpeek.com/v1/retrievers/{os.environ['RETRIEVER_ID']}/execute",
    headers={
        "Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}",
        "X-Namespace": os.environ["NAMESPACE_ID"],
    },
    json={"inputs": {"query": "a dark city street at night"}},
).json()
print(run["status"], len(run["documents"]))
```

```javascript JavaScript theme={null}
const run = await fetch(
  `https://api.mixpeek.com/v1/retrievers/${process.env.RETRIEVER_ID}/execute`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}`,
      "X-Namespace": process.env.NAMESPACE_ID,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ inputs: { query: "a dark city street at night" } }),
  },
).then((r) => r.json());
console.log(run.status, run.documents.length);
```

Read `documents`, `status` and `warnings` on every retriever run; list endpoints return `results` and a `next_cursor` to page with. See [Concepts](https://docs.mixpeek.com/docs/overview/concepts.md#response-envelopes) and [Execute retriever](https://docs.mixpeek.com/docs/api-reference/retrievers/execute-retriever.md).

## mixpeek CLI

`@mixpeek/cli` installs a `mixpeek` command that scaffolds, runs and deploys [Apps](https://docs.mixpeek.com/docs/tools/apps.md) from your terminal. It needs Node.js 18 or later. It reads the app id from `mixpeek.config.json` in the current directory, which `mixpeek apps init` writes.

```bash Shell title="Log in and deploy an app" theme={null}
npm install -g @mixpeek/cli
mixpeek login                 # prompts for your API key and API URL, checks them, saves them
mixpeek apps init --template video-search
cd my-video-search            # the project name you chose at the prompt
mixpeek apps deploy --env staging --message "First deploy"
```

| Command | What it does | Options |
| - | - | - |
| `mixpeek login` | Prompts for an API key and API URL, checks them against `GET /v1/me`, and saves them to `~/.mixpeek/credentials.json` | none |
| `mixpeek apps init` | Scaffolds a project with `mixpeek.config.json` | `-t, --template` (`product-search`, `document-intelligence`, `video-search`, `brand-compliance`) |
| `mixpeek apps dev` | Runs your `dev` script with `VITE_MIXPEEK_API_URL` set | none |
| `mixpeek apps deploy` | Builds, zips `dist/`, `build/` or `out/`, uploads and deploys | `-e, --env` (default `staging`), `-m, --message` |
| `mixpeek apps logs` | Streams build logs for the latest or a given deploy | `-d, --deploy` |
| `mixpeek apps preview` | Lists active pull-request preview deploys | none |
| `mixpeek apps publish` | Promotes staging to production | none |
| `mixpeek apps rollback` | Rolls back to the previous published version | none |
| `mixpeek apps versions` | Lists version history | none |
| `mixpeek apps domains add <domain>` | Attaches a custom domain and prints the TXT record to add | none |
| `mixpeek apps domains verify <domain>` | Starts DNS verification | none |

Before `deploy`, `logs`, `publish` or `rollback` will run, set `app_id` in `mixpeek.config.json` to the id of an app you created. [Apps](https://docs.mixpeek.com/docs/tools/apps.md) covers creating one.

> [!NOTE]
>
> The CLI has no plugin or extractor commands. To build and publish your own extractor, see [Custom extractors and models](https://docs.mixpeek.com/docs/extract/custom-extractors.md).

## MCP server

The hosted MCP server at `https://mcp.mixpeek.com/mcp` exposes 104 Mixpeek tools to AI agents with no install. Add it to Claude Code, Claude Desktop, Cursor, Codex or Gemini CLI. See [Agents and MCP](https://docs.mixpeek.com/docs/overview/agents.md).


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