NativePort
← All use cases

Make your knowledge searchable by meaning

Create text vectors for semantic search in your own document index.

The problem

Keyword search can miss a useful passage because the question uses different words. A chat model also cannot remember every document in your system between requests. Your agent needs a retrieval step that can find relevant material before it answers.

How NativePort helps

NativePort gives your application access to Jina embeddings, which turn text into numerical representations of its meaning. Store these alongside your documents, then compare a question’s representation to find useful passages for the agent.

Technical implementation

Use Python 3 with requests installed (python -m pip install requests). Set NATIVEPORT_API_KEY in your environment to your NativePort key. Run the snippets on your server, where your key stays private.

This example creates vectors for two passages, then embeds the question with the matching query task.

python
import os
import requests

BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}

def embed(texts, task):
    response = requests.post(BASE + "/jina/embeddings", headers=HEADERS,
        json={"model": "jina-embeddings-v3", "task": task,
              "input": texts, "normalized": True}, timeout=90)
    response.raise_for_status()
    return [item["embedding"] for item in
            sorted(response.json()["data"], key=lambda item: item["index"])]

passages = ["Returns are accepted within 30 days.", "Support opens at nine."]
vectors = embed(passages, "retrieval.passage")
query = embed(["When can I return a purchase?"], "retrieval.query")[0]
scores = [sum(a * b for a, b in zip(query, vector)) for vector in vectors]
best = max(range(len(scores)), key=scores.__getitem__)
print(passages[best])

For larger collections, store vectors in your own vector index such as pgvector or OpenSearch. Keep the same model and dimensions for stored passages and queries; a model change generally requires re-embedding. The chat endpoint does not generate embeddings. See Jina’s routes.

Tool costs

Tool used in the examplePrice per call
Jina — text embeddings $0.0000211 / 1,000 tokens (usage-based)

Prices in USD. Usage-based tools have no fixed per-call price. View pricing.

Let your agent build it

You don’t need to write this code yourself. Copy this page’s link and paste it into your agent. Ask it to follow the guide and implement the feature for you.