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:
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.
export PMIND_KEY='PMIND...:...'3. List models
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
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.
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):
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
- Stream responses for token-by-token output
- Call tools for function-calling round-trips
- Embed text for retrieval-augmented use cases
- Use the OpenAI SDK directly
- Use the Anthropic SDK, or Claude Code