PortModels
Log in

Authentication

API keys and Connect tokens, how they differ, and how to send them.

Every request carries a bearer token:

text
Authorization: Bearer <token>

Two kinds of credential#

CredentialPrefixWho it acts asWho pays
API keypm_YouYour credits
Connect access tokenpmc_A connected userThe 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:

text
pm_9F3k...ZQ2

PortModels 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.
bash
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#

text
https://api.portmodels.com

The OpenAI-compatible surface is mounted under /openai/v1, so a client library that takes a base URL should be pointed at:

text
https://api.portmodels.com/openai/v1

Failure modes#

StatusMeaning
401Missing header, malformed header, unknown key, revoked key, or revoked connection
403Authenticated, but not allowed to do this — for a Connect token, usually a missing scope
429Rate 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.