Skip to content

ChatOption.ResponseFormat doesn't work #109

@sciutand

Description

@sciutand

Using

PackageVersion Include="Anthropic" Version="12.3.0"

sample code

public class ManualJob(AnthropicClient client) : Job
{
    public CancellationToken Token { get; set; }

    protected override async Task HandleAsync()
    {
        var chatClient = client.Beta.AsIChatClient("claude-sonnet-4-5-20250929");

        var response = await chatClient.GetResponseAsync(new ChatMessage(ChatRole.User,
                "Tell me a joke and give me a number"),
            new ChatOptions
            {
                ResponseFormat = ChatResponseFormat.ForJsonSchema<ResultDto>()
            },
            Token);

        Console.WriteLine($"{response.Text}");
    }
}

public class ResultDto
{
    public required int Number { get; set; }
    public required string Joke { get; set; }
}

yields

{"type":"error","error":{"type":"invalid_request_error","message":"output_format: This field is deprecated. Use 'output_config.format' instead. See https://platform.claude.com/docs/en/build-with-claude/structured-outputs for more information."},"request_id":"req_011CXnQbWsGEKvt5E5r93b6C"}

The issue is this code still uses the deprecated property

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions