The problem
A filename rarely describes everything in an image. Ordinary keyword search cannot match “a diagram of a water cycle” to an unlabeled scan, and a text agent cannot search thousands of images by looking at every file on each question.
How NativePort helps
NativePort connects to Jina’s image-and-text embedding model. It gives each image a numerical representation that can be compared with a written query. Your application stores those representations and retrieves likely matches for the agent to inspect.
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.
Set IMAGE_URL to an accessible image. This example embeds one image and a query in the same vector space and compares them locally.
import os
import requests
BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}
response = requests.post(BASE + "/jina/embeddings", headers=HEADERS,
json={"model": "jina-clip-v2", "normalized": True,
"input": [{"image": os.environ["IMAGE_URL"]},
{"text": "a diagram of a water cycle"}]}, timeout=120)
response.raise_for_status()
vectors = sorted(response.json()["data"], key=lambda item: item["index"])
image_vector, query_vector = [item["embedding"] for item in vectors]
similarity = sum(a * b for a, b in zip(image_vector, query_vector))
print("Similarity:", similarity)For a collection, store each vector with the image ID and URL in your own index. Use the same model and dimensions for queries. A similarity score is not an OCR transcript or proof that a match is correct. See Jina CLIP’s input format.
Tool costs
| Tool used in the example | Price per call |
|---|---|
| Jina CLIP — image 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.