You need an API key and curl. The examples also show Python and TypeScript.
1. Get an API key
Sign in to PrivateMind, open API Keys in the sidebar, and click Create key. Give it a name, set a budget cap, and copy the secret immediately. It isn't shown again.
A key has two parts:
PMIND...:...The part before the colon is the key ID, which starts with PMIND. The part after it is the secret. You send the whole string as the bearer token.
2. Set your key
Every example on this site uses the base URL https://api.privatemind.com.
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}'You see only the models your organisation can call. Pick an id for the next step.
4. Make a chat completion
This example uses the fast alias, which points to the most efficient model in your environment. Models lists the other 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);You get back a standard OpenAI chat.completion object. The answer is in choices[0].message.content and the token counts are in usage.
Any OpenAI SDK that takes a base URL works unchanged, including the official Python, Node and Go SDKs. Set the base URL to https://api.privatemind.com/v1 and use your PMIND key as the API key. OpenAI SDK shows 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, without /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 search and retrieval
- Use the OpenAI SDK directly
- Use the Anthropic SDK, or Claude Code