Vector
Managed vector store (RAG): collections + upsert/query/delete, self-hosted on pgvector by default.
Overview
https://api.infrai.cc/v1/vectorAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/vector capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/vector/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"Methods
vector.collection.create
Create a vector collection (namespace) for an embedding dimension and distance metric — the container for RAG vectors. Self-hosted on pgvector by default; free management.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
collection | string | Required | Collection (namespace) name. |
dimension | number | Required | Embedding vector dimension (required on create; must match the embeddings you upsert). |
metric | "cosine" | "euclidean" | "dotproduct" | Optional | Distance metric: cosine (default), euclidean, or dotproduct. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
Collection { collection, dimension, metric, vector_count, state }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/vector/collection/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"collection": "...", "dimension": 0}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/vector/collection/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'collection': '...', 'dimension': 0},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "dimension": 0}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "dimension": 0}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);vector.upsert
Insert or update vectors (id + embedding + metadata) into a collection. Pair ai.embed → vector.upsert for one-stop RAG ingestion. Billable work-action.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
collection | string | Required | Collection (namespace) name. |
vectors | Array<{ id, embedding: number[], metadata? }> | Required | Vectors to write: each carries an id, an embedding (number[]) and optional metadata. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
UpsertResult { collection, upserted }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/vector/upsert \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"collection": "...", "vectors": []}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/vector/upsert",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'collection': '...', 'vectors': []},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/vector/upsert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "vectors": []}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/vector/upsert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "vectors": []}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);vector.query
Run an approximate nearest-neighbor (ANN) similarity search over a collection, returning the top-k closest vectors with scores and metadata. Billable work-action.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
collection | string | Required | Collection (namespace) name. |
embedding | number[] | Required | Query embedding vector — the nearest neighbors of this point are returned. |
top_k | number | Optional | Number of nearest matches to return (default 10). |
filter | Record<string, unknown> | Optional | Optional metadata filter applied before the similarity search. |
Returns
QueryResult { collection, matches: Array<{ id, score, metadata? }> }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/vector/query \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"collection": "...", "embedding": []}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/vector/query",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'collection': '...', 'embedding': []},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/vector/query",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "embedding": []}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/vector/query",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "embedding": []}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);vector.collection.get
Fetch a vector collection's configuration (dimension, metric, vector count). Free management read.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
collection | string | Required | Collection (namespace) name. |
Returns
Collection { collection, dimension, metric, vector_count, state }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/vector/collection/get \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/vector/collection/get",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/get",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/get",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);vector.collection.list
List the account's vector collections. Free management read.
Returns
{ collections: Collection[] }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/vector/collection/list \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/vector/collection/list",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);vector.collection.delete
Delete a vector collection and all its vectors. Free management (idempotent).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
collection | string | Required | Collection (namespace) name. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
CollectionDeleteResult { collection, deleted }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X DELETE https://api.infrai.cc/v1/vector/collection/delete \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/vector/collection/delete",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);vector.delete
Delete specific vectors by id from a collection. Free management.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
collection | string | Required | Collection (namespace) name. |
ids | string[] | Required | Vector ids to delete from the collection. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
DeleteResult { collection, deleted }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X DELETE https://api.infrai.cc/v1/vector/delete \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/vector/delete",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/vector/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/vector/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);All capabilities
Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.
| Capability | Endpoint | Description |
|---|---|---|
vector.collection.create | POST /v1/vector/collection/create | Create a vector collection (namespace) for an embedding dimension and distance metric — the container for RAG vectors. Self-hosted on pgvector by default; free management. |
vector.collection.delete | DELETE /v1/vector/collection/delete | Delete a vector collection and all its vectors. Free management (idempotent). |
vector.collection.get | GET /v1/vector/collection/get | Fetch a vector collection's configuration (dimension, metric, vector count). Free management read. |
vector.collection.list | GET /v1/vector/collection/list | List the account's vector collections. Free management read. |
vector.delete | DELETE /v1/vector/delete | Delete specific vectors by id from a collection. Free management. |
vector.query | POST /v1/vector/query | Run an approximate nearest-neighbor (ANN) similarity search over a collection, returning the top-k closest vectors with scores and metadata. Billable work-action. |
vector.upsert | POST /v1/vector/upsert | Insert or update vectors (id + embedding + metadata) into a collection. Pair ai.embed → vector.upsert for one-stop RAG ingestion. Billable work-action. |
End-to-end example
A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.
A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.
#!/usr/bin/env python3
"""Infrai · vector — runnable real-app example (single file, zero deps).
Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request
KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..." # <- your key
BASE = "https://api.infrai.cc"
# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
req = request.Request(
BASE + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json"})
try:
with request.urlopen(req, timeout=60) as r:
return json.loads(r.read())
except error.HTTPError as e:
return json.loads(e.read())
def show(label, resp):
print(f"\n== {label} ==")
print(json.dumps(resp, indent=2, ensure_ascii=False))
return resp
# 1) vector.collection.create — POST /v1/vector/collection/create · Create a vector collection (namespace) for an embedding dimension and distance metric — the container for RAG vectors. Self-hosted on pgvector by default; free management.
r1 = show("vector.collection.create", infrai("POST", "/v1/vector/collection/create", {"collection":"docs","dimension":3,"metric":"cosine"}))
# 2) vector.upsert — POST /v1/vector/upsert · Insert or update vectors (id + embedding + metadata) into a collection. Pair ai.embed → vector.upsert for one-stop RAG ingestion. Billable work-action.
r2 = show("vector.upsert", infrai("POST", "/v1/vector/upsert", {"collection":"docs","vectors":[{"id":"a","embedding":[0.1,0.2,0.3],"metadata":{"title":"intro"}}]}))
# 3) vector.query — POST /v1/vector/query · Run an approximate nearest-neighbor (ANN) similarity search over a collection, returning the top-k closest vectors with scores and metadata. Billable work-action.
r3 = show("vector.query", infrai("POST", "/v1/vector/query", {"collection":"docs","embedding":[0.1,0.2,0.3],"top_k":3}))
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at https://infrai.cc/login for a
# project key + $2 free credit (email sign-in starts at $0). On 402
# INSUFFICIENT_CREDIT, add funds at https://infrai.cc/billing (or POST
# /v1/account/topup and open the returned checkout_url).
export INFRAI_API_KEY="ifr_..." # from https://infrai.cc/login
# 2) vector.collection.create
curl -X POST https://api.infrai.cc/v1/vector/collection/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"collection": "...", "dimension": 0}'
# 3) vector.upsert
curl -X POST https://api.infrai.cc/v1/vector/upsert \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"collection": "...", "vectors": []}'
# 4) vector.query
curl -X POST https://api.infrai.cc/v1/vector/query \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"collection": "...", "embedding": []}'
# 5) vector.collection.get
curl -X GET https://api.infrai.cc/v1/vector/collection/get \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 6) vector.collection.list
curl -X GET https://api.infrai.cc/v1/vector/collection/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 7) vector.collection.delete
curl -X DELETE https://api.infrai.cc/v1/vector/collection/delete \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 8) vector.delete
curl -X DELETE https://api.infrai.cc/v1/vector/delete \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 1) Auth: every call is a raw HTTPS request carrying only your project key.
# No SDK to install — just the `requests` library.
import os, requests
BASE = "https://api.infrai.cc"
HEADERS = {
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Content-Type": "application/json",
}
# 2) vector.collection.create
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/vector/collection/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'collection': '...', 'dimension': 0},
)
resp.raise_for_status()
print(resp.json())
# 3) vector.upsert
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/vector/upsert",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'collection': '...', 'vectors': []},
)
resp.raise_for_status()
print(resp.json())
# 4) vector.query
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/vector/query",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'collection': '...', 'embedding': []},
)
resp.raise_for_status()
print(resp.json())
# 5) vector.collection.get
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/vector/collection/get",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 6) vector.collection.list
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/vector/collection/list",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 7) vector.collection.delete
import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/vector/collection/delete",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 8) vector.delete
import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/vector/delete",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch().
const BASE = "https://api.infrai.cc";
const HEADERS = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) vector.collection.create
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "dimension": 0}),
},
);
console.log(await resp.json());
// 3) vector.upsert
const resp = await fetch(
"https://api.infrai.cc/v1/vector/upsert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "vectors": []}),
},
);
console.log(await resp.json());
// 4) vector.query
const resp = await fetch(
"https://api.infrai.cc/v1/vector/query",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "embedding": []}),
},
);
console.log(await resp.json());
// 5) vector.collection.get
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/get",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 6) vector.collection.list
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 7) vector.collection.delete
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 8) vector.delete
const resp = await fetch(
"https://api.infrai.cc/v1/vector/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch(), typed.
const BASE = "https://api.infrai.cc";
const HEADERS: Record<string, string> = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) vector.collection.create
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "dimension": 0}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 3) vector.upsert
const resp = await fetch(
"https://api.infrai.cc/v1/vector/upsert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "vectors": []}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 4) vector.query
const resp = await fetch(
"https://api.infrai.cc/v1/vector/query",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"collection": "...", "embedding": []}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 5) vector.collection.get
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/get",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 6) vector.collection.list
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 7) vector.collection.delete
const resp = await fetch(
"https://api.infrai.cc/v1/vector/collection/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 8) vector.delete
const resp = await fetch(
"https://api.infrai.cc/v1/vector/delete",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);