Skip to main content
The Cloud Platform API lets you do from a script or a coding agent what you do in the NEAR AI Cloud console: create organizations and workspaces, issue API keys, invite members and read usage and spend. Inference (chat completions, responses, images and the like) stays on https://cloud-api.near.ai. All examples use https://cloud-platform.near.ai. Ids such as ORG_ID are UUIDs returned by earlier calls.

Credentials

Calls that need a credential send Authorization: Bearer <credential>. Which credential a call takes depends on the call: Tokens issued by cloud-api are not accepted by cloud-platform. Sign in against cloud-platform as shown below. Unless a section says otherwise, the examples use $ACCESS_TOKEN.

Sign in from a script or agent

GitHub or Google

  1. Open https://cloud-platform.near.ai/v1/auth/github (or /v1/auth/google) in a browser. It redirects to the provider.
  2. After you approve, the provider sends the browser to /v1/auth/callback, which answers with JSON:
  1. Copy access_token and refresh_token into your environment:
After the browser step, refresh from the script until the refresh token expires; then sign in again.

NEAR wallet

Sign a NEP-413 message with your wallet, then post the signature and the payload that was signed:
The response has the same shape as the callback above.

Refresh the access token

When the access token stops working (HTTP 401), exchange the refresh token for a new one:
Every refresh returns a new refresh token and replaces the one you sent. Store the new refresh_token each time. The next refresh must use it.

Sign out and revoke

Revoking NEAR_AI_API_KEY as above deletes that key, so only run it when you want the key gone. /v1/auth/revoke revokes only the credential in the header and answers with its kind and id. To manage your signed-in sessions:

Your account

Returns your profile (id, email, username, display_name, avatar_url, auth_provider) and the organizations and workspaces you belong to, each organization with your role. Use it to find the ids for the calls below. GET /v1/users/me/status checks that the account is in good standing. PUT /v1/users/me/profile with display_name and avatar_url updates your profile.

Organizations and workspaces

An organization owns the balance and the members. Workspaces inside it own API keys.
Names are 1 to 255 characters. A workspace name is unique within its organization. Rename or re-describe with PUT /v1/organizations/{org_id} or PUT /v1/workspaces/{workspace_id} (send only the fields to change). DELETE on the same paths deletes them. Read one with GET /v1/organizations/{org_id} or GET /v1/workspaces/{workspace_id}.

Organization settings

Change settings with PATCH. For each field, leaving it out changes nothing and null restores the default. Only owners and admins can change model restrictions.
The response also lists each model’s long-context state under long_context (read-only).

API keys

API keys belong to a workspace. They authenticate inference requests on https://cloud-api.near.ai.
The response contains the full secret in key (it begins with sk-). It is shown only in this response and cannot be retrieved again. Store it right away.

Members and invitations

Roles are owner, admin and member.
The response has one entry per invitation in results, with success, email_sent and, if it failed, an error.

Accept an invitation

The invited user signs in and then either lists their pending invitations and accepts one by id:
or accepts with the token from the invitation email:
Decline with POST /v1/users/me/invitations/{invitation_id}/decline.

Usage and billing

Reads take the session access token. Dates are ISO 8601; ranges may not exceed 366 days.
Amounts named total_cost and total_spent are in nano-dollars (10^-9 USD); *_display fields are human readable. History for a single key is at GET /v1/workspaces/{workspace_id}/api-keys/{api_key_id}/usage/history.

Cost of individual requests

Each history entry has an inference_id. Inference responses also carry it in the inference-id header. Send up to 10,000 of these ids with an API key (not an access token) to get their costs:
Ids with no usage record come back with a cost of 0 and a warning. Usage can take a few seconds to appear after a request finishes. This call is served by https://cloud-platform.near.ai; the copy on https://cloud-api.near.ai will be removed on 2026-12-07, together with the usage balance endpoint. See the migration guide.

Reporting tokens

A reporting token (rpt-...) is a read-only credential for usage reporting, separate from API keys. Owners and admins manage them with an access token:
The token value is shown only in the create response. See the Usage Reporting API for how reporting tokens are used.

Next steps