Skip to content

Vector

Managed vector store (RAG): collections + upsert/query/delete, self-hosted on pgvector by default.

1. Overview

Base path: https://api.infrai.cc/v1/vector
Auth header: Authorization: Bearer $INFRAI_API_KEY
bash
# 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"

2. Methods (7)

2.1vector.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.

Parameters

NameTypeRequiredDescription
collectionstring
Required
Collection (namespace) name.
dimensionnumber
Required
Embedding vector dimension (required on create; must match the embeddings you upsert).
≥ 1
metric"cosine" | "euclidean" | "dotproduct"OptionalDistance metric: cosine (default), euclidean, or dotproduct.
default: "cosine"
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

Collection { collection, dimension, metric, vector_count, state }
NameTypeDescription
collectionstringName of the collection
dimensionintegerDimension of the vector embeddings
metricstringDistance metric for similarity search (cosine, euclidean, dotproduct)
vector_countintegerNumber of vectors currently stored in the collection
statestringCollection lifecycle state (ready, pending, failed)
raw_vendor_payloadobjectRaw vendor-native payload, when the vendor adapter surfaces one

Example

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X POST https://api.infrai.cc/v1/vector/collection/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"collection": "sample", "dimension": 1}'

2.2vector.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.

Parameters

NameTypeRequiredDescription
collectionstring
Required
Collection (namespace) name.
vectorsArray<{ id, embedding: number[], metadata? }>
Required
Vectors to write: each carries an id, an embedding (number[]) and optional metadata.
≥ 1 item
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

UpsertResult { collection, upserted }
NameTypeDescription
okbooleanWhether the upsert succeeded
idstring | nullIdentifier of the upserted vector

Example

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X POST https://api.infrai.cc/v1/vector/upsert \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"collection": "sample", "vectors": [{"id": "sample", "embedding": [1.0]}]}'

2.3vector.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.

Parameters

NameTypeRequiredDescription
collectionstring
Required
Collection (namespace) name.
embeddingnumber[]
Required
Query embedding vector — the nearest neighbors of this point are returned.
top_knumberOptionalNumber of nearest matches to return (default 10).
≥ 1default: 10
filterRecord<string, unknown>OptionalOptional metadata filter applied before the similarity search.

Returns

QueryResult { collection, matches: Array<{ id, score, metadata? }> }
NameTypeDescription
itemsobject[]List of matching vectors with scores
next_cursorstring | nullCursor for next page; null if last page

Example

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X POST https://api.infrai.cc/v1/vector/query \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"collection": "sample", "embedding": [1.0]}'

2.4vector.collection.get

GET /v1/vector/collection/get

Fetch a vector collection's configuration (dimension, metric, vector count). Free management read.

Parameters

NameTypeRequiredDescription
collectionstring
Required
Collection (namespace) name.

Returns

Collection { collection, dimension, metric, vector_count, state }
NameTypeDescription
collectionstringName of the collection
dimensionintegerDimension of the vector embeddings
metricstringDistance metric for similarity search (cosine, euclidean, dotproduct)
vector_countintegerNumber of vectors currently stored in the collection
statestringCollection lifecycle state (ready, pending, failed)
raw_vendor_payloadobjectRaw vendor-native payload, when the vendor adapter surfaces one

Example

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X GET https://api.infrai.cc/v1/vector/collection/get \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.5vector.collection.list

GET /v1/vector/collection/list

List the account's vector collections. Free management read.

Returns

{ collections: Collection[] }
NameTypeDescription
collectionsobject[]List of collection records
collections[].collectionstringName of the collection
collections[].dimensionintegerDimension of the vector embeddings
collections[].metricstringDistance metric for similarity search (cosine, euclidean, dotproduct)
collections[].vector_countintegerNumber of vectors currently stored in the collection
collections[].statestringCollection lifecycle state (ready, pending, failed)
collections[].raw_vendor_payloadobjectRaw vendor-native payload, when the vendor adapter surfaces one
raw_vendor_payloadobjectRaw vendor-native payload, when the vendor adapter surfaces one

Example

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X GET https://api.infrai.cc/v1/vector/collection/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.6vector.collection.delete

DELETE /v1/vector/collection/delete

Delete a vector collection and all its vectors. Free management (idempotent).

Parameters

NameTypeRequiredDescription
collectionstring
Required
Collection (namespace) name.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

CollectionDeleteResult { collection, deleted }
NameTypeDescription
collectionstringName of the deleted collection
deletedintegerNumber of vectors freed by the collection drop
raw_vendor_payloadobjectRaw vendor-native payload, when the vendor adapter surfaces one

Example

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X DELETE https://api.infrai.cc/v1/vector/collection/delete \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.7vector.delete

DELETE /v1/vector/delete

Delete specific vectors by id from a collection. Free management.

Parameters

NameTypeRequiredDescription
collectionstring
Required
Collection (namespace) name.
idsstring[]
Required
Vector ids to delete from the collection.
≥ 1 item
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

DeleteResult { collection, deleted }
NameTypeDescription
okbooleanWhether the vector was deleted
idstring | nullIdentifier of the deleted vector

Example

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X DELETE https://api.infrai.cc/v1/vector/delete \
  -H "Authorization: Bearer $INFRAI_API_KEY"

3. 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.

vector.collection.createPOST /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.

Parameters (4)
NameTypeRequiredDescription
collectionstringRequiredCollection name (unique per account).
dimensionintegerRequiredEmbedding vector dimension (e.g. 1536 for text-embedding-3-small).
≥ 1
metric"cosine" | "euclidean" | "dotproduct"OptionalDistance metric used for similarity search.
default: "cosine"
metadataobject | nullOptionalOptional free-form collection metadata.
vector.collection.deleteDELETE /v1/vector/collection/delete

Delete a vector collection and all its vectors. Free management (idempotent).

No request parameters.

vector.collection.getGET /v1/vector/collection/get

Fetch a vector collection's configuration (dimension, metric, vector count). Free management read.

No request parameters.

vector.collection.listGET /v1/vector/collection/list

List the account's vector collections. Free management read.

No request parameters.

vector.deleteDELETE /v1/vector/delete

Delete specific vectors by id from a collection. Free management.

Parameters (2)
NameTypeRequiredDescription
collectionstringRequiredCollection containing the vectors.
idsstring[]RequiredVector ids to delete.
≥ 1 item
vector.queryPOST /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.

Parameters (5)
NameTypeRequiredDescription
collectionstringRequiredCollection to search.
embeddingnumber[]RequiredQuery embedding; length must equal the collection dimension.
top_kintegerOptionalNumber of nearest neighbors to return.
≥ 1default: 10
filterobject | nullOptionalOptional metadata filter (exact-match keys, e.g. source= "docs").
include_metadatabooleanOptionalInclude each match's stored metadata in the result.
default: true
vector.upsertPOST /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.

Parameters (2)
NameTypeRequiredDescription
collectionstringRequiredTarget collection name.
vectorsobject[]RequiredVectors to upsert (same id overwrites).
≥ 1 item

4. 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.

python
#!/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}))