The problem
An agent wired to one model provider cannot simply call another provider with the same connection details. Different credentials, request formats, and model names make a model change an integration task rather than a prompt change.
How NativePort helps
NativePort gives your agent one chat interface and an account-specific list of available models. Select the model you want, including supported open-model options, and keep the rest of the conversation flow. You can compare answers using the same prompts before choosing one.
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.
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()
for model in catalog.json()["data"]:
print(model["id"])
def chat(messages):
response = requests.post(BASE + "/inference/v1/chat/completions",
headers=HEADERS,
json={"model": os.environ["NATIVEPORT_MODEL"], "messages": messages,
"max_tokens": 800}, timeout=120)
response.raise_for_status()
return response.json()["choices"][0]["message"]["content"]
answer = chat([{"role": "user", "content": "Explain how a heat pump works in three sentences."}])
print(answer)Set NATIVEPORT_MODEL to another returned ID to try that model. Hugging Face entries use IDs beginning with huggingface/; availability depends on your account. NativePort routes the chosen model explicitly, without automatic fallback. Keep optional parameters within the common inference contract.
Tool costs
| Tool used in the example | Price per call |
|---|---|
| NativePort Inference — chat | 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.