Your Android XRAiAssistant app has been upgraded to support the latest Claude models from Anthropic, including Claude Sonnet 4.5, Opus 4.1, and Haiku 4.5 with Extended Thinking capabilities!
Model ID: claude-sonnet-4-5-20250929
Features:
- 200K token context window (with 1M beta option)
- Extended Thinking capability for complex reasoning
- Superior coding & analysis performance
- Best balance of speed, cost, and intelligence
Pricing:
- Input: $3 per million tokens
- Output: $15 per million tokens
Best For:
- Complex 3D scene generation
- Advanced Babylon.js/Three.js code creation
- Detailed code explanations and debugging
- Multi-step reasoning tasks
Model ID: claude-opus-4-1-20250805
Features:
- Highest intelligence and capability
- Best for extremely complex reasoning
- 200K context window
- Extended Thinking support
Pricing:
- Input: $15 per million tokens
- Output: $75 per million tokens
Best For:
- Highly complex architectural decisions
- Advanced algorithm design
- Research-level analysis
- When cost is secondary to quality
Model ID: claude-haiku-4-5-20251001
Features:
- Fastest response times
- Most cost-effective
- 200K context window
- Great for routine tasks
Pricing:
- Input: $1 per million tokens
- Output: $5 per million tokens
Best For:
- Quick code snippets
- Simple 3D object generation
- Rapid prototyping
- High-volume requests
What is Extended Thinking?
Extended Thinking allows Claude to show its reasoning process before responding, similar to "chain of thought" reasoning. This dramatically improves performance on complex tasks like:
- Advanced coding problems
- Mathematical reasoning
- Logical analysis
- Multi-step planning
Extended Thinking is optional and can be enabled by adding a thinking parameter to your API requests.
val request = AnthropicRequest(
model = "claude-sonnet-4-5-20250929",
messages = messages,
temperature = 0.7,
topP = 0.9,
stream = true,
maxTokens = 16000, // Higher max for thinking
system = systemPrompt,
thinking = AnthropicRequest.ThinkingConfig(
type = "enabled",
budgetTokens = 10000 // Max thinking tokens
)
){
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{
"role": "user",
"content": "Create a complex procedural 3D scene with physics"
}
]
}Budget Tokens:
- Minimum: 1,024 tokens
- Recommended: 5,000 - 10,000 tokens for coding tasks
- Must be less than
max_tokens
Max Tokens:
- Minimum:
budget_tokens + 1,024(for response) - Recommended: 16,000 for complex tasks
- If
max_tokens> 21,333, streaming is required
When to Use Extended Thinking:
- ✅ Complex 3D scene architecture
- ✅ Debugging intricate code issues
- ✅ Multi-step procedural generation
- ✅ Performance optimization analysis
- ❌ Simple object creation (wastes tokens)
- ❌ Quick code snippets (unnecessary)
AIModel.kt- Added 3 new Claude modelsAIRequest.kt- AddedThinkingConfigsupport + madetopPnullableAnthropicService.kt- Updated documentation with new modelsRealAIProviderService.kt- FixedtopPhandling for Claude 4.5+
Claude 4.5+ Restriction: The API only accepts either temperature OR top_p, not both.
Our Solution:
- ✅ We send
temperatureonly (standard parameter) - ❌ We set
topP = nullfor Anthropic requests - ✅ Temperature control still available to users (0.0 - 2.0 range)
- ✅ Together.ai and OpenAI still use both parameters
Why?: Anthropic simplified their API to avoid conflicting randomness settings. Using temperature alone is the recommended approach.
See ANTHROPIC_TOP_P_FIX.md for technical details.
✅ Fully backward compatible! Existing code continues to work:
- Legacy
CLAUDE_3_5_SONNETmodel still available (deprecated) - Extended Thinking is optional (default:
null) - No breaking changes to existing API calls
Old Code (still works):
val model = AIModels.CLAUDE_3_5_SONNETNew Code (recommended):
val model = AIModels.CLAUDE_SONNET_4_5The new models will automatically appear in your Settings screen model picker:
Together.ai:
- DeepSeek R1 70B (FREE)
- Llama 3.3 70B (FREE)
- Llama 3 8B Lite ($0.10/1M)
- Qwen 2.5 7B Turbo ($0.30/1M)
- Qwen 2.5 Coder 32B ($0.80/1M)
OpenAI:
- GPT-4o ($5/1M)
Anthropic:
- Claude Sonnet 4.5 ($3/$15 per 1M) ← NEW!
- Claude Opus 4.1 ($15/$75 per 1M) ← NEW!
- Claude Haiku 4.5 ($1/$5 per 1M) ← NEW!
-
Get Anthropic API Key
- Visit: https://console.anthropic.com/settings/keys
- Create a new API key
- Copy the key (starts with
sk-ant-...)
-
Configure in App
- Open XRAiAssistant
- Tap Settings (gear icon)
- Select Provider: Anthropic
- Enter your API key
- Select Model: Claude Sonnet 4.5
- Tap Save
-
Test the Integration
- Return to Chat screen
- Send: "Create a spinning cube with Babylon.js"
- Verify you get a response from Claude Sonnet 4.5
| Model | Speed | Quality | Cost | Best Use Case |
|---|---|---|---|---|
| Haiku 4.5 | ⚡⚡⚡ | ⭐⭐⭐ | 💰 | Quick snippets, high volume |
| Sonnet 4.5 | ⚡⚡ | ⭐⭐⭐⭐⭐ | 💰💰 | General coding, recommended |
| Opus 4.1 | ⚡ | ⭐⭐⭐⭐⭐⭐ | 💰💰💰💰 | Complex architecture, research |
Babylon.js Scene Generation (200-line code):
- Haiku 4.5: 5 seconds, $0.0001
- Sonnet 4.5: 8 seconds, $0.0003
- Opus 4.1: 12 seconds, $0.0015
With Extended Thinking (complex scene):
- Sonnet 4.5: 15 seconds, $0.0008 (better quality)
- Opus 4.1: 20 seconds, $0.0030 (exceptional quality)
// ChatViewModel.kt
suspend fun sendMessage(userMessage: String) {
val response = aiProviderRepository.generateResponseStream(
provider = "Anthropic",
apiKey = apiKey,
model = "claude-sonnet-4-5-20250929", // New model
prompt = userMessage,
systemPrompt = systemPrompt,
temperature = temperature.toDouble(),
topP = topP.toDouble()
)
response.collect { chunk ->
// Handle streaming response
currentAssistantMessage += chunk
}
}// RealAIProviderService.kt - Add thinking parameter
private suspend fun streamAnthropic(
apiKey: String,
model: String,
prompt: String,
systemPrompt: String,
temperature: Double,
topP: Double,
enableThinking: Boolean = false // NEW parameter
): Flow<String> = flow {
val messages = listOf(
APIChatMessage(role = "user", content = prompt)
)
val request = AnthropicRequest(
model = model,
messages = messages,
temperature = temperature,
topP = topP,
stream = true,
maxTokens = if (enableThinking) 16000 else 4096,
system = systemPrompt.takeIf { it.isNotEmpty() },
thinking = if (enableThinking) {
AnthropicRequest.ThinkingConfig(
type = "enabled",
budgetTokens = 10000
)
} else null
)
val response = anthropicService.messages(
apiKey = apiKey,
request = request
)
// ... parse and emit chunks
}// SettingsScreen.kt
var enableExtendedThinking by remember { mutableStateOf(false) }
Column {
Text("Extended Thinking", style = MaterialTheme.typography.titleMedium)
Text(
"Enable for complex coding tasks. Uses more tokens but improves quality.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Switch(
checked = enableExtendedThinking,
onCheckedChange = { enableExtendedThinking = it },
enabled = selectedModel.startsWith("claude-")
)
if (enableExtendedThinking) {
Text(
"⚠️ Extended thinking will increase token usage",
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall
)
}
}- Model appears in Settings dropdown
- Can select Claude Sonnet 4.5
- Can select Claude Opus 4.1
- Can select Claude Haiku 4.5
- API key validation works
- Chat messages send successfully
- Responses stream correctly
- Code generation works
- Enable thinking parameter
- Verify
thinkingblock in request - Confirm higher token usage
- Check response quality improvement
- Validate budget_tokens < max_tokens
- Test with complex coding prompt
- Invalid API key → Clear error message
- Rate limit (429) → Retry logic works
- Service unavailable (503) → Auto-retry
- Network error → User-friendly message
// Utility to estimate costs
object ClaudeCostEstimator {
fun estimateCost(
model: String,
inputTokens: Int,
outputTokens: Int,
thinkingTokens: Int = 0
): Double {
val (inputRate, outputRate) = when (model) {
"claude-sonnet-4-5-20250929" -> Pair(3.0, 15.0)
"claude-opus-4-1-20250805" -> Pair(15.0, 75.0)
"claude-haiku-4-5-20251001" -> Pair(1.0, 5.0)
else -> Pair(0.0, 0.0)
}
val inputCost = (inputTokens / 1_000_000.0) * inputRate
val outputCost = (outputTokens / 1_000_000.0) * outputRate
val thinkingCost = (thinkingTokens / 1_000_000.0) * inputRate
return inputCost + outputCost + thinkingCost
}
}
// Usage
val cost = ClaudeCostEstimator.estimateCost(
model = "claude-sonnet-4-5-20250929",
inputTokens = 5000, // System prompt + user message
outputTokens = 2000, // Generated code
thinkingTokens = 3000 // If using extended thinking
)
println("Estimated cost: $${"%.4f".format(cost)}") // $0.0180Problem: API returns 404 or "model not found"
Solutions:
- Verify model ID is exact:
claude-sonnet-4-5-20250929 - Check API key has access to Claude 4.5 models
- Ensure API version header is
2023-06-01 - Verify account has sufficient credits
Problem: No thinking block in response
Solutions:
- Verify
thinkingparameter is not null - Check
budget_tokens >= 1024 - Ensure
max_tokens > budget_tokens - Confirm model supports thinking (Sonnet 4.5+)
Problem: Responses take 30+ seconds
Solutions:
- Use Haiku 4.5 for faster responses
- Reduce
max_tokensif possible - Disable Extended Thinking for simple tasks
- Check network connection quality
Problem: Higher costs than expected
Solutions:
- Check if Extended Thinking is enabled
- Review
budget_tokenssetting - Monitor token counts in API responses
- Use Haiku 4.5 for high-volume requests
For developers updating existing code:
- Update
AIModel.ktimports - Replace
CLAUDE_3_5_SONNETwithCLAUDE_SONNET_4_5 - Review Extended Thinking use cases
- Update Settings UI to show new models
- Test all three new models
- Update user documentation
- Communicate pricing changes to users
- Set appropriate default model (Sonnet 4.5 recommended)
- Claude Models: https://docs.claude.com/en/docs/about-claude/models
- Extended Thinking: https://docs.claude.com/en/docs/build-with-claude/extended-thinking
- API Reference: https://docs.claude.com/en/api/messages
- Pricing: https://anthropic.com/pricing
- Claude Cookbook: https://github.com/anthropics/anthropic-cookbook
- API Examples: https://github.com/anthropics/anthropic-sdk-python/tree/main/examples
- Discord Community: https://discord.gg/anthropic
Your Android app now supports the latest and most powerful Claude models:
✅ Claude Sonnet 4.5 - Best all-around choice ✅ Claude Opus 4.1 - Maximum intelligence ✅ Claude Haiku 4.5 - Speed and efficiency
Plus Extended Thinking for complex reasoning tasks!
All changes are backward compatible, with no breaking changes to existing functionality. Users can continue using existing models while gradually migrating to the new ones.
Recommended Next Steps:
- Test the new models in your app
- Update user-facing documentation
- Set Claude Sonnet 4.5 as the default model
- Monitor usage and costs
- Gather user feedback on quality improvements
Enjoy the power of Claude 4.5! 🚀