Skip to main content
The model factory (octo/models.py) creates LLM instances for any supported provider. It auto-detects the provider from the model name and handles all provider-specific configuration.

Supported Providers

ProviderLangChain ClassModel Pattern
AnthropicChatAnthropicclaude-*
AWS BedrockChatBedrockConverse*.anthropic.*
OpenAIChatOpenAIgpt-*, o1-*, o3-*
Azure OpenAIAzureChatOpenAIgpt-* + AZURE_OPENAI_ENDPOINT
GitHub ModelsChatAnthropic or ChatOpenAIgithub/*

Auto-Detection

The _detect_provider() function checks model names in order:
  1. Starts with github/ → GitHub Models
  2. Contains .anthropic. → AWS Bedrock
  3. Starts with claude- → Anthropic
  4. Starts with gpt-, o1-, o3- → OpenAI (or Azure if endpoint set)
Override with LLM_PROVIDER environment variable.

Tier System

make_model(model_name, tier) accepts a tier parameter:
TierPurposeTypical Model
highComplex reasoning, planningOpus
defaultGeneral chat, routingSonnet
lowSummarization, cheap tasksHaiku
Tiers are resolved to model names via HIGH_TIER_MODEL, DEFAULT_MODEL, LOW_TIER_MODEL in .env.

GitHub Models

GitHub Models is a special provider that auto-routes based on model name:
  • github/claude-* or github/anthropic/claude-*ChatAnthropic with GitHub’s Anthropic base URL
  • Everything else → ChatOpenAI with GitHub’s OpenAI-compatible base URL
Authentication uses GITHUB_TOKEN (PAT with models:read scope).

Design Decisions

ChatBedrock fails with tool results (“Extra inputs not permitted”). ChatBedrockConverse uses AWS’s native converse API which handles tool use correctly.
Heavy dependencies (boto3, langchain_anthropic, etc.) are imported inside factory functions. This keeps startup fast and avoids import errors when a provider isn’t installed.
The boto3 Bedrock client is cached as a singleton to avoid creating new connections on every model instantiation. Configured with read_timeout=300 and retries={"max_attempts": 0} (retries handled by Octo’s retry module).
ChatBedrockConverse.bind_tools() stores tools as Pydantic objects instead of dicts. LangGraph’s _should_bind_tools crashes with AttributeError. The patch in models.py normalizes tool storage.