Skip to content

Multiple Beta headers not added according to API specification #266

@newkek

Description

@newkek

Hello, I am running into an issue where trying to use multiple Beta features headers in a BetaMessageNewParams may result in some of those Beta headers being ignored.

The anthropic API documentation mentions that multiple Beta features need to be enabled by providing a list of comma separated values in a single Header key.

However, https://github.com/anthropics/anthropic-sdk-go/blob/main/betamessage.go#L56 loops over each values in the Beta slice and calls option.WithHeaderAdd(), which will eventually call requests.Header.Add() with the anthropic-beta key.
This will result in multiple values being added to that same key in the http Request Header.

The issue is, in the Go http client, when there are multiple values in the slice for a Header key, the result over the wire will be:

Anthropic-Beta: value1
Anthropic-Beta: value2

And not:

Anthropic-Beta: value1,value2

Based on the Anthropic docs it means either: one of the options will be ignored? Or both? It's unclear.
But either way the SDK does not seem to follow the same convention as the API regarding these Beta headers.

I would be happy to provide a straightforward PR fix for this if you agree with the issue. Thank you

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