Explore Claude 4 Sonnet’s Playground — an interactive environment to test models, run queries in real time. Try prompts, adjust parameters, and iterate instantly to accelerate development and validate use cases.
Claude Sonnet 4 builds upon the foundation laid by its predecessor, Claude 3.7 Sonnet, which introduced hybrid reasoning capabilities and demonstrated improved performance in various benchmarks. The evolution to Claude Sonnet 4 includes further enhancements in coding proficiency, reasoning accuracy, and memory retention, positioning it as a more robust and reliable AI model for diverse applications.
Claude Sonnet 4 significantly enhances the capabilities of its predecessor, Sonnet 3.7, excelling in both coding and reasoning tasks with improved precision and controllability. Achieving state-of-the-art performance on SWE-bench (72.7%), Sonnet 4 balances capability and computational efficiency, making it suitable for a broad range of applications from routine coding tasks to complex software development projects. Key enhancements include improved autonomous codebase navigation, reduced error rates in agent-driven workflows, and increased reliability in following intricate instructions.

Claude Sonnet 4's enhanced capabilities make it suitable for a wide range of applications:
Log in to cometapi.com. If you are not our user yet, please register first. Sign into your CometAPI console. Get the access credential API key of the interface. Click “Add Token” at the API token in the personal center, get the token key: sk-xxxxx and submit.

Select the “\**claude-sonnet-4-20250514\**” endpoint to send the API request and set the request body. The request method and request body are obtained from our website API doc. Our website also provides Apifox test for your convenience. Replace <YOUR_API_KEY> with your actual CometAPI key from your account. base url is Anthropic Messages format and Chat format.
Insert your question or request into the content field—this is what the model will respond to . Process the API response to get the generated answer.
Process the API response to get the generated answer. After processing, the API responds with the task status and output data.
| Comet Price (USD / M Tokens) | Official Price (USD / M Tokens) |
|---|---|
Input:$2.40/M Output:$12.00/M | Input:$3.00/M Output:$15.00/M |
import anthropic
import os
# Get your CometAPI key from https://api.cometapi.com/console/token, and paste it here
COMETAPI_KEY = os.environ.get("COMETAPI_KEY") or "<YOUR_COMETAPI_KEY>"
BASE_URL = "https://api.cometapi.com"
message = anthropic.Anthropic(
base_url=BASE_URL,
api_key=COMETAPI_KEY,
)
messages = message.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(messages.content[0].text)| claude-sonnet-4-20250514 | ||
|---|---|---|
| claude-sonnet-4-20250514-thinking | ||
| cometapi-sonnet-4-20250514 | ||
| cometapi-sonnet-4-20250514 |