PHPackages                             upstash/vector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. upstash/vector

ActiveLibrary

upstash/vector
==============

An HTTP/REST based Vector DB client built on top of Upstash REST API.

v1.2.0(1y ago)63.3k↓42.9%1[3 PRs](https://github.com/upstash/vector-php/pulls)1MITPHPPHP ^8.3CI passing

Since Jan 14Pushed 3mo ago6 watchersCompare

[ Source](https://github.com/upstash/vector-php)[ Packagist](https://packagist.org/packages/upstash/vector)[ Docs](https://github.com/upstash/vector-php)[ RSS](/packages/upstash-vector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (26)Used By (1)

Vector Client SDK for PHP
=========================

[](#vector-client-sdk-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9d4925512d9cfb44d3db6c092208bded496c89bf8621bdbdc5b8ad275078af01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f757073746173682f766563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/upstash/vector)[![Tests](https://camo.githubusercontent.com/65741774e794f8ace04d3421e7b9ecad3b5665c89ad1bb3190d2a9f6f460b8c1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f757073746173682f766563746f722d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/upstash/vector-php/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/f1ca348c56b99390408e0a2f2ccd7f07921d19a5982d06fa27e16152e871b630/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f757073746173682f766563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/upstash/vector)

Upstash Vector is an HTTP serverless Vector Database.

You can store, query, and retrieve vectors from your application, use it to power your search, and more.

You can read more about Upstash Vector [here](https://docs.upstash.com/vector).

Quick Start
-----------

[](#quick-start)

### Installation

[](#installation)

You can install the package via composer:

```
composer require upstash/vector
```

### Create Index

[](#create-index)

Create a new index on [Upstash](https://console.upstash.com/vector)

Usage
-----

[](#usage)

### Initialize the index

[](#initialize-the-index)

```
use Upstash\Vector\Index;

// Initialize the index
$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

// or just to use the environment variables
$index = Index::fromEnv();
```

### Upserting Vectors

[](#upserting-vectors)

```
use Upstash\Vector\Index;
use Upstash\Vector\VectorUpsert;

use function Upstash\Vector\createRandomVector;

$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

$index->upsert(new VectorUpsert(
    id: 'upstash-rocks',
    vector: createRandomVector(dimensions: 1536),
    metadata: ['field' => 'value'],
));
```

### Upserting Data with Embedding Models

[](#upserting-data-with-embedding-models)

```
use Upstash\Vector\Index;
use Upstash\Vector\DataUpsert;

$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

$index->upsertData(new DataUpsert(
    id: 'upstash-vector',
    data: 'Upstash Vector is a serverless vector database.',
    metadata: ['field' => 'value'],
));
```

### Querying Vectors

[](#querying-vectors)

```
use Upstash\Vector\Index;
use Upstash\Vector\VectorQuery;

use function Upstash\Vector\createRandomVector;

$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

$index->query(new VectorQuery(
    vector: createRandomVector(dimensions: 1536),
    topK: 5,
));
```

### Querying Data with Embedding Models

[](#querying-data-with-embedding-models)

```
use Upstash\Vector\Index;
use Upstash\Vector\DataQuery;

$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

$index->queryData(new DataQuery(
    data: 'What is Upstash Vector?',
    topK: 5,
));
```

### Fetch specific vectors

[](#fetch-specific-vectors)

```
use Upstash\Vector\Index;
use Upstash\Vector\VectorFetch;

$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

$index->fetch(new VectorFetch(ids: ['upstash-rocks']));
```

### Delete specific vectors

[](#delete-specific-vectors)

```
use Upstash\Vector\Index;

$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

$index->delete(['upstash-rocks']);
```

Namespaces
----------

[](#namespaces)

Upstash Vector allows you to partition a single index into multiple isolated namespaces. Each namespace functions as a self-contained subset of the index, in which read and write requests are only limited to one namespace. To learn more about it, [see Namespaces](https://upstash.com/docs/vector/features/namespaces).

### Example

[](#example)

```
use Upstash\Vector\Index;
use Upstash\Vector\VectorUpsert;

use function Upstash\Vector\createRandomVector;

$index = new Index(
    url: 'UPSTASH_VECTOR_REST_URL',
    token: 'UPSTASH_VECTOR_REST_TOKEN',
);

// Upsert to namespace
$index->namespace('books')->upsert(new VectorUpsert(
    id: 'upstash-rocks',
    vector: createRandomVector(dimensions: 1536),
    metadata: ['field' => 'value'],
));
```

Troubleshooting
---------------

[](#troubleshooting)

We have a [Discord](upstash.com/discord) for common problems. If you can't find a solution, please [open an issue](https://github.com/upstash/vector-js/issues/new).

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance64

Regular maintenance activity

Popularity28

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 88% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

14

Last Release

440d ago

Major Versions

v0.2.1 → v1.0.02025-02-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/dab2f1963c9204b0788e3b9736304c6108eeb868e6606293a49b5666ff9ce8ed?d=identicon)[buggyhunter](/maintainers/buggyhunter)

![](https://www.gravatar.com/avatar/ac16470355630b6cb24d134e4c2bce83c517a17d71217b4fbb11a050477a1062?d=identicon)[yunusemreozdemir](/maintainers/yunusemreozdemir)

---

Top Contributors

[![heyjorgedev](https://avatars.githubusercontent.com/u/2780099?v=4)](https://github.com/heyjorgedev "heyjorgedev (81 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![CahidArda](https://avatars.githubusercontent.com/u/57228345?v=4)](https://github.com/CahidArda "CahidArda (1 commits)")

---

Tags

aiphpsdksdk-phpsemantic-searchupstashupstash-vectorvectorvector-databasephpsdkaivectorragupstash

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/upstash-vector/health.svg)

```
[![Health](https://phpackages.com/badges/upstash-vector/health.svg)](https://phpackages.com/packages/upstash-vector)
```

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[mozex/anthropic-php

Anthropic PHP is a supercharged community-maintained PHP API client that allows you to interact with Anthropic API.

46365.1k13](/packages/mozex-anthropic-php)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

963.1M35](/packages/getbrevo-brevo-php)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[gemini-api-php/client

API client for Google's Gemini API

216221.4k5](/packages/gemini-api-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
