All insights

Model APIs

Claude 4 API: Availability, Setup, Migration, and Pricing

Claude Opus 4 and Sonnet 4 were retired from Anthropic-operated APIs on June 15, 2026. Check API access and billing requirements, make a first request with the current Sonnet model, and configure production error handling.

Illustration for Claude 4 api

Direct answer

Claude Opus 4 and Claude Sonnet 4 are no longer callable through Anthropic-operated platforms, including the Claude API. Anthropic’s lifecycle documentation says they were retired on June 15, 2026, and requests to retired models fail. If you mean the direct Anthropic API, don’t start a new integration with a Claude 4 model ID. For a Sonnet-style starting point, Anthropic currently lists Claude Sonnet 5.5 (claude-sonnet-5-5) as its latest Sonnet model. (Model deprecations)

Cloud-provider availability can differ. Anthropic says partner-operated platforms, including Amazon Bedrock and Google Cloud’s Google-managed Claude offering, set their own retirement schedules. This guide does not verify whether either provider still serves the original Claude 4 models today; check that provider’s current model catalog before using a legacy model ID. (Model deprecations)

Make a first request with Anthropic’s current Sonnet model

This example uses Anthropic’s direct Claude API—not Vertex AI or Bedrock. You need a Claude Console account and an API key. Before sending a paid request, make sure the Console organization has usage credits or other billing access enabled. Claude API access and billing are separate from a regular Claude web or app subscription; eligible Max, Ultra, and Team subscribers may claim API credits by linking an organization. Check Anthropic’s billing instructions and supported regions before proceeding. (API overview; API credits for subscribers)

  1. Create an API key in the Claude Console. For local development, keep it in an environment variable; don’t commit it to source control. The key guide describes personal keys for individual development and service-account keys for shared workloads.

  2. Install the SDK. Anthropic’s current Python SDK requires Python 3.10 or later. (Python SDK documentation)

    python -m pip install anthropic
    
  3. Set the key in your shell (macOS/Linux example):

    export ANTHROPIC_API_KEY="your-api-key"
    
  4. Save this as first_request.py:

    import anthropic
    
    client = anthropic.Anthropic()
    message = client.messages.create(
        model="claude-sonnet-5-5",
        max_tokens=256,
        messages=[{"role": "user", "content": "Reply with: API connection works."}],
    )
    
    for block in message.content:
        if block.type == "text":
            print(block.text)
    

    Run it from the same shell where you set the key:

    python first_request.py
    

    A successful request prints Claude’s text reply in the terminal. The SDK invocation and text-block handling follow Anthropic’s Python SDK example; the request structure is documented in the Messages API reference. This is a documentation-based example, not a reported live test.

The direct Claude API is REST-based at https://api.anthropic.com; the Messages endpoint is POST /v1/messages. The SDK handles request authentication and HTTP details for this example. If you call HTTP directly, follow Anthropic’s current API overview and Messages reference; don’t reuse credentials or endpoint settings from a cloud-provider integration.

Production checks

Before moving the example into a service:

  • Use an appropriate credential. Anthropic recommends a personal key for your own development and a service-account key for shared workloads. For production workloads on cloud platforms, CI/CD, or Kubernetes where you already have an identity provider, Anthropic documents Workload Identity Federation as an option to avoid static API keys. Store any static key outside source code and restrict access. (Authentication; API key guide)
  • Check current limits and spend controls. Limits depend on the organization and usage tier; short bursts can trigger errors even when average traffic seems within a per-minute limit. Anthropic shows organization-specific limits in the Console. (Rate limits)
  • Handle retries deliberately. The Anthropic SDK automatically retries transient connection failures, rate limits, and 5xx server errors with exponential backoff, up to two retries by default, and honors retry-after when present. A 429 caused by a rate limit may be retryable after that delay; a 429 caused by a monthly spend cap has no retry-after header and will continue failing until access resumes. Check the error details and billing state rather than retrying that case indefinitely. (API errors; Rate limits)
  • Set a request timeout that fits your service. The Python SDK accepts a configurable timeout; choose it to fit your application’s own request deadline rather than relying on an unlimited wait. The SDK’s documented default is 10 minutes, with a 5-second connection timeout. (Python SDK source defaults)
  • Plan for model changes and monitor usage. Use an active model ID, review usage and cost in the Console, and evaluate replacement models against your own test cases before switching production traffic. Anthropic provides a migration guide for moving older Sonnet Messages API integrations to Sonnet 5.5.

API pricing and a simple cost estimate

Anthropic’s published prices are in USD per million tokens (MTok). Its current pricing reference lists Claude Sonnet 5.5 at $2/MTok for input and $10/MTok for output. It also lists Sonnet 4’s historical rates as $3/$15 per MTok; don’t mistake those rates for an available direct Anthropic API option, since Sonnet 4 is retired on Anthropic-operated platforms and requests to retired models fail. Check the current pricing page for the applicable model and any pricing features.

Illustrative Sonnet 5.5 calculation: for 1,000,000 input tokens and 200,000 output tokens, the base token charge is (1 × $2) + (0.2 × $10) = $4. This excludes other applicable charges or pricing features; actual cost depends on token usage and the terms for your account. (Pricing)

API usage is not the same as a Claude web or app subscription. If you use a cloud provider instead of Anthropic directly, check that provider’s current model availability, credentials, limits, and billing separately; provider lifecycle schedules and billing can differ.

Sources

Model deprecations — Claude Platform Docs

API overview — Claude Platform Docs

Supported regions — Claude Platform Docs

I created a Claude Console organization—how do I start using the Claude API?

API credits for Max, Ultra, and Team plans

Get your Claude API key

Python SDK — Claude Platform Docs

Create a Message — Claude API Reference

Authentication — Claude Platform Docs

Claude API errors

Rate limits — Claude Platform Docs

Anthropic Python SDK default timeout and retry constants

Claude Sonnet 5.5 migration guide

Pricing — Claude Platform Docs

Contact us