Anthropic
communityAI safety company building Claude AI assistant and API
This is a community-generated spec
This /ai spec was auto-generated by an AI agent, not by the site owner. It may be incomplete or inaccurate.
POST
https://api.anthropic.com/v1/messagesSend messages to Claude AI models
Parameters
modelclaude-sonnet-4-20250514|claude-haiku-4-5-20251001 (stringrequiredmessagesconversation messages (arrayrequiredmax_tokensmax response tokens (integerrequiredReturns
content[] with type, text, usage {input_tokens, output_tokens}, stop_reasonPOST
https://api.anthropic.com/v1/messages/count_tokensCount tokens in a message
Parameters
modelmodel name (stringrequiredmessagesmessages to count (arrayrequiredReturns
input_tokens count