Prompt cache mode can be supported by setting parameters: "cache_control": {"type": "ephemeral"} (If you need a dedicated channel, please contact the administrator)
Request
Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Header Params
Body Params application/json
Example
{"model":"claude-3-7-sonnet-20250219","messages":[{"role":"user","content":[{"type":"text","text":"Summarize the content of the article, no more than 50 words: {text}","cache_control":{"type":"ephemeral"}}]}]}
Request Code Samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl--location'/v1/messages' \
--header'x-api-key: {YOUR_API_KEY}' \
--header'Authorization: Bearer <token>' \
--header'content-type: application/json' \
--data'{
"model": "claude-3-7-sonnet-20250219",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the content of the article, no more than 50 words: {text}",
"cache_control": {
"type": "ephemeral"
}
}
]
}
]
}'
Responses
🟢200OK
application/json
Bodyapplication/json
Example
{"id":"msg_bdrk_01MKgCTVgyqRZTHF9ej4xwZ8","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"The paper points out that AI hallucinations are an inevitable product of the training mechanism, and the model tends to make blind guesses rather than admit not knowing. Comparative tests show that the accuracy of the model that is good at guessing seems to be high, but the error rate is extremely high; while the honest model would rather not answer than tell nonsense."}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":0,"cache_read_input_tokens":1869,"output_tokens":93}}