Authentication
API keys, Connect tokens and sign-in tokens for model and customer actions.
Every request carries a bearer token:
Authorization: Bearer <token>Credentials for OpenAI-compatible endpoints#
| 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/v1Authentication for video jobs#
Persistent image-to-video jobs use POST /run, a separate
action API. The ai.media.* actions accept a pmc_ Connect token with
models.run consent, a pm_ API key with the required media permission, or
the short-lived account token returned by auth.login. API-key spending
limits apply to the job's reservation and final cost. Connected jobs are
pinned to the verified app; another app cannot read or cancel them.
Connected customer actions#
Connect tokens can call all registered customer actions through POST /run
with the appropriate consent and the user's current permissions. models.run
covers AI actions, including video. The account.manage scope enables the
other customer account and developer features, including API keys and billing.
Apps must enable and request that scope and obtain consent before using it;
existing model-only grants are not silently expanded. File, KV and diagnostic
endpoints keep their documented scopes. See Connect scopes.
Administrative and moderator actions are never available through Connect, even when the connected user is an administrator. API keys created through Connect also exclude administrative and moderator permissions.
OpenAI-compatible failure 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.