Create a Message
POST
/v1/messages https://api.anthropic.com
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our user guide
Parameters
header Header Parameters
| Name | Type |
|---|---|
anthropic-version The version of the Claude API you want to use. Read more about versioning and our version history here. | string |
Request Body
application/json
required
interface CreateMessageParams {
model:Model ;
messages:InputMessage [];
max_tokens: number;
metadata?:Metadata ;
service_tier?: "auto" | "standard_only";
stop_sequences?: string[];
stream?: boolean;
system?:RequestTextBlock [] | string;
temperature?: number;
thinking?:ThinkingConfigParam ;
tool_choice?:ToolChoice ;
tools?: (Tool | BashTool20250124 | TextEditor20250124 | TextEditor20250429 | TextEditor20250728 | WebSearchTool20250305 )[];
top_k?: number;
top_p?: number;
}
model:
messages:
max_tokens: number;
metadata?:
service_tier?: "auto" | "standard_only";
stop_sequences?: string[];
stream?: boolean;
system?:
temperature?: number;
thinking?:
tool_choice?:
tools?: (
top_k?: number;
top_p?: number;
}
Responses
200 application/json
Message object.
interface Message {
id: string;
type: "message";
role: "assistant";
content:ContentBlock [];
model:Model ;
stop_reason:StopReason | null;
stop_sequence: string | null;
usage:Usage ;
}
id: string;
type: "message";
role: "assistant";
content:
model:
stop_reason:
stop_sequence: string | null;
usage:
}
Client Errors
4XX application/json
Error response.
See our errors documentation for more details.
interface ErrorResponse {
error:InvalidRequestError | AuthenticationError | BillingError | PermissionError | NotFoundError | RateLimitError | GatewayTimeoutError | APIError | OverloadedError ;
request_id: string | null;
type: "error";
}
error:
request_id: string | null;
type: "error";
}