Skip to content
DOCS — PRODUCT · CONFIGURATION

Configuration

OpenMed configuration spans local config files, auth files, session storage, workflow output directories, and environment variables.

Files And Directories

Path Purpose
~/.openmed/provider_secrets.json Optional per-user OpenAI / Anthropic / OpenRouter / MiMo / Doubleword API keys created by openmed config provider-set
~/.openmed/auth.json Credential file for the experimental ChatGPT sign-in, created by openmed login
~/.openmed/audit.json Optional private audit-trail destination and PHI payload policy
~/.openmed/traces/ Local audit trace store and HF-write fallback path
~/.openmed/service_secrets.json Optional endpoints and keys for your own medical service planes
~/.openmed/sessions/ Persisted TUI session data
~/.openmed/history.jsonl Local prompt history for Up/Down recall (last 100 entries, skipped in DEID mode)
~/.config/openmed/config.toml General CLI configuration
~/.config/openmed/profiles/ Custom configuration profiles
~/.config/openmed/skills/ User-installed local skills
~/.config/openmed/mcp_servers.json MCP server configuration
~/.config/openmed/mcp_tools_cache.json Cached MCP tool discovery results
~/.openmed/cache/openrouter_models.json Cached OpenRouter model capability metadata (24h)
~/.openmed/batches/<job-id>/ Private Doubleword batch state, staged input, partial output, and error JSONL
~/.openmed/responses/<response-id>.json Private Doubleword flex/priority request and result snapshots; override with OPENMED_RESPONSES_DIR
./.openmed/OPENMED_PLAN.md Human-readable durable global plan for long workspace-scoped runs
./.openmed/OPENMED_PLAN.json Machine-readable durable global plan ledger and validation state
/tmp/openmed/artifacts/ Default workflow artifact root
/tmp/openmed/cases/ Default case-run root

~/.config follows XDG_CONFIG_HOME when that variable is set.

General CLI Config

~/.config/openmed/config.toml holds the keys that openmed config show, openmed config set, and profiles manage. OpenMed creates it the first time you save a value:

# OpenMed configuration file
# Generated automatically. Edit with care.

default_org = "OpenMed"
cache_dir = "/home/you/.cache/openmed"
device = null
hf_token = null
log_level = "INFO"
timeout = 300
use_medical_tokenizer = true
medical_tokenizer_exceptions = null
profile = null

The TUI and openmed agent --once do not read these values. To change how the agent runs, use the runtime settings below.

OpenMed writes this file so that only you can read it, and it never copies HF_TOKEN from the environment into it. A token you set yourself with openmed config set hf_token is stored here as plain text.

Runtime Settings

OpenMed loads per-project and per-user runtime settings that control permission policy, tool filtering, and result persistence. These are separate from the general CLI config and profiles.

Path Purpose
./OPENMED.md Project instructions injected into the system prompt (loaded from the git root, or the working directory outside a git repository)
./.openmed/settings.json Project-level runtime settings (same location rule)
~/.openmed/settings.json User-level runtime settings

Settings cascade: CLI arguments > project settings > user settings > defaults. Each key resolves on its own, and a project list replaces the user list instead of merging with it.

A settings file looks like this:

{
  "permission_mode": "auto",
  "deny_tools": ["edit_*"],
  "ask_tools": ["write_file"],
  "tool_result_persist_threshold_chars": 50000,
  "model": "gpt-6.1-sol",
  "provider": "openai",
  "reasoning_effort": "medium"
}

Supported runtime settings keys:

Key Type Default Purpose
permission_mode auto / acceptall / denyall / plan auto Tool execution gating mode
allow_tools list of tool name patterns none Strict allowlist: when set, the model sees only matching tools, and they run without a prompt. Ignored in the consumer and coordination agent modes, which have their own lists
deny_tools list of tool name patterns none Tools removed entirely
ask_tools list of tool name patterns none Tools that always prompt for approval
tool_result_persist_threshold_chars integer 50000 Oversized results written to disk above this threshold
model model ID built-in default Default model for new sessions (openmed config model-set)
provider openai / anthropic / openrouter / mimo / doubleword / custom inferred from the model Provider for the saved model
reasoning_effort none / low / medium / high / xhigh / max medium Default reasoning effort

deny_tools and ask_tools accept shell-style wildcards such as edit_*. allow_tools accepts exact tool names and a trailing *, such as read_*.

model, provider, and reasoning_effort apply when OpenMed starts; see Default model and newer models. model and provider are read as a pair, so a project model is never combined with the user's provider.

The model picker also stores its favorites and recents here, under a model_prefs key that it manages itself.

In acceptall, ask_tools does not trigger per-call approval prompts; use deny_tools to block tools that should never run in full-access mode.

Use /config in the TUI to see the effective runtime configuration at any time.

Core Environment Variables

Provider credentials and provider-specific tuning (OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_*, MIMO_API_KEY, DOUBLEWORD_API_KEY, OPENMED_ANTHROPIC_*) are documented on the Providers page.

Variable Purpose Default / behavior
OPENMED_HOME Override the ~/.openmed root used for global auth and sessions ~/.openmed
OPENMED_CONFIG Override the config file path (--config-path does the same for one command) ~/.config/openmed/config.toml
OPENMED_PROFILE Name the active config profile when the config file has none. Does not load the profile's values unset
OPENMED_PROVIDER_SECRETS_PATH Override the provider secrets file path ~/.openmed/provider_secrets.json
OPENMED_WORKFLOW_ARTIFACTS_DIR Override workflow artifact root /tmp/openmed/artifacts
OPENMED_WORKFLOW_CASES_DIR Override case-run root /tmp/openmed/cases
OPENMED_BATCH_DIR Override the private asynchronous batch job root ~/.openmed/batches
OPENMED_RESPONSES_DIR Override private individual Responses request and result storage ~/.openmed/responses
OPENMED_SKILLS_DIR Override the user skills directory ~/.config/openmed/skills
OPENMED_DRAFT_SNAPSHOT_TTL_SECONDS Lifetime of immutable workflow draft snapshots 86400 (24 hours)
OPENMED_AUTO_APPROVE Skip tool approval prompts and log each one (1, true, yes, or on) off
OPENMED_NO_UPDATE_CHECK Skip the background release check at TUI startup (1, true, yes, or on) off

Audit And Trace Storage

Audit trails are off by default. When enabled, OpenMed writes one JSON trace per agent run to a private destination owned by the operator.

Supported destinations:

  • hf_dataset — private Hugging Face Dataset repo, recommended for versioned audit history
  • hf_bucket — private Hugging Face Storage Bucket
  • local — local JSON traces only

Enable a private dataset destination:

export OPENMED_AUDIT_HF_TOKEN=hf_...
openmed audit enable --destination hf_dataset --dataset "<user-or-org>/openmed-traces"

This writes ~/.openmed/audit.json:

{
  "enabled": true,
  "schema_version": "1.0",
  "destination": "hf_dataset",
  "phi_payload": "payload",
  "flush_mode": "per_run",
  "local": {
    "path": "~/.openmed/traces",
    "fallback_on_hf_failure": true
  },
  "hf": {
    "repo": "<user-or-org>/openmed-traces",
    "token_env": "OPENMED_AUDIT_HF_TOKEN"
  }
}

Environment variables override this file:

Variable Purpose Default
OPENMED_AUDIT_CONFIG_PATH Override the audit config file path ~/.openmed/audit.json
OPENMED_AUDIT_ENABLED Override audit on/off at runtime config file / off
OPENMED_AUDIT_DESTINATION hf_dataset, hf_bucket, local, or none config file / none
OPENMED_AUDIT_HF_TOKEN HF token for private audit writes token_env, then HF_TOKEN, if present
OPENMED_AUDIT_HF_REPO Target private HF dataset repo config file
OPENMED_AUDIT_HF_BUCKET Target private HF bucket config file
OPENMED_AUDIT_PHI_PAYLOAD none, fingerprint, preview, or payload payload
OPENMED_AUDIT_FLUSH_MODE per_run or manual per_run
OPENMED_AUDIT_LOCAL_FALLBACK Write local trace if HF write fails 1
OPENMED_AUDIT_LOCAL_PATH Local audit trace path ~/.openmed/traces

Default phi_payload=payload stores full private transcript and tool payloads. Use preview, fingerprint, or none for smaller traces. See Audit Trail for the trace schema and CLI commands.

Model Providers

Credentials, model selection, and per-provider behaviour for OpenAI, Anthropic, OpenRouter, MiMo, Doubleword, and custom endpoints are documented together on the Providers page.

See Providers for API keys and ~/.openmed/provider_secrets.json, the experimental ChatGPT sign-in, OpenRouter models, MiMo setup, Anthropic caching, and provider selection. See Doubleword for real-time, async Responses and batch mode selection, and Batch Inference for bulk job storage and resume behavior.

Doubleword credentials and execution mode

Store the key once with openmed config provider-set doubleword --api-key "sk-...", or export DOUBLEWORD_API_KEY. The stored location is provider.doubleword.options.apiKey inside ~/.openmed/provider_secrets.json. An optional models list beside apiKey customizes the picker and makes its first entry the interactive default; DOUBLEWORD_MODELS overrides it. See Doubleword model configuration. No base URL or async flag belongs in that entry:

{
  "provider": {
    "doubleword": {
      "options": {
        "apiKey": "sk-...",
        "models": ["deepseek-ai/DeepSeek-V4.1-Flash"]
      }
    }
  }
}

Select the mode when running a command: openmed agent --provider doubleword starts the real-time TUI; openmed responses submit request.json --service-tier flex submits an individual async request; openmed batch submit requests.jsonl submits a 24-hour bulk job. --wait only keeps the local command polling. It does not change the tier, price, or completion window. See the complete setup and request example.

MiMo credentials example

MiMo token-plan users can configure just the key in ~/.openmed/provider_secrets.json:

{
  "provider": {
    "mimo": {
      "options": {
        "apiKey": "tp-..."
      }
    }
  }
}

Replace the placeholder with your token-plan key, or use "{env:MIMO_API_KEY}" and export that variable. Add mimo inside the existing provider object if you already have other providers configured. Then run openmed agent --provider mimo; the endpoint and all four model names are built in. See MiMo provider configuration for key precedence, model selection, and troubleshooting. Keep API keys out of settings.json and project files.

Context And Compaction

OpenMed sends its full tool schema (about 23,000 tokens) plus the system prompt on every turn, so expect more than 25,000 tokens of fixed overhead before any patient content. Long sessions therefore need compaction: older turns are summarized so the request keeps fitting.

How OpenMed decides when to compact

Compaction runs when the estimated request crosses a fraction of the model's context window (0.80 by default, lower for some models, such as 0.70 on GPT-6). That requires knowing the window, which OpenMed resolves in this order:

Provider Source of the window
OpenAI / Codex / Anthropic / MiMo V2.5 Curated per-model table
OpenRouter The model's own metadata, using the window the routed provider actually serves (not the model's theoretical maximum, which can be several times larger)
Doubleword Curated serving windows from Doubleword's Models dashboard and documentation, scoped to this provider and the exact model alias
Custom endpoint The server's own /models listing (max_model_len), read at startup
Anything else Unknown

OpenMed has no context window for the MiMo V2.6 IDs, so it leaves proactive compaction off for them and relies on the reactive overflow recovery path.

Doubleword's 11 built-in models have known windows: 1,000,000 tokens for the DeepSeek, GLM, Kimi K3 and Inkling entries; a conservative 262,000 tokens for Kimi K2.6 and both Nemotron entries. These are built into OpenMed and use the dashboard's rounded serving limits; OpenMed does not read a window from Doubleword's /v1/models listing. Any other model ID on Doubleword, such as an account-specific alias, has an unknown window.

At the default 80% threshold, the 1M models compact near 800K request tokens, including the SDK's reserved output budget. A 28K request is not near that threshold. To choose 50% instead, launch with OPENMED_COMPACTION_THRESHOLD=0.5 openmed agent --provider doubleword. This changes the compaction threshold, not the model's actual window.

An unknown window disables automatic compaction

OpenMed does not guess a context window. If it cannot determine one, it turns proactive compaction off rather than compact against a fabricated number — summarizing is lossy and irreversible, and in a clinical session the transcript is the record. You will see a one-time notice in the TUI, and /compact remains available to compact manually.

A guessed window is wrong in both directions: too small and OpenMed compacts a session that had plenty of room; too large and it never compacts until the server errors.

Compaction still runs reactively in all cases: when a provider reports that the request no longer fits, OpenMed compacts once and retries. Rate limits are explicitly not treated as overflow, so a throttle never destroys history.

Making an unknown window known

For a self-hosted or custom endpoint, run the doctor:

openmed config endpoint-doctor http://localhost:8000/v1

vLLM and SGLang report max_model_len on /v1/models, which the doctor reads directly. If your server does not report a window, the doctor fails the context check and tells you what to set.

Silent truncation

Some servers do not error when a prompt exceeds their context — they drop the front of it. The front is exactly where OpenMed's system prompt and tool schemas live, so the symptom is a model that appears to ignore its instructions and refuses to call tools, with nothing in any log. llama.cpp defaults to a 4096-token context, and Ollama's default auto-scales with available VRAM and can land at 4k.

endpoint-doctor detects this with a canary: it places a unique token at the very start of the system prompt, pads to the size of a real turn, and asks the model to echo it back. If the token comes back, the front survived.

  [FAIL] truncation: The model could not see a token placed at the START of the
         system prompt, and the server returned no error — it is silently
         truncating.

A server that errors on an over-long prompt passes this check — refusing is the honest behaviour.

Setting context explicitly on your server

Engine Flag Default if unset
vLLM --max-model-len 65536 The model's maximum (can OOM the KV cache)
SGLang --context-length 65536 The model's maximum
llama.cpp --ctx-size 65536 4096 — truncates every turn
Ollama OLLAMA_CONTEXT_LENGTH=65536 before ollama serve Auto-scales; can be 4k. Verify with ollama ps
Variable Purpose Default
OPENMED_COMPACTION_THRESHOLD Override the fraction of the window at which compaction triggers. Clamped to 0.10–0.95 per-model, 0.80 unless the model sets a lower value

Web search is off by default on every provider, including OpenAI and ChatGPT OAuth. Enabling it sends queries — which may contain clinical detail — to a third-party search vendor, so it is an explicit operator decision. Full setup and privacy guidance: Web Search.

export OPENMED_WEB_SEARCH=1
export SERPER_API_KEY="..."       # or TAVILY_API_KEY / BRAVE_SEARCH_API_KEY

Both parts are required: a key alone does nothing, so adding one for another purpose can never silently start sending clinical queries.

When search has never been enabled the search_web tool is hidden from the model entirely, so it does not spend schema budget on a capability that cannot work. If you enable search but the backend is misconfigured, the tool stays visible and explains exactly what is wrong.

Provider-native search (OpenAI and Codex OAuth)

OpenAI's Responses API — used by both the OpenAI provider and ChatGPT OAuth — can run a server-side search where the model searches and returns prose. OpenMed does not request it by default, for two reasons: it is unavailable on Anthropic, OpenRouter and local models, so behaviour would differ by provider; and its results never reach OpenMed as inspectable sources, so a claim drawn from them cannot be traced to a page you can open.

If you accept that trade — for non-clinical research use, for example — enable it per session:

Variable Purpose Default
OPENMED_BUILTIN_WEB_SEARCH Request the provider's server-side web_search tool on OpenAI / Codex OAuth 0 (off)
OPENMED_BUILTIN_WEB_SEARCH=1 openmed agent --model gpt-6.1-sol

This is independent of OPENMED_WEB_SEARCH: the two can be used together, and the client-side tool is the one that produces citable sources.

Native Medical Services

OpenMed ships native medical tools, but many of them use OpenMed's native medical service plane rather than an embedded local model binary.

These are native OpenMed tools. They are not remote MCP servers.

The service split is intentional:

  • extraction and de-identification run on a dedicated native service plane
  • terminology, HCC, RAF, RxNorm, LOINC, MedlinePlus, and PubMed run on a dedicated native service plane

The point of that split is not locality for its own sake. It is to keep sensitive or high-volume clinical processing on dedicated service planes that are easier to govern, faster on long unstructured inputs, and more cost-efficient than routing every page through a frontier-model path. General agent reasoning still uses the configured model provider.

By default, OpenMed operates these native medical services. To point either service plane at your own server, set OPENMED_INFERENCE_URL / OPENMED_MED_CODES_API_URL or use ~/.openmed/service_secrets.json:

{
  "inference": {
    "base_url": "https://nlp.internal.example.org",
    "api_key": "{env:OPENMED_NLP_KEY}"
  },
  "med_codes": {
    "base_url": "https://codes.internal.example.org",
    "api_key": "{env:OPENMED_CODES_KEY}"
  }
}

Every field is optional. See Use your own service endpoints for all fields.

See Native Medical Services for the deployment story and hosting patterns.

MCP Configuration

~/.config/openmed/mcp_servers.json lists your remote MCP servers:

{
  "version": 1,
  "servers": [
    {
      "id": "guidelines_hub",
      "name": "Guidelines Hub",
      "url": "https://example.com/mcp",
      "enabled": true,
      "timeout_seconds": 20,
      "extra_headers": {}
    }
  ]
}

See MCP Connectors for the validation rules.

Variable Purpose Default
OPENMED_MCP_CONFIG_PATH Override MCP config file path ~/.config/openmed/mcp_servers.json
OPENMED_MCP_TOOLS_CACHE_PATH Override tool-cache path ~/.config/openmed/mcp_tools_cache.json
OPENMED_MCP_TOOLS_CACHE_TTL_SECONDS Override discovery cache TTL 3600
OPENMED_MCP_<SERVER_ID>_ENABLED Override a server's enabled state unset
OPENMED_MCP_<SERVER_ID>_URL Override a server's URL unset
OPENMED_MCP_<SERVER_ID>_HEADERS_JSON Override a server's auth headers unset

Session PHI Mode

OpenMed exposes a session PHI mode in the CLI/TUI:

  • full
  • deid
  • strict

This mode is stored in session state and shown in the UI. deid and strict restrict what can reach the model: tools that return raw record content and workflows that read local files are refused. See PHI modes for exactly what each mode enforces and its limits.

Profiles

openmed config profiles
openmed config profile-show dev
openmed config profile-use prod

See Profiles for built-in and custom profile details.