Get API key

Quickstart

Make your first PrivateMind API request in five minutes.

Set two environment variables and you're done.

1. Get an API key

Sign in to PrivateMind, open Settings → API Keys, and click Create key. Give it a name, set a budget cap, and copy the secret immediately. It isn't shown again.

Keys are split into two parts:

Text
PMIND...:...

The part before the colon is the ID (starts with PMIND), and the part after is the secret. The full string, both halves together, is the bearer token.

2. Set your key

The rest of this site uses https://api.privatemind.com as the base URL.

cURL
export PMIND_KEY='PMIND...:...'

3. List models

cURL
curl -s "https://api.privatemind.com/v1/models" \
  -H "Authorization: Bearer $PMIND_KEY" \
  | jq '.data[] | {id, context_length, supported_parameters}'

The list reflects what's actually deployed and what your org can call. Pick a model id for the next step.

4. Make a chat completion

Tip

We use the fast alias here, which automatically points to the most efficient model available in your environment. See Models for more details on aliases.

curl -s "https://api.privatemind.com/v1/chat/completions" \
  -H "Authorization: Bearer $PMIND_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fast",
    "messages": [{"role": "user", "content": "Summarise CAP theorem in one sentence."}]
  }'
from openai import OpenAI

client = OpenAI(base_url="https://api.privatemind.com/v1", api_key=PMIND_KEY)
resp = client.chat.completions.create(
    model="fast",
    messages=[{"role": "user", "content": "Summarise CAP theorem in one sentence."}],
)
print(resp.choices[0].message.content)
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: `https://api.privatemind.com/v1`,
  apiKey: process.env.PMIND_KEY,
});
const resp = await client.chat.completions.create({
  model: 'fast',
  messages: [{ role: 'user', content: 'Summarise CAP theorem in one sentence.' }],
});
console.log(resp.choices[0].message.content);

Response is the standard OpenAI chat.completion envelope: choices[0].message.content plus a usage block.

Tip

The official OpenAI SDKs (Python, Node, Go, anything that takes a base_url) work against PrivateMind unchanged. Point them at https://api.privatemind.com/v1 and pass your PMIND key as the API key. See OpenAI SDK compatibility for the matrix of what's supported.

Or use the Anthropic shape

The same key and models also answer the Anthropic Messages API. Point an Anthropic SDK at https://api.privatemind.com (no /v1):

Python
import anthropic

client = anthropic.Anthropic(base_url="https://api.privatemind.com", api_key=PMIND_KEY)
message = client.messages.create(
    model="fast",
    max_tokens=400,
    messages=[{"role": "user", "content": "Summarise CAP theorem in one sentence."}],
)
print(next(b.text for b in message.content if b.type == "text"))

See Messages API and Anthropic SDK.

Where next