Use this file to discover all available pages before exploring further.
Use Electron Hub with the official Anthropic SDKs by simply changing the base URL. This allows you to access Claude models and 450+ other AI models through familiar Anthropic interfaces.
import json# Define toolstools = [ { "name": "get_weather", "description": "Get the current weather in a given location", "input_schema": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" } }, "required": ["location"] } }]message = client.messages.create( model="claude-sonnet-4-5-20250929", max_tokens=1000, tools=tools, messages=[ { "role": "user", "content": "What's the weather like in Paris?" } ])print(message.content)# Handle tool usefor content in message.content: if content.type == "tool_use": print(f"Tool: {content.name}") print(f"Input: {content.input}")
Reduce costs and improve performance by caching parts of your prompts that don’t change between requests. Prompt caching allows you to mark sections of your prompt for caching, with cache writes charged at 1.25x and cache reads at 0.1x the original input price.
Prompt Caching Guide
Learn how to use prompt caching with Anthropic Claude models, including examples for system and user message caching.
const message = await anthropic.messages.create({ model: 'claude-sonnet-4-5-20250929', max_tokens: 1000, system: `You are a helpful AI assistant that specializes in explaining complex technical concepts in simple terms. Always: 1. Use analogies and examples 2. Break down complex ideas into steps 3. Ask clarifying questions if needed 4. Provide practical applications`, messages: [ { role: 'user', content: 'Explain quantum computing' } ]});
const message = await anthropic.messages.create({ model: 'claude-sonnet-4-5-20250929', max_tokens: 1000, system: 'You are a JSON generator. Always respond with valid JSON.', messages: [ { role: 'user', content: 'Generate a JSON object with information about a fictional character including name, age, occupation, and three personality traits.' } ]});const characterData = JSON.parse(message.content[0].text);console.log(characterData);
// Use Haiku for simple tasksconst quickResponse = await anthropic.messages.create({ model: 'claude-3-haiku-20240307', max_tokens: 100, messages: [{ role: 'user', content: 'What time is it in UTC?' }]});// Use Opus for complex reasoningconst complexAnalysis = await anthropic.messages.create({ model: 'claude-3-opus-20240229', max_tokens: 2000, messages: [{ role: 'user', content: 'Analyze the economic implications of...' }]});