Tern LogoTern

AI Models

Tern works out of the box: by default, LLM calls go through Tern’s Anthropic proxy, so there’s nothing to configure. If you’d rather route calls through your own account, Tern supports Anthropic Claude (direct API, AWS Bedrock, Google Vertex AI, and Portkey), OpenAI GPT, Google Gemini, and any OpenAI-compatible router.

The Tern proxy (default)

Out of the box, Tern routes LLM calls through its own Anthropic proxy: no API key, no setup, authenticated by the Tern account created on first run. Calls run on Claude models.

Prefer your own provider? Configure one below, then select it in Settings. Or disable the proxy and Tern picks up your configuration automatically (a key alone doesn’t switch you):

export TERN_MODEL_BASE_URL=null

With the proxy disabled, nothing falls back to it; if no other provider is configured, calls fail.

Configuration

Onboarding will walk you through inputting a key directly into the product. You can also configure providers through environment variables:

# Anthropic (direct API)
export ANTHROPIC_API_KEY=your_anthropic_key

# OpenAI
export OPENAI_API_KEY=your_openai_key

# Google Gemini
export GEMINI_API_KEY=your_gemini_key

# Anthropic via AWS Bedrock
export BEDROCK_ANTHROPIC_MODEL="global.anthropic.claude-sonnet-4-5-20250929-v1:0"
export BEDROCK_BASE_MODEL="claude-sonnet-4-5"  # optional: enables cost tracking

# Anthropic via Google Vertex AI
export VERTEX_ANTHROPIC_PROJECT="your-gcp-project-id"
export VERTEX_ANTHROPIC_REGION="us-central1"
export VERTEX_ANTHROPIC_MODEL="claude-sonnet-4-5@20250514"

# Anthropic via Portkey (both required, then UI setup for base model)
export PORTKEY_API_KEY=your_portkey_key
export PORTKEY_MODEL=claude-sonnet-4-5-20250929

Model Precedence

The Tern proxy is the default. Disable it and Tern auto-selects the first configured provider in this list:

  1. Tern proxy - Default. No configuration required.
  2. Anthropic Claude - ANTHROPIC_API_KEY
  3. OpenAI - OPENAI_API_KEY
  4. Google Gemini - GEMINI_API_KEY
  5. Anthropic via Portkey (requires opt-in) - PORTKEY_API_KEY + PORTKEY_MODEL + UI setup
  6. Anthropic via AWS Bedrock (requires opt-in) - BEDROCK_ANTHROPIC_MODEL
  7. Anthropic via Google Vertex AI (requires opt-in) - VERTEX_ANTHROPIC_PROJECT + VERTEX_ANTHROPIC_REGION

Cloud Provider Setup

Anthropic via Bedrock

Models are configured through your AWS account, and may vary according to your organizations AWS configuration.

Configuration:

# Required: the model ARN or inference profile ID to call
export BEDROCK_ANTHROPIC_MODEL="global.anthropic.claude-sonnet-4-5-20250929-v1:0"

# Optional: the base model name, used only for cost tracking
export BEDROCK_BASE_MODEL="claude-sonnet-4-5"

The Bedrock model ARN is opaque, so Tern can’t derive pricing from it. BEDROCK_BASE_MODEL maps the ARN to a known Claude model name (e.g. claude-sonnet-4-5, claude-opus-4-1, claude-haiku-4-5) for cost reporting. It is optional: if you leave it unset, Bedrock works normally and usage is reported at zero cost.

To find available models:

$ aws bedrock list-inference-profiles

Anthropic via Vertex AI

Google Vertex AI provides access to Claude models through Google Cloud. This is useful if your organization already uses Google Cloud and prefers to consolidate AI spending under your GCP billing.

Prerequisites:

  1. A Google Cloud project with Vertex AI API enabled
  2. Claude models enabled in your project (via the Model Garden)
  3. Application Default Credentials configured (gcloud auth application-default login)
  4. IAM permissions: roles/aiplatform.user or aiplatform.endpoints.predict

Configuration:

# Required: Project ID (also accepts GOOGLE_CLOUD_PROJECT or GCLOUD_PROJECT)
export VERTEX_ANTHROPIC_PROJECT="your-gcp-project-id"

# Required: Region (also accepts GOOGLE_CLOUD_LOCATION)
# Available regions: us-central1, us-east5, europe-west1, europe-west4, asia-southeast1
export VERTEX_ANTHROPIC_REGION="us-central1"

# Required: the model ID to call (there is no default)
export VERTEX_ANTHROPIC_MODEL="claude-sonnet-4-5@20250514"

# Optional: base model name, used only for cost tracking
export VERTEX_BASE_MODEL="claude-sonnet-4-5"

Note: Cost tracking uses the same pricing as direct Anthropic API. Actual costs may vary based on your Google Cloud agreement.

Anthropic via Portkey

Portkey is an AI gateway that provides observability, caching, and routing features for LLM calls. See Portkey’s documentation for setup instructions.

Note: Cost tracking uses the base model you select during setup. Actual costs may vary based on your Portkey configuration.

Configuration (requires opt-in):

Portkey requires both env vars to be set, then setup in Tern to select the base model for pricing:

# Both required - Portkey won't appear unless both are set
export PORTKEY_API_KEY=your_portkey_key
export PORTKEY_MODEL="@anthropic/claude-sonnet-4-5-20250929"

The model uses Portkey’s Model Catalog format: @provider/model. For Anthropic models, use @anthropic/model-name.

Then in Tern’s settings, click “Complete Setup” for Portkey and select the base model (e.g., Claude Sonnet 4.5) that corresponds to your model string. This is used for pricing and capability detection.

OpenAI-Compatible Routers

Many LLM routers (LiteLLM, vLLM, Ollama, etc.) expose an OpenAI-compatible Chat Completions API. Tern supports these via additional environment variables:

OPENAI_API_KEY="your-router-api-key"
OPENAI_BASE_URL="http://localhost:4000"   # Your router's base URL
OPENAI_MODEL="your-model-name"             # Model identifier for the router

When OPENAI_BASE_URL is set, Tern switches from OpenAI’s Responses API to the Chat Completions API (the industry standard). The model string is passed through opaquely to the router.

Example Configurations

LiteLLM (litellm.ai):

OPENAI_API_KEY="sk-..."
OPENAI_BASE_URL="http://localhost:4000"
OPENAI_MODEL="claude-3-5-sonnet"  # LiteLLM model alias

Ollama (ollama.com):

OPENAI_API_KEY="ollama"  # Ollama doesn't require a real key
OPENAI_BASE_URL="http://localhost:11434"
OPENAI_MODEL="llama3.2"

vLLM (vllm.ai):

OPENAI_API_KEY="your-key"
OPENAI_BASE_URL="http://your-vllm-server:8000"
OPENAI_MODEL="meta-llama/Llama-3.1-8B-Instruct"

See also

  • Tours: what those LLM calls are actually doing.
  • Architecture: what’s sent to the LLM and what stays on your machine.