Skip to main content

call_anthropic_structured

Function call_anthropic_structured 

Source
pub fn call_anthropic_structured(
    system: &str,
    user_prompt: &str,
    schema: Value,
) -> Result<String, String>
Expand description

Call the Anthropic Messages API with structured output via tool_use.

Constrains the model output to a JSON Schema by using Anthropic’s tool_use mechanism: tools: [{ name: "emit_spec", input_schema: schema }] with tool_choice: { type: "tool", name: "emit_spec" }.

Returns the tool input serialized as a JSON string on success.