anthropics / anthropic-sdk-typescript

Access to Anthropic's safety-first language model APIs
https://www.npmjs.com/package/@anthropic-ai/sdk
MIT License
725 stars 79 forks source link

Please update the OpenAPI spec #605

Open laszukdawid opened 1 week ago

laszukdawid commented 1 week ago

Hi, unfortunately I don't know any better communication channel than to create an issue here. If there's a preferred communication way, please let me know.

For own project (terminal-agent), I had to create Anthropic Go SDK and the best way to do that was by generating one from OpenAPI spec. In another thread, I was pointed to this repository, specifically to .stats.yaml file (https://github.com/anthropics/anthropic-sdk-typescript/blob/main/.stats.yml#L2). It's been quite helpful, so thank you have keeping it public :) (I also have updated copy of it - anthropic-openapi-spec)

As I generated the client from the spec it seems that the spec is missing some things. For one, x-api-key header is required on most of endpoints; however, it's missing from POST /v1/messages and POST /v1/complete (yes, legacy, but still in use). Likewise, endpoints paths have query param (?beta=true) which (I think!) isn't proper way of declaring the spec.

Please let me know if and how I could help :)

RobertCraigie commented 1 week ago

Hey David, have you seen the alpha Go SDK? https://github.com/anthropics/anthropic-sdk-go

endpoints paths have query param (?beta=true) which (I think!) isn't proper way of declaring the spec

you're correct it isn't the proper way of doing things but the server doesn't require the beta param like that, it's just used to have two distinct types for the beta and non-beta endpoints

laszukdawid commented 6 days ago

Thanks @RobertCraigie for the response and pointing to the repo. Somehow I have missed it; will definitely check it out :)

Are you on the Anthropic team?

With the beta param my main concern is around using code auto-generators. Since it isn't (still need to triple check!) according to the spec, code generators I used had some issues, e.g. go client was created with duplicated entities and that's a compilation error.

My main concern is still lack of the x-api-key header. It's always easier to remove not-necessary refs, rather than add something that one doesn't know what's missing. I "figured it out" and would rather the next person not to spend that extra time cross-checking docs with specs.