

Show HN: I built a vector database API on Cloudflare
source link: https://github.com/TimeSurgeLabs/athenadb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Repository files navigation
🦉AthenaDB⚡️
Serverless, distributed Vector Database as an API written with Cloudflare Workers, Workers AI, D1, and Vectorize.
AthenaDB is a simple, serverless, distributed vector database that can be used as an API. It is written with Cloudflare Workers AI, D1, Vectorize.
Features
- Simple API endpoints for inserting, querying, retrieving, and deleting vector text data.
- Embedding generation without storing the text in the database.
- Distributed database with data replication across multiple data centers.
Getting Started
- Downloads and install Wrangler.
- Log in to Wrangler with
wrangler login
. AthenaDB requires a $5/month Workers subscription to function. - Run the following commands:
git clone https://github.com/TimeSurgeLabs/athenadb.git
cd athenadb
npm run create-vector
npm run create-db
Copy the output Database ID and paste it in wrangler.toml
under database_id
. Then, run the following two commands:
npm run init-db
npm run deploy
You should get an output with your API URL. You can now use the API endpoints.
API Endpoints
POST /:namespace/insert
Inserts text data into the database. Text is converted into embeddings using Cloudflare AI and stored along with a unique identifier.
- Request Body:
input
: A single string (max 1024 characters).inputs
: An array of strings (each max 1024 characters).
POST /:namespace/query
Queries the database for similar text embeddings. Specify ?limit=number
in the URL to specify the number of results to return. The default is 5, the maximum is 20.
- Request Body:
input
: A single string for querying. (max 1024 characters)inputs
: An array of strings for batch querying. (each max 1024 characters)
GET /:namespace/:uuid
Retrieves a specific entry from the database using its unique identifier (UUID). Add query parameters ?vector=true
to retrieve the vector along with the entry. Add query parameters ?db_id=true
to retrieve the SQL table ID along with the entry.
GET /:namespace?limit=10&offset=0
Retrieves all entries from the given namespace. Limit can be set to a maximum of 100 entries. Add query parameters ?vector=true
to retrieve the vectors along with the entries. Add query parameters ?db_id=true
to retrieve the SQL table ID along with the entries.
DELETE /:namespace/:uuid
Deletes a specific entry from the database using its unique identifier (UUID). Warning: This action is irreversible.
DELETE /:namespace
Deletes all entries from the given namespace. Warning: This action is irreversible.
POST /embeddings
Generates embeddings for given text without storing it in the database.
- Request Body:
text
: A string whose embedding is to be generated.
GET /
A test endpoint that returns 'Hello world!' as a response.
Usage Examples
Inserting Text
fetch('https://athenadb.yourusername.workers.dev/your-namespace/insert', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ input: 'Your text here' })
})
Querying the Database
fetch('https://athenadb.yourusername.workers.dev/your-namespace/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ input: 'Query text' })
})
Retrieving an Entry
fetch('https://athenadb.yourusername.workers.dev/your-namespace/your-uuid', {
method: 'GET'
})
Deleting an Entry
fetch('https://athenadb.yourusername.workers.dev/your-namespace/your-uuid', {
method: 'DELETE'
})
Generating Embeddings
fetch('https://athenadb.yourusername.workers.dev/embeddings', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: 'Your text here' })
})
Clients
Recommend
-
15
Vector Database for Similarity Search This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you....
-
7
How Is Data Processed in a Vector Database? Milvus provid...
-
12
As the core vector execution engine, Knowhere to
-
6
How Does the Milvus Vector Database Ensure Data Security? This...
-
7
Measuring the popularity of different Vector Databases. By Ben Lorica and Leo Meyerovich. Introduction Vector databases and vector search are on the radar of a growing number of technical teams. A key driver is that...
-
6
Guest The vector database is a new kind of database for the AI era
-
9
The most popular vector database for enterprise usersFuel your machine learning deploymentStore, index, and manage massive embedding vectors generated by deep neural networks and other machine learning (ML) mode...
-
14
Experience CozoDB: The Hybrid Relational-Graph-Vector Database - The Hippocampus for LLMs
-
5
SingleStore CEO sees little future for purpose-built vector databases
-
6
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK