AI Models

Tern uses AI, and for the Open Beta, we’re bring-your-own-key API key. Tern supports Anthropic Claude (direct API, AWS Bedrock, and Portkey), OpenAI GPT, and Google Gemini models.

Configuration

Onboarding will walk you through inputting a key directly into the product, but you can also configure which AI model Tern uses through environment variables:

# Anthropic configuration (default: claude-sonnet-4.5)
export ANTHROPIC_API_KEY=your_anthropic_key
export TERN_MODEL=claude-sonnet-4.5

# OpenAI configuration (default: gpt-5)
export OPENAI_API_KEY=your_openai_key
export TERN_MODEL=gpt-5

# Google Gemini configuration (default: gemini-2.5-pro)
export GEMINI_API_KEY=your_gemini_key
export TERN_MODEL=gemini-2.5-pro

Or Anthropic through a 3rd party:

# Anthropic via AWS Bedrock - Uses ARN instead of direct keys
# Use `aws bedrock list-inference-profiles` to find available models
export BEDROCK_ANTHROPIC_MODEL="global.anthropic.claude-sonnet-4-5-20250929-v1:0"

# Anthropic via Portkey - AI gateway with observability & routing
export PORTKEY_API_KEY=your_portkey_key
export TERN_MODEL=claude-sonnet-4.5

Model Precedence

When multiple providers are configured, Tern will try providers in this order:

  1. Anthropic Claude - ANTHROPIC_API_KEY
  2. OpenAI - OPENAI_API_KEY
  3. Google Gemini - GEMINI_API_KEY
  4. Anthropic via AWS Bedrock (requires opt-in) - BEDROCK_ANTHROPIC_MODEL
  5. Anthropic via Portkey - PORTKEY_API_KEY

Recommended Models

Anthropic Claude

  • Claude Sonnet 4.5 (claude-sonnet-4.5) — Default. Best balance of performance and cost, especially for coding tasks.
  • Claude Haiku 4.5 (claude-haikk-4.5) — Quick, solid performance.
  • Claude Opus 4.1 (claude-opus-4.1) — Top-end model. Highest performance on coding & reasoning benchmarks.

Anthropic via Bedrock

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

To find available models:

$ aws bedrock list-inference-profiles

Anthropic via Portkey

Portkey is an AI gateway that provides observability, caching, and routing features for LLM calls. When using Portkey:

  • Claude Sonnet 4.5 (claude-sonnet-4.5) — Default. Same models as direct Anthropic API
  • Requires a Portkey API key (pk-...)

OpenAI

  • GPT-5 (gpt-5) - Default. Latest model with excellent reasoning and code generation
  • GPT-5 Mini (gpt-5-mini) - Faster performance, lower cost
  • GPT-5 Nano (gpt-5-nano) - Fastest performance, lowest cost

Google Gemini

  • Gemini 2.5 Pro (gemini-2.5-pro) - Default. State-of-the-art reasoning and coding, 1M+ token context
  • Gemini 2.5 Flash (gemini-2.5-flash) - Best price/performance ratio with thinking capabilities
  • Gemini 2.5 Flash-Lite (gemini-2.5-flash-lite) - Most cost-efficient option

Experimenting with Models

Feel free to experiment with other models that are available through these providers. Different models may be better suited for particular types of code transformations or specific programming languages.