Authentication
API keys and Connect tokens, how they differ, and how to send them.
Every request carries a bearer token:
Authorization: Bearer <token>Two kinds of credential#
| Credential | Prefix | Who it acts as | Who pays |
|---|---|---|---|
| API key | pm_ | You | Your credits |
| Connect access token | pmc_ | A connected user | The user's credits |
Use an API key for your own scripts, backends, and testing. Use a Connect access token when your published app runs models on a user's behalf — that is what makes the run billable to the user and your markup payable to you. See Connect overview.
Creating an API key#
Create keys from your account settings. The full key is shown once, at creation:
pm_9F3k...ZQ2PortModels stores only a hash of the key plus a short preview
(pm_9F3..ZQ2) so you can tell your keys apart in the list. There is no way to
recover a lost key — revoke it and create a new one.
Handling keys safely#
- Keep keys in environment variables or a secret manager, never in source control.
- Use a separate key per deployment so one can be revoked without taking down the others.
- Revoke immediately if a key is exposed; revocation takes effect at once.
- Never put an API key in browser JavaScript — anyone loading your page can read it.
export PORTMODELS_API_KEY="pm_..."
curl https://api.portmodels.com/openai/v1/chat/completions \
-H "Authorization: Bearer $PORTMODELS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek-ai/DeepSeek-V3", "messages": [{"role": "user", "content": "Hello"}]}'Base URL#
https://api.portmodels.comThe OpenAI-compatible surface is mounted under /openai/v1, so a client
library that takes a base URL should be pointed at:
https://api.portmodels.com/openai/v1Failure modes#
| Status | Meaning |
|---|---|
| 401 | Missing header, malformed header, unknown key, revoked key, or revoked connection |
| 403 | Authenticated, but not allowed to do this — for a Connect token, usually a missing scope |
| 429 | Rate limited — honor Retry-After |
A 401 on a Connect token means that token is no longer usable; the app may
still have other active device sessions. Send only the affected login back
through Connect rather than retrying. See
Revocation and token lifetime.