Skip to main content
Every request to the Portrix API must include an API key in the Authorization header as a Bearer token. Without a valid key the API returns a 401 Unauthorized response. Your API key identifies your account, enforces rate limits, and controls which models and features you can access.

Header Format

Include your API key in every request using the following header format:
A full request header block looks like this:
Never include your API key in a URL query parameter. Always pass it in the Authorization header to prevent the key from being logged in server access logs or browser history.

Getting an API Key

1

Create a Portrix account

Sign up for a free account at app.portrix.ai. You can sign in with Google, GitHub, or an email address.
2

Open API key settings

Once you are logged in, navigate to Settings → API Keys in the left sidebar.
3

Create a new key

Click Create new key, give it a descriptive name (e.g. production-backend or local-dev), and set any optional scopes or expiry. Click Create.
4

Copy your key

Copy the key immediately — it is only shown once. Store it securely in a password manager or secrets vault. If you lose it, you must rotate it and update all references.

Using the Key

The examples below show how to authenticate using cURL, the Python openai SDK, and the JavaScript openai SDK. In every case you only need to point the client at the Portrix base URL and supply your key.
Store your API key in an environment variable named PORTRIX_API_KEY. The examples above read the key from the environment so it never appears in your source code.

Security Best Practices

Follow these guidelines to keep your API keys secure:
  • Use environment variables — never hard-code keys in source files. Use .env files locally and your platform’s secrets manager in production (e.g. AWS Secrets Manager, Vercel Environment Variables, GitHub Actions secrets).
  • Never commit keys to version control — add .env to your .gitignore and audit your repository history if you suspect a key was exposed.
  • Rotate keys regularly — treat API keys like passwords. Rotate them periodically, and immediately rotate any key you suspect has been compromised.
  • Use one key per environment — create separate keys for development, staging, and production so you can revoke a single environment’s access without disrupting others.
  • Restrict key scopes — when creating a key, grant only the permissions required for that key’s use case. Avoid using an unrestricted admin key in application code.

Authentication Errors

If you receive a 401, double-check that your key is correctly copied and that the Authorization: Bearer prefix is present. If you receive a 403, review the key’s scopes in Settings → API Keys or contact support to request elevated permissions. See the Errors reference for the full list of error codes and response formats.