What AI Models Are Used in learn-claude-code? A Complete Technical Guide
The learn-claude-code repository exclusively uses Anthropic's Claude family of large language models, configured via the MODEL_ID environment variable, with built-in support for switching to any Anthropic API-compatible provider by adjusting the ANTHROPIC_BASE_URL endpoint.
The open-source learn-claude-code project provides a framework for building AI-powered coding agents. Understanding what AI models are used in learn-claude-code is essential for developers configuring their own instances. This guide examines the source code to reveal exactly how models are selected, where defaults are defined, and how to integrate alternative providers.
Anthropic Claude: The Primary AI Engine
All agent loops in the repository import the anthropic Python SDK and instantiate an Anthropic client. The system architecture relies entirely on Claude models, with specific versions controlled through environment configuration read at runtime.
Model Selection via the MODEL_ID Environment Variable
The repository reads the target model identifier from the MODEL_ID environment variable at runtime. In agents/s01_agent_loop.py (lines 29-38), the code imports the Anthropic client and prepares the model variable for use in API calls. Every LLM invocation passes this identifier to client.messages.create(model=MODEL, ...).
Default Configuration in .env.example
The default model specified in .env.example (lines 5-7) is claude-sonnet-4-6. This provides a balanced performance profile for coding tasks. The repository also documents specific snapshot versions, with skills/agent-builder/scripts/init_agent.py (line 40) hard-coding claude-sonnet-4-20250514 as a fallback for scaffolding operations.
Extending to Anthropic-Compatible AI Providers
While Claude is the default, the architecture supports any provider implementing the Anthropic API surface. By modifying two environment variables, users can redirect requests to alternative AI models without changing the underlying code.
Supported Third-Party Models
The .env.example file (lines 27-59) documents several compatible providers: MiniMax-M2.5, GLM-5, Kimi-k2.5, and DeepSeek-Chat. These models can be used by setting ANTHROPIC_BASE_URL to the provider's endpoint and MODEL_ID to the specific model name.
Configuration Pattern for Alternative Endpoints
The client initialization pattern in agents/s01_agent_loop.py accepts an optional base_url parameter. When ANTHROPIC_BASE_URL is set, the client directs all requests to that endpoint while maintaining the same messages.create interface. This allows seamless switching between Claude and compatible alternatives without code changes.
Implementation Details in the Source Code
The model handling is centralized and consistent across the codebase. Key files demonstrate exactly how the AI integration works.
Client Initialization in Agent Loops
The primary agent implementation in agents/s01_agent_loop.py imports Anthropic from the anthropic library and instantiates the client with an optional base URL. The model identifier is retrieved via os.environ["MODEL_ID"] and passed to every client.messages.create call. This pattern is repeated in agents/s_full.py, which provides a more feature-complete reference implementation.
Hard-Coded Fallbacks in Scaffolding Scripts
The skills/agent-builder/scripts/init_agent.py file contains a safety fallback. At line 40, if no model is specified, it defaults to claude-sonnet-4-20250514. This ensures that scaffolding operations have a known-good model configuration even when environment variables are unset.
Practical Configuration Examples
Here are concrete ways to configure different AI models in learn-claude-code.
Running with the Default Claude Model
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Default MODEL_ID is claude-sonnet-4-6
# Run agent
python agents/s01_agent_loop.py
The script reads MODEL_ID from .env, creates an Anthropic client, and starts the REPL loop that sends prompts to Claude.
Switching to MiniMax or Other Providers
# Example: use MiniMax's Claude-compatible endpoint
export ANTHROPIC_BASE_URL="https://api.minimax.io/anthropic"
export MODEL_ID="MiniMax-M2.5"
python agents/s01_agent_loop.py
The same code path is reused; only the endpoint and model ID differ.
Direct Python SDK Usage
import os
from anthropic import Anthropic
client = Anthropic(base_url=os.getenv("ANTHROPIC_BASE_URL"))
model = os.getenv("MODEL_ID", "claude-sonnet-4-6")
response = client.messages.create(
model=model,
system="You are a helpful coding assistant.",
messages=[{"role": "user", "content": "Write a Python function that checks if a number is prime."}],
max_tokens=1024,
)
print("Claude says:", response.content[0].text)
Summary
- The learn-claude-code repository exclusively uses Anthropic's Claude family of models as its AI engine.
- Model selection is controlled via the
MODEL_IDenvironment variable, withclaude-sonnet-4-6as the default. - The architecture supports Anthropic-compatible providers (MiniMax, GLM-5, Kimi, DeepSeek) by adjusting
ANTHROPIC_BASE_URL. - Core implementation resides in
agents/s01_agent_loop.pyandagents/s_full.py, using theanthropicPython SDK. - Fallback model
claude-sonnet-4-20250514is hard-coded inskills/agent-builder/scripts/init_agent.pyfor scaffolding safety.
Frequently Asked Questions
Can I use GPT-4 or other OpenAI models with learn-claude-code?
No. The codebase is built specifically around the Anthropic SDK and API surface. All agent loops import from anthropic import Anthropic and use client.messages.create(). To use GPT-4, you would need to fork the repository and replace the client initialization with the OpenAI SDK, modifying the message creation calls accordingly.
What is the difference between claude-sonnet-4-6 and claude-sonnet-4-20250514?
claude-sonnet-4-6 is the default model identifier specified in .env.example for general agent operations. claude-sonnet-4-20250514 is a specific dated snapshot hard-coded in skills/agent-builder/scripts/init_agent.py (line 40) as a fallback for scaffolding tasks, ensuring consistent behavior when environment variables are not set.
How do I switch to a Chinese model like MiniMax or GLM-5?
Set the ANTHROPIC_BASE_URL environment variable to the provider's endpoint and update MODEL_ID to the specific model name. For example, set ANTHROPIC_BASE_URL="https://api.minimax.io/anthropic" and MODEL_ID="MiniMax-M2.5". The .env.example file contains commented templates for MiniMax, GLM-5, Kimi-k2.5, and DeepSeek-Chat configurations.
Is the anthropic Python SDK the only dependency required for AI functionality?
Yes. The requirements.txt file lists anthropic as the primary dependency for AI model interaction. This single SDK handles all LLM communication, whether pointing to Anthropic's official API or a compatible third-party endpoint via the base_url parameter. No additional AI SDKs are required to run the agents.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →