AI Models

Tern runs LLM calls through its own proxy to Anthropic: Tern retains none of that traffic, and Anthropic’s retention of it is minimal. To send them through your own account instead, put the provider in ~/.tern/agent.yaml. The service reads that file. The file should be readable only by you:

chmod 600 ~/.tern/agent.yaml
ai:
  providers:
    tern:
      base_url: "null"
    anthropic:
      api_key: sk-ant-...

base_url: "null" turns the proxy off. With it off, nothing falls back to it. If no other provider is configured, calls fail.

tern set-provider shows whether the key loaded. tern set-provider anthropic selects it. tern doctor checks the same thing. The file the service reads is the Config line from tern service status. That is ~/.tern/agent.yaml unless the service was installed with another config.

Providers

Same file. If nothing is selected, Tern uses the first configured provider in this order: Anthropic, OpenAI, Gemini, Portkey, Bedrock, Vertex. tern set-provider wins over that order.

ai:
  providers:
    openai:
      api_key: sk-...
    gemini:
      api_key: ...
    portkey:
      api_key: ...
      models:
        balanced: "@anthropic/claude-opus-5-5"
    bedrock:
      models:
        balanced: us.anthropic.claude-opus-5-5
      base_model: claude-opus-5-5
    vertex:
      project_id: your-gcp-project
      region: global
      models:
        balanced: claude-opus-5-5
      base_model: claude-opus-5-5

Bedrock and Vertex sign in through the cloud account already on the machine. The file is still where you tell Tern what to call, the same as a key for the others. base_model is optional and only used for cost reporting. Portkey also needs the model string, in Portkey’s catalog format (@provider/model), and a base model chosen in Settings for pricing.

OpenAI-compatible routers

OpenRouter is the usual one. Point openai at it:

ai:
  providers:
    openai:
      api_key: sk-or-...
      base_url: https://openrouter.ai/api/v1
      models:
        balanced: anthropic/claude-opus-5.5

When base_url is set, Tern uses the Chat Completions API and passes the model string through as-is. LiteLLM, vLLM, and Ollama are the same shape: base_url is the server, balanced is the model name it expects. Ollama does not check the key. Its base_url is http://localhost:11434, and balanced is whatever tag you pulled.

From a terminal

The same fields accept environment variables when you run tern yourself: ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, PORTKEY_API_KEY, PORTKEY_MODEL, BEDROCK_ANTHROPIC_MODEL, VERTEX_ANTHROPIC_PROJECT, VERTEX_ANTHROPIC_REGION, VERTEX_ANTHROPIC_MODEL, and TERN_MODEL_BASE_URL=null for the proxy.

See also

  • The hook: the live path those calls serve.
  • The tour: the summary they produce.
  • The review: post that read on the pull request.
  • The service: the background process that reads this file.
  • Architecture: what’s sent to the LLM and what stays on your machine.