Skip to content

Add cache_control attribute to Message #317

Open
@NexumIT

Description

@NexumIT

Within Claude AI you can pass a attribute for caching.

$data = [
    "model" => "claude-3-5-sonnet-20240620",
    "max_tokens" => 1024,
    "messages" => [
        [
            "role" => "user",
            "content" => [
                [
                    "type" => "text",
                    "text" => $prompt,
                ]
            ]
        ],
        [
            "role" => "assistant",
            "content" => [
                [
                    "type" => "tool_use",
                    "id" => "tool_1",
                    "name" => "get_weather",
                    "input" => [
                        "location" => "Amsterdam"
                    ],
                    "cache_control" => ["type" => "ephemeral"] // Cache the tool call
                ]
            ]
        ],
        [
            "role" => "user",
            "content" => [
                [
                    "type" => "text",
                    "text" => $question
                ]
            ]
        ]
    ]
];

I can't find how to do this. Is this possible? If not, is it possible to add?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions