Decision 006: The model endpoint is configuration-only, and a custom endpoint reuses OPENAI_API_KEY
- Status: proposed (accepted when the issue-19 pull request is approved)
- Date: 2026-10-10
- Deciders: @MadaraUchiha-314 (approver), the-loop (proposer)
- Work item: issue #19
Context
Issue #19 asks that tiny-harness call any OpenAI-compatible URL — Ollama, OpenRouter and the like — "in the config section related to OpenAI". The OpenAI SDK already has two ambient ways to do that: it reads OPENAI_BASE_URL when no URL is passed, and it copies OPENAI_ORG_ID / OPENAI_PROJECT_ID into every request. Before this work item the first of those was live: exporting OPENAI_BASE_URL silently redirected every prompt, tool result and the API key to another host, with nothing in the configuration file to say so.
Decision
[openai] base_urlis the only way to choose the endpoint. The adapter always builds its client with an explicit URL (https://api.openai.com/v1when none is configured), soOPENAI_BASE_URLis ignored. A custom endpoint also gets no organization or project headers and no redirects.- A custom endpoint reuses
OPENAI_API_KEY, which becomes optional whenbase_urlis set. There is no second key variable. - One adapter, two wire APIs.
[openai] apiselects the Responses API (default) or Chat Completions insideOpenAILLM; there is no separate adapter class. - The endpoint fails closed.
base_urlmust behttporhttps, must carry nouser:password@, and must usehttpsto send a key to anything but a literal loopback host.
Consequences
- The endpoint a deployment talks to is always visible in its configuration file and in the startup log line (
model endpoint <origin> api=<api> model=<model>). - An operator who exports a real OpenAI key and points
base_urlat a third party sends that key to the third party. The configuration reference says so; a separate variable would have prevented it at the cost of a second name for the same secret. - A server behind a redirecting proxy must be configured with its final URL.
Alternatives considered
- Honour
OPENAI_BASE_URL. Rejected: an environment variable could redirect the harness's traffic and key without any change to the reviewed configuration. - A separate key variable for custom endpoints (e.g.
TINY_HARNESS_MODEL_API_KEY). Offered at the requirements gate; the requirements were approved withOPENAI_API_KEY, as the ticket asked. - A second adapter class for Chat Completions. Rejected: configuration, client, errors, model info and key handling are shared; only mapping and parsing differ.