AI Models

Tern uses AI, and for the Open Beta, we’re bring-your-own-key API key. Tern supports Anthropic Claude (direct API and AWS Bedrock), 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

# 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"

# 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

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

Recommended Models

Anthropic Claude

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

NOTE: Claude through Bedrock does not have a default model, as the models made available by your organization may vary.

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.