The problem
A text-only model cannot inspect a photograph or diagram just because its URL appears in the prompt. OCR can read visible words, but it may miss the relationship between objects, page layout, or the visual cues that distinguish a receipt from a form.
How NativePort helps
NativePort gives your agent access to models that can examine images. Send the picture with a question, and the model can describe what it sees or suggest a document category. Select a model with image support rather than assuming every model can see.
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.
Choose an available model with GET /inference/v1/models and set its full provider/model ID as NATIVEPORT_MODEL. The examples use the common text chat endpoint; they do not assume access to a particular model.
Set IMAGE_URL to an accessible image. This checks the chosen model’s vision capability before sending it.
import os
import requests
BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}
catalog = requests.get(BASE + "/inference/v1/models", headers=HEADERS, timeout=30)
catalog.raise_for_status()
model = next(item for item in catalog.json()["data"]
if item["id"] == os.environ["NATIVEPORT_MODEL"])
if not model.get("capabilities", {}).get("vision"):
raise ValueError("Choose a model with capabilities.vision = true")
response = requests.post(BASE + "/inference/v1/chat/completions", headers=HEADERS,
json={"model": model["id"], "max_tokens": 500,
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Classify this as receipt, form, chart, or other. Explain the visible evidence; say if unclear."},
{"type": "image_url", "image_url": {"url": os.environ["IMAGE_URL"]}},
]}]}, timeout=120)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])For exact field extraction, use a document schema instead. Vision answers may miss small text or infer details, so ask the model to distinguish visible evidence from uncertainty. See supported image inputs.
Tool costs
| Tool used in the example | Price per call |
|---|---|
| NativePort Inference — vision | Varies by selected model and token usage |
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.