API reference

Privatemode supports API endpoints that are compatible with the OpenAI API and the Anthropic API. We like to highlight that we don't use any OpenAI or Anthropic services but only follow their interface definitions. Create and manage your API keys in the Privatemode portal.

Connect to Privatemode

Choose the setup for your application's language.

For JavaScript and TypeScript applications, we recommend the Privatemode SDK. It connects directly to Privatemode without a local proxy and handles remote attestation and end-to-end encryption in your application.

Install the SDK:

npm i privatemode-ai

Create a client with your Privatemode API key:

import { PrivatemodeAI } from 'privatemode-ai';

const client = new PrivatemodeAI({
  apiKey: process.env.PRIVATEMODE_API_KEY!,
});

The client exposes the familiar OpenAI interface. See the SDK getting started guide for a complete request, streaming, and the supported resources.

For other languages and third-party integrations, use the Privatemode proxy. It exposes a local OpenAI-compatible and Anthropic-compatible API while handling remote attestation and end-to-end encryption.

Base URL

With a proxy running on your machine, the base URL is:

http://localhost:8080

All endpoints are served under the /v1 prefix. For more information on how the proxy works, see the architecture documentation and the Privatemode proxy guide.

Authentication

The recommended way to authenticate is to configure the proxy with your API key via --apiKey. The proxy then authenticates all requests for you, and the api_key field of client SDKs only needs a placeholder value.

Alternatively, start the proxy without an API key and pass your key with each request in the Authorization header. The proxy forwards the header to the Privatemode API:

Authorization: Bearer <your-api-key>

Using the OpenAI SDKs

Since the API is OpenAI-compatible, you can use the official OpenAI SDKs by pointing them at your proxy:

from openai import OpenAI

client = OpenAI(
    api_key="<your-api-key>",  # or a placeholder if the proxy is configured with --apiKey
    base_url="http://localhost:8080/v1",
)
import (
	"github.com/openai/openai-go/v3"
	"github.com/openai/openai-go/v3/option"
)

client := openai.NewClient(
	// The API key only needs a placeholder if the proxy is configured with --apiKey.
	option.WithAPIKey("<your-api-key>"),
	option.WithBaseURL("http://localhost:8080/v1"),
)

Endpoints

OpenAI-compatible

Anthropic-compatible