# client

> **Tool `tools/llm/client.py`** (program, Models). Shared clients for GameFrame's model-powered tools (tools/llm/).

Run it with `./gameframe run client ARGS` or `python3 tools/llm/client.py`. [Source on GitHub](https://github.com/tanepiper/game-frame/blob/main/tools/llm/client.py).

## Its own help

This is the help text in the tool itself, as `./gameframe tool client` prints it.

```text
Shared clients for GameFrame's model-powered tools (tools/llm/).

Usage:
  from client import api, text_of, run_claude, MODEL, PROTOCOL

Local models are the default. Set GAMEFRAME_LLM_ENDPOINT, GAMEFRAME_LLM_PROTOCOL and the
selected provider's model setting to choose a server, API and model. Use GAMEFRAME_MODEL only
for a one-run override. For hosted use, set
GAMEFRAME_LLM_PROVIDER=anthropic or openai; these named providers use their standard endpoint
and ignore GAMEFRAME_LLM_ENDPOINT. Use openai-compatible with GAMEFRAME_LLM_ENDPOINT for a
custom OpenAI-compatible service. The Anthropic protocol also drives the headless Claude Code
agent.

api() returns a client with messages.create(). Its OpenAI adapter supports text, base64 image
blocks and JSON-schema output. Anthropic batch requests are enabled for the hosted API; set
GAMEFRAME_LLM_BATCHES=1 to enable them on another endpoint that implements that API.

Use GAMEFRAME_LOCAL_LLM_API_KEY for an authenticated local server. Save hosted keys as
GAMEFRAME_ANTHROPIC_API_KEY, GAMEFRAME_OPENAI_API_KEY or
GAMEFRAME_OPENAI_COMPATIBLE_API_KEY. Local mode never sends a hosted key. Set
GAMEFRAME_ANTHROPIC_WORKSPACE_ID when an Anthropic key needs a workspace header. Settings load
from the environment and then .env files in the current folder, project and GameFrame.
GAMEFRAME_NO_DOTENV=1 skips them.

What it does not do: track provider spending or download models. Use each tool's --budget or
--max limits where available. Run this file directly to check the selected setup.
```
