Docs

AI21 Labs API Authentication

How to authenticate AI21 Labs API requests: one Bearer API key plus a connectionId. MindCloud stores your API key securely — set it once, never resend it.

Every AI21 Labs API request through MindCloud needs two things: a MindCloud API Key and a connectionId for your AI21 Labs account. This page covers both, plus exactly how to send them, so you do not need to visit any other page to get authenticated.

Steps to authenticate

  1. Create a MindCloud account at app.mindcloud.co if you do not already have one.
  2. Generate a MindCloud API Key in API Keys. This is the Bearer token you send on every request. Keep it on your server.
  3. Create a AI21 Labs connection in Connections. AI21 Labs uses an API key. You generate the key in your AI21 Labs account, then paste it in when you create the connection — MindCloud stores it securely and never returns it in a response.
  4. Copy the connection’s connectionId — you will send it on every request alongside your MindCloud API Key.

How requests are authenticated

Authentication has two layers. Your MindCloud API Key authenticates the request to MindCloud, sent as a Bearer token in the Authorization header. The connectionId selects the connected AI21 Labs account that should run the action. MindCloud stores and refreshes the AI21 Labs credentials behind that connection, so you never send provider tokens with your requests.

Pass connectionId in the query string for GET and DELETE actions, and in the JSON body for POST, PUT, and PATCH actions.

For example, calling List Library Files with an AI21 Labs connection looks like this:

curl --request POST \
  --url "https://connect.mindcloud.co/v2/universal/apps/aI21Labs/actions/list-library-files/run" \
  --header "Authorization: Bearer $MINDCLOUD_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "connectionId": "$CONNECTION_ID",
  "arguments": {}
}'

The Authorization: Bearer <your MindCloud API Key> header authenticates you to MindCloud; the connectionId tells MindCloud which AI21 Labs account to run the action against. Missing or invalid Authorization returns 401, and a missing or mismatched connectionId returns 400.

Connect AI21 Labs

You need an active AI21 Studio workspace and permission to create API keys.

  1. Sign in to AI21 Studio

    Open AI21 Studio and sign in with the workspace that owns the API usage you want this connection to use.

    AI21 Studio
  2. Open Workspace Settings

    From the left sidebar, open Settings for the current workspace.

  3. Open the API Keys tab

    In Workspace Settings, select the API Keys tab.

  4. Create a new API key

    Click Create new key, optionally give it a name, then create the key.

  5. Copy the API key into MindCloud

    Paste the new API key into the MindCloud test connection API key field and save the connection.

Keep your key safe

Keep your MindCloud API Key on your server; do not ship it in browser code, mobile apps, public repositories, or logs. Anyone with the key can call the Universal API as your MindCloud account, across every connection you have created.