Skip to main content
Portrix uses API key authentication. Every request you send to the Portrix API must include your API key as a Bearer token in the Authorization header. There are no session tokens, OAuth flows, or per-provider credentials to manage — one Portrix key grants access to every model in the catalog.

Getting your API key

1

Open the Portrix dashboard

Go to app.portrix.ai and sign in to your account. If you don’t have an account yet, sign up for free — it only takes a minute.
2

Navigate to API Keys

In the left sidebar, click Settings, then select API Keys.
3

Create a new key

Click Create new key. Enter a descriptive label so you can identify the key later — for example, production, staging, or local-dev. Then click Create.
4

Copy and store your key

Copy the key shown on screen and store it immediately in a password manager or secrets vault.
Your API key is displayed only once, immediately after creation. If you close the dialog without copying it, you’ll need to revoke the key and create a new one. Store it somewhere safe right away.

Using your API key

Include your API key in the Authorization header of every request using the Bearer scheme.

Portrix request headers

In addition to the Authorization header, Portrix accepts several optional headers that give you per-request control over routing and model selection. These headers are optional. When omitted, Portrix uses the model field from the request body and applies your account’s default routing policy.

Environment variables

Hard-coding API keys in source code is a security risk. Instead, store your key in an environment variable and read it at runtime. Set the variable in your shell or in a .env file:
Then load the variable in your application:

Key management

You can create, rename, and revoke API keys at any time from Settings → API Keys in the Portrix dashboard. Rotating a key — Create a new key, update your application to use it, verify the new key works, then revoke the old one. There is no downtime if you update the key in your environment before revoking the previous one. Naming conventions — Use clear, environment-scoped names so you can identify which key belongs to which deployment:

Security best practices

  • Never commit API keys to source control. Add .env to your .gitignore and use a secrets manager (AWS Secrets Manager, HashiCorp Vault, Doppler, etc.) in production.
  • Use environment variables. Read the key from process.env or os.environ rather than inlining it in code.
  • Rotate keys periodically. Establish a regular rotation schedule — quarterly at minimum — and rotate immediately if you suspect a key has been exposed.
  • Use separate keys per environment. Isolating keys by environment (production, staging, development) limits the blast radius of an accidental leak and makes auditing easier.

Error reference