Claude Opus 4 API

Claude Opus 4 is Anthropic’s hybrid reasoning large language model for advanced coding, visual analysis, computer use, tool use, and long-running agentic tasks.
Context
200K tokens
Input
$19.5 / 1M
Output
$97.5 / 1M
Released
May 22, 2025

How to use Claude Opus 4 API

Install any OpenAI-compatible SDK, point it at api.aimlapi.com/v1, and set the model to anthropic/claude-opus-4.
import requests

r = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={"Authorization": "Bearer " + AIMLAPI_KEY},
    json={
      "model": "anthropic/claude-opus-4",
      "messages": [
        {
          "role": "user",
          "content": "Hello!"
        }
      ]
    },
)
print(r.json())
const r = await fetch("https://api.aimlapi.com/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.AIMLAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "anthropic/claude-opus-4",
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }),
});
console.log(await r.json());
curl -X POST https://api.aimlapi.com/v1/chat/completions \
  -H "Authorization: Bearer $AIMLAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"anthropic/claude-opus-4","messages":[{"role":"user","content":"Hello!"}]}'

OpenAI-compatible — swap the base URL and it works with your existing SDK.

Claude Opus 4 API Pricing

TypePrice
Input
$19.5 / 1M
Output
$97.5 / 1M
Cached input
$1.95 / 1M

Claude Opus 4 has documented prompt-caching pricing: 5-minute cache writes cost 1.25× base input pricing, 1-hour cache writes cost 2× base input pricing, and cache hits/refreshes are billed at a lower rate.

Claude Opus 4 vs other models

ModelInputOutputContextBest for
Claude Opus 4
This page
$19.5 / 1M
$97.5 / 1M
200K tokens
Agentic workflows and structured output
$4.1262 / 1M
$20.631 / 1M
200K tokens
Chat + assistants
$6.5 / 1M tokens
$32.5 / 1M tokens
200K tokens
Chat + assistants
$6.877 / 1M tokens
$34.385 / 1M tokens
200K tokens
Chat + assistants

Start building with Claude Opus 4

Get API Key
1000+ models, one API.