Skip to main content

What you will build

You will send one request to POST /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:
Authenticate direct HTTP requests with 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 to https://api.cometapi.com and keep the Messages API request shape.

Common parameters

Troubleshooting / FAQ

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.
Confirm that the SDK client sets base_url in Python or baseURL in Node.js to https://api.cometapi.com.
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

Last modified on June 30, 2026