Fetch the complete documentation index at https://www.nativecluster.com/llms.txt

# How do I connect any OpenAI-compatible tool?

> On a Mac running NativeCluster, `nativecluster env` writes a base URL and a key to a file only you can read. Source it, and any tool or library that reads `OPENAI_BASE_URL` and `OPENAI_API_KEY` uses your cluster's models, with no second sign-in.

## Set it up

```sh
nativecluster env
. '<the path it printed>'
```

`env` prints `OPENAI_BASE_URL=http://localhost:8487/v1` and the path of its file, never the key. Sourcing the file sets:

| Variable | Value |
|---|---|
| `OPENAI_BASE_URL` | `http://localhost:8487/v1` |
| `OPENAI_API_KEY` | your session for NativeCluster's own tool (`nct_…`) |
| `NATIVECLUSTER_API_KEY` | the same session, for tools configured by name |

Never print, paste, log or commit the key. Source the file in the shell that starts your tool, rather than copying the key anywhere.

## Check it

```sh
curl -s "$OPENAI_BASE_URL/models" -H "Authorization: Bearer $OPENAI_API_KEY"
```

It lists the chat models that can code, the best coder first. If none of the cluster's computers can run a model that codes, it answers `503` `no_model_fits`; a call that names a chat model still works.

## Libraries that read these variables

By their own source code, as of 2026-11-13:

- **OpenAI's Python library** (`openai`): `OpenAI()` reads `OPENAI_BASE_URL` and `OPENAI_API_KEY` when they aren't passed.
- **OpenAI's Node library** (`openai`): `new OpenAI()` reads `OPENAI_BASE_URL` and `OPENAI_API_KEY` the same way.
- **LangChain's `ChatOpenAI`**: reads `OPENAI_API_BASE` first, then `OPENAI_BASE_URL`, and `OPENAI_API_KEY`.

```python
from openai import OpenAI

client = OpenAI()
reply = client.chat.completions.create(
    model="qwen3.8:27b",
    messages=[{"role": "user", "content": "Write a haiku about a Mac cluster."}],
)
print(reply.choices[0].message.content)
```

A tool that takes a base URL and a key in its own settings works too: give it `http://localhost:8487/v1` and point its key at the variable, not the key's text. The tool must speak OpenAI's Chat Completions (`/v1/chat/completions`); NativeCluster doesn't serve the Responses API.

## Tell a project's agents to use it

Paste these lines into the project's `AGENTS.md`, the instructions file coding agents read, so every agent that works on it uses your cluster rather than a hosted API. Claude Code reads `AGENTS.md` when the project has no `CLAUDE.md`; if it has one, add the line `@AGENTS.md` to it. An agent asks the person before it adds them: the file is theirs.

```md
## AI models

This project's model calls go to our own Macs through NativeCluster, never to a hosted AI service.

- Code reads `OPENAI_BASE_URL` and `OPENAI_API_KEY` from the environment. On a Mac running NativeCluster, run `nativecluster env` and source the file it prints: the base URL is `http://localhost:8487/v1`.
- Never hard-code a key, and never print, paste, log or commit anything starting `nck_` or `nct_`.
- `nativecluster models list` shows the cluster's models. Since NativeCluster 0.4.21, `nativecluster run <model>` downloads a model the cluster lacks when it fits this Mac; models are large (often 5 to 60 GB), so prefer one the cluster has.
- NativeCluster's docs: https://www.nativecluster.com/llms.txt
```

## What this session is

- **It's yours.** It's made from the command's own sign-in, for NativeCluster's own tool. Its calls wait in the same line as everyone's, and Usage shows them with your name.
- **It works on this Mac only**, at `http://localhost:8487/v1`. From another computer, use a Developer key and the main's address: see [The API](https://www.nativecluster.com/docs/api.md).
- **Its model list is the models that code.** `GET /v1/models` lists the chat models that can code. Every other model the cluster has, chat, search, speech or pictures, still answers when a call names it; `nativecluster models list` shows them all.
- **An owner or administrator can switch it off** for a person on Members (the nativecluster command's models, beside their apps). Then every call is `403` `not_given`.
- **It ends** when you run `nativecluster logout`, when an administrator ends your sign-ins, or after 90 days at most. Run `nativecluster env` again for a new one. Since 0.4.19 that keeps the earlier ones working, ten at most from one sign-in, so a second `env` never ends the session another tool holds.
