This guide walks you through making a live request to an AI model via Portrix. Whether you prefer the command line, Python, or JavaScript, you’ll have a working request running in under five minutes — with access to 400+ models through a single endpoint.
Before you begin
Prerequisites
- A Portrix API key — grab one at app.portrix.ai
curl installed, or a code editor with Python 3.8+ or Node.js 18+
Using cURL
The fastest way to verify your setup is a raw curl request. Replace YOUR_API_KEY with your actual key:
You should receive a JSON response within a few seconds. If you see a 401 error, double-check that your API key is correct and that you have not included extra whitespace.
Using Python
Install the official OpenAI SDK — Portrix is fully compatible with it:
Then point the client at the Portrix base URL:
Using JavaScript / TypeScript
Install the OpenAI npm package:
Configure the client with the Portrix base URL:
Understanding the response
A successful response follows the standard OpenAI chat completions shape:
The fields you’ll use most often:
Legacy text completions
Portrix also supports the POST /v1/completions endpoint for older integrations that use the non-chat completions format. The request shape mirrors the OpenAI legacy completions API — use a prompt string instead of a messages array:
For all new integrations, prefer POST /v1/chat/completions — it is supported by every model on Portrix and is the format used throughout this documentation.
Switching models
One of Portrix’s core benefits is that changing the underlying model requires updating a single string. Everything else in your code stays identical:
If you already have working OpenAI code, migrating to Portrix requires exactly two changes: set base_url / baseURL to https://api.portrix.ai/v1, and replace your OpenAI key with your Portrix API key. Your prompts, tools, and response-parsing logic need no modifications.