What you will build
You will send one request toPOST /v1/messages, print the Claude response text, and keep the code ready for Anthropic SDK or direct HTTP usage.
Prerequisites
- A CometAPI API key stored in
COMETAPI_KEY - A Claude model ID from the Models page
curl, Python 3.10+, or Node.js 18+
API key, base URL, authentication
Use the Anthropic-compatible Messages endpoint through CometAPI:x-api-key and the Anthropic API version header:
Code examples
Use the tabs below for copyable examples in cURL, Python, and Node.js.Flow explanation
Claude Messages requests are synchronous by default. The API returns a message object in one HTTP response, and your application reads the first text content block. Use this route when you need Claude-specific request shapes such as Anthropic message arrays, extended thinking, prompt caching, or tool use. If your application already uses the official Anthropic SDK, set the SDK base URL tohttps://api.cometapi.com and keep the Messages API request shape.
Common parameters
| Parameter | Use |
|---|---|
model | A Claude model ID available to your account. |
max_tokens | Maximum response token budget for the Messages API response. |
messages | Anthropic message array with user and assistant roles. |
stream | Streams incremental message events when set to true. |
thinking | Enables Claude extended thinking when the selected model supports it. |
Troubleshooting / FAQ
The request returns 401
The request returns 401
Confirm that
COMETAPI_KEY is set in the same shell or runtime that sends the request. Do not paste a real key into source files.The SDK still calls Anthropic directly
The SDK still calls Anthropic directly
Confirm that the SDK client sets
base_url in Python or baseURL in Node.js to https://api.cometapi.com.Which model should I use
Which model should I use
Use a Claude model ID available to your account. This quickstart does not hardcode a Claude model because availability changes by account and model family.
Next steps
- Use the Anthropic Messages API reference for full request and response fields.
- Check model availability in Models.
- Configure local coding sessions with the Claude Code integration guide.
- Review retry behavior in Error codes and retry strategy.