Lesson 20 of 46 ~20 min
Course progress
0%

Environment Setup & API Configuration

Configure your development environment for Opus 4.6 — API keys, SDK installation, project structure, and environment variables.

Before you can harness the full power of Opus 4.6, you need a properly configured workspace. This lesson walks you through every step — from API key creation to a battle-tested project structure.

API Access Setup

Step 1: Create Your API Key

  1. Navigate to console.anthropic.com
  2. Create a new API key with a descriptive name (e.g., opus-46-course)
  3. Copy the key immediately — it will not be shown again
# Store securely in your shell profile
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.zshrc
source ~/.zshrc

Security rule: Never commit API keys to version control. Never paste them into chat windows. Never store them in code files.

Step 2: Install the SDK

# Python
pip install anthropic>=0.42.0

# TypeScript/Node.js
npm install @anthropic-ai/sdk@latest

Step 3: Verify Installation

from anthropic import Anthropic

client = Anthropic()
response = client.messages.create(
    model="claude-opus-4-6-20260205",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello, Opus 4.6. Confirm your model version."}]
)
print(response.content[0].text)
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();
const response = await client.messages.create({
  model: 'claude-opus-4-6-20260205',
  max_tokens: 256,
  messages: [{ role: 'user', content: 'Hello, Opus 4.6. Confirm your model version.' }],
});
console.log(response.content[0].text);

Project Structure

A well-organized project saves hours of confusion later:

opus-46-project/
├── .env                      # API keys (gitignored!)
├── .gitignore
├── prompts/
│   ├── system/               # System prompts by role
│   │   ├── code-reviewer.md
│   │   ├── architect.md
│   │   └── security-auditor.md
│   └── templates/            # Reusable prompt templates
│       ├── bug-diagnosis.md
│       └── refactor-plan.md
├── context/
│   ├── project-context.md    # Project-specific context
│   └── conventions.md        # Coding standards and patterns
├── tools/
│   └── mcp-servers/          # Custom MCP server configurations
├── scripts/
│   ├── chat.py               # Interactive CLI
│   ├── batch.py              # Batch processing
│   └── cost-tracker.py       # Token usage and cost monitoring
├── src/                      # Your application code
└── tests/

Environment Variables

# .env file (always gitignored!)
ANTHROPIC_API_KEY=sk-ant-...
CLAUDE_MODEL=claude-opus-4-6-20260205
CLAUDE_FALLBACK_MODEL=claude-sonnet-4-5-20241022

# Cost control
CLAUDE_MAX_TOKENS=8192
CLAUDE_THINKING_BUDGET=10000

# Context configuration
CLAUDE_MAX_CONTEXT=200000  # Start conservative, increase as needed

Model Identifier

The correct model string for Opus 4.6:

claude-opus-4-6-20260205

Breaking Changes from Opus 4.5

If you are migrating from Opus 4.5, be aware of these API changes:

ChangeOpus 4.5Opus 4.6
Model stringclaude-opus-4-5-20250101claude-opus-4-6-20260205
Assistant prefillingSupportedRemoved
Structured outputOptionalNew requirements
Thinking modethinking: {type: "enabled"}thinking: {type: "adaptive"}

Quick Smoke Test

Run this script to confirm everything works:

#!/usr/bin/env python3
"""Opus 4.6 environment smoke test."""
import os
from anthropic import Anthropic

def main():
    # Verify API key
    api_key = os.environ.get("ANTHROPIC_API_KEY")
    if not api_key:
        print("❌ ANTHROPIC_API_KEY not set")
        return

    client = Anthropic()

    # Test basic message
    response = client.messages.create(
        model="claude-opus-4-6-20260205",
        max_tokens=128,
        messages=[{"role": "user", "content": "Respond with: OPUS_46_READY"}]
    )
    result = response.content[0].text
    assert "OPUS_46_READY" in result, f"Unexpected response: {result}"
    print(f"✅ Basic messaging works")
    print(f"   Model: {response.model}")
    print(f"   Input tokens: {response.usage.input_tokens}")
    print(f"   Output tokens: {response.usage.output_tokens}")

if __name__ == "__main__":
    main()

Your environment is ready. In the next lesson, you will learn the art of crafting your first effective prompt specifically tuned for Opus 4.6’s capabilities.