Application Process
To use the Claude Messages API, first go to the Ace Data Cloud Console to obtain your API Token for backup.
If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in, and will return to the current page automatically after completion.
One API Token can call all services on the platform without needing to apply separately for each service. The first application will grant a free quota for a trial experience; when the quota is insufficient, you can recharge the general balance in the console.
📘 Complete Documentation: Claude Messages API →
Basic Usage
The request path for the Claude Messages API is/v1/messages, consistent with the Anthropic official API. We need to provide at least three required parameters:
model: Choose the Claude model to use. The latest flagship isclaude-fable-5-1(1 million Token context, maximum output 128K Token); the originalclaude-fable-5is still compatible.messages: An array of input messages, each containingrole(role) andcontent(content), whererolesupportsuserandassistant.max_tokens: The maximum number of output tokens, used to limit the length of a single reply.
system: System prompt used to set the model’s behavior and role.temperature: Generation randomness, between 0-1, with higher values leading to more diverse replies.stream: Whether to use streaming responses; set totruefor a word-by-word return effect.stop_sequences: Custom stop sequences; the model will stop generating when encountering these texts.top_p: Nucleus sampling parameter, used with temperature to control generation randomness.top_k: Sample only from the top K options with the highest probabilities.tools: Tool definitions for allowing the model to invoke external functions.tool_choice: Controls how the model uses the provided tools.cache_control: Automatically creates cache breakpoints at the last cacheable content block of the request; can also be written on specific content blocks.
cURL Example
Python Example
id: The unique identifier for this message.type: Alwaysmessage.role: Alwaysassistant.content: An array of reply content, each element containingtype(e.g.,text) and corresponding content.model: The name of the model processing the request.stop_reason: The reason for stopping. Stable values includeend_turn,max_tokens,stop_sequence,tool_use,pause_turn(which can return the current assistant content as is to continue),refusal, andmodel_context_window_exceeded.stop_sequence: If stopped due to a custom stop sequence, displays the matching stop sequence text.stop_details: Whenstop_reasonisrefusal, may include refusal category and explanation.usage: Token usage statistics.input_tokensis uncached input;cache_creation_input_tokensandcache_read_input_tokensare for cache writing and reading, respectively;output_tokensis the number of output tokens. The official cache read base price for Fable 5.1 is 12.50 and $20/million Tokens for 5 minutes and 1 hour, respectively; actual platform prices are calculated based on package discounts. Non-streaming responses may also includecostrecorded by Ace Data Cloud.
System Prompt
The Claude Messages API supports setting system prompts through thesystem field to define the model’s behavior, role, and context.
Python Example
system prompt, you can precisely control Claude’s role and behavior.
Streaming Response
This interface also supports streaming responses; setting thestream parameter to true will provide a step-by-step return effect, making it very suitable for implementing word-by-word display on web pages.
Python Example
event: and data:. The types of streaming events include:
message_start: The start of a message, containing basic information about the message and the model name.content_block_start: The start of a content block.content_block_delta: Incremental updates to the content block, containing newly generated text segments.content_block_stop: The end of a content block.message_delta: Incremental updates at the message level, containingstop_reasonand finalusageinformation.message_stop: The end of a message.
content_block_delta events in the streaming response contain the progressively generated text content, and the complete reply can be obtained by concatenating all text_delta.
JavaScript Example
Multi-turn Dialogue
If you want to connect to multi-turn dialogue functionality, you need to alternate messages from theuser and assistant roles in the messages array, passing in the previous conversation history.
Python Example
messages, Claude can provide accurate answers based on the context.
Deep Thinking Model
Claude’s thinking and thinking summary are two different concepts: the model can perform internal reasoning, but the API does not return the raw thought chain. When the reasoning process needs to be displayed, the API returns a processed summary. The current model recommends using adaptive thinking and controlling the overall reasoning effort throughoutput_config.effort:
display: "summarized"returns a readable summary of the thought; it is not the raw thought chain.display: "omitted"returnsthinking: "", but still retains the opaquesignatureto support subsequent dialogue.- The default value for display in Fable 5.1, Fable 5, Opus 5, Sonnet 5, Opus 4.8, and Opus 4.7 is
omitted; Opus 4.6, Sonnet 4.6, and earlier models that support thinking default to usingsummarized. - Display only affects the returned content and streaming latency, does not disable reasoning, nor reduce the billing of thinking tokens.
- Whether thinking is enabled by default and the default value of display are two independent issues. Opus 5 and Sonnet 5 default to enabling adaptive thinking; Opus 4.8, 4.7, and 4.6 need to be explicitly enabled.
budget_tokensis only used for older models that still support fixed thinking budgets. New models should usethinking.type=adaptiveandoutput_config.effort; thinking in Fable 5.1 is always on and cannot be explicitly turned off.- In multi-turn dialogues and tool calls, the complete thinking block and signature returned by the assistant should be passed back unchanged; do not modify or generate the signature yourself.
- Some compatible routes cannot handle
redacted_thinkingor explicitly turn off thinking without loss, in which case a parameter error will be returned, rather than silently discarding or changing the request semantics.
summarized will produce thinking_delta; omitted does not produce thinking_delta, only retaining the lifecycle of the thinking block and signature_delta.
Visual Model
Claude supports multimodal input and can process both text and images simultaneously. In the Messages API, you can use visual capabilities by settingcontent to an array format and passing in the image content block.
Using Base64 Encoded Images
Using URL Images
cURL Example
image/jpeg, image/png, image/gif, image/webp.
Documents and PDFs
PDFs use thedocument content block, supporting both Base64 and URL stable sources. Base64 sources must use application/pdf:
{"type":"url","url":"https://example.com/report.pdf"}. The document also supports text/plain and content sources composed of text/image blocks; optional fields include title, context, and citations. The file_id source of the Files API is a separate beta feature and is not included in the stable contract of this interface.
Cache Control
The top-levelcache_control will automatically place the cache breakpoint at the last cacheable block:
cache_control can also be written on text, image, document, tool_use, tool_result content blocks, or tool definitions. ttl supports 5m (default) and 1h; please check usage.cache_creation_input_tokens and usage.cache_read_input_tokens to determine cache writing and hits.
Example of a returned result:
Tool Use
The Claude Messages API natively supports tool invocation functionality, allowing the model to call your predefined tools/functions when needed.Python Example
content block of type tool_use:
stop_reason is tool_use, indicating that the model needs to call a tool. Upon receiving this result, you need to execute the tool function and return the result in the form of tool_result to the model:
Differences with Chat Completion API
Ace Data Cloud provides two formats of the Claude API, with the main differences as follows: Theusage.input_tokens of the Messages API only represents uncached input, while cache_read_input_tokens and cache_creation_input_tokens are billed independently; all three will be calculated at their corresponding prices.
If your system is already integrated with the OpenAI format API, you can use the Chat Completion API for a seamless switch. If you need to utilize all of Claude’s native capabilities, it is recommended to use the Messages API.
Error Handling
The error responses from the public interface use the Ace Data Cloud platform envelope:error.code is a stable error code, error.message is an explanation, and trace_id is used for request troubleshooting. Common HTTP statuses include:
400: Invalid request parameters or protocol content.401: Invalid, missing, or expired authorization token.403: Forbidden access, insufficient balance, or quota limits.404: API or model does not exist.413: Request body too large.429: Too many requests.500/503/504: Service error, temporarily unavailable, or processing timeout.
Error Response Example
error.code.

