Skip to main content

Docs · Using the API

Use PearPie from your own tools

PearPie speaks the same API as OpenAI and Anthropic. So any tool built for those (Claude Code, the OpenAI SDK, your own scripts) can talk to PearPie instead, and reach your local models or the PearPie Network. This is the one developer-oriented guide: it has a little setup and a couple of commands.

What it is

While PearPie is running on your computer, it quietly offers an API on this device that looks exactly like the OpenAI and Anthropic ones. If you already have a tool that talks to those services, you can point it at PearPie and everything keeps working, except that the request now runs on your own machine or over your private PearPie Network instead of going straight to a provider.

It's the same engine the PearPie app uses, just reachable from your own code.

Where it lives

The API listens on this device only, at:

http://127.0.0.1:8787

It's loopback-only on purpose: nothing on your network or the internet can reach it, so your requests never leave the machine except over PearPie's own encrypted connections. (The port can be changed with the PEARPIE_API_PORT setting.)

You can pass an API key, but for local use it's optional; anything is accepted because the endpoint is already private to your machine. If you set PEARPIE_LOCAL_API_KEY, send it as a Bearer token or an x-api-key header. Either way, that key is only used to reach PearPie; it's never forwarded to a provider.

Two ways to talk to it

PearPie answers on both API styles:

  • POST /v1/messages — the Anthropic style (what Claude Code and Anthropic SDKs use).
  • POST /v1/chat/completions — the OpenAI style (what the OpenAI SDK and most other tools use).

Here's the nice part: it doesn't matter which style your tool speaks — every PearPie model is reachable from either one. You can drive Mistral, a local model, or anything else from an Anthropic-style tool, or use Claude from an OpenAI-style one. PearPie translates between them for you. (There's also GET /v1/models to list what's available, and GET /health.)

Picking a model (important)

Your tool chooses the model by the name it sends in the request. PearPie routes on that name, so it has to be a name PearPie knows: one of its own model ids. A name PearPie doesn't recognise is turned away rather than guessed at.

To see the exact ids you can use right now, ask the API:

curl http://127.0.0.1:8787/v1/models

That list is the source of truth, and it includes both kinds of model:

  • Local models (e.g. a Gemma or Qwen build) run on this device, free and private. If the model isn't loaded yet, the first request waits while PearPie loads it.
  • Premium models (e.g. Claude, larger Mistral or DeepSeek builds) run on the PearPie Network and cost credits. See pricing →

The one thing to watch: some tools default to their own model names. Claude Code, for example, ships with dated Anthropic model strings. Those won't match a PearPie id, so set your tool's model to a PearPie id explicitly (whatever /v1/models shows). Once you do, that model works through either API style.

Example: Claude Code

Point Claude Code at PearPie with three environment variables (the base URL, any token, and a PearPie model id):

ANTHROPIC_BASE_URL=http://127.0.0.1:8787 \
ANTHROPIC_AUTH_TOKEN=local \
ANTHROPIC_MODEL=mistral-small \
ANTHROPIC_SMALL_FAST_MODEL=mistral-small \
  claude

Swap mistral-small for any id from /v1/models: a Claude model, a local model, whatever you like. (If you set a PEARPIE_LOCAL_API_KEY, use that as the ANTHROPIC_AUTH_TOKEN instead of local.)

Example: an OpenAI client

Anything that speaks the OpenAI API works the same way — just point its base URL at PearPie and use a PearPie model id:

curl http://127.0.0.1:8787/v1/chat/completions \
  -H "Authorization: Bearer local" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "stream": true,
    "messages": [{"role": "user", "content": "Say hello."}]
  }'

This reaches a PearPie Network model from an OpenAI-style request — the cross-style translation happens inside PearPie.

Good to know

  • Privacy holds. Local models never leave this device. Network models run privately on European infrastructure; your message is discarded after the reply and nothing is stored.
  • Credits. Local models are free; PearPie Network models draw from your credit balance, the same as in the app.
  • Prompt caching just works. For tools that use it (like Claude Code against a Claude model), the request is passed through untouched so provider-side caching keeps saving you tokens.
  • It's local-first. The API is only there while PearPie is running, and only on this machine.