Skip to content

Conversation

@danackerson
Copy link
Contributor

Describe the change
Add support for Anthropic models.

Provide documentation link
Anthropic API requests require a custom header "anthropic-version". More details here

Describe your solution
Added new APITypeAnthropic with APIVersion = "2023-06-01" and baseURL of "https://api.anthropic.com/v1"

Tests
Checking correct APIVersion and default baseURL.

Additional context
Currently, trying to override the default config with Anthropic values, fails with a 404 not found error (because there's no request header "anthropic-version":"2023-06-01").

@codecov
Copy link

codecov bot commented Feb 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.88%. Comparing base (774fc9d) to head (bbdb735).
Report is 86 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #934      +/-   ##
==========================================
+ Coverage   98.46%   98.88%   +0.42%     
==========================================
  Files          24       27       +3     
  Lines        1364     1800     +436     
==========================================
+ Hits         1343     1780     +437     
+ Misses         15       14       -1     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! As usual, integration test, README updates and examples are very much appreciated 🙌🏻

@sashabaranov sashabaranov merged commit be2e238 into sashabaranov:master Feb 25, 2025
3 checks passed
sunhailin-Leo pushed a commit to sunhailin-Leo/go-openai that referenced this pull request Feb 25, 2025
…nov#934)

* feat: add Anthropic API support with custom version header

* refactor: use switch statement for API type header handling

* refactor: add OpenAI & AzureAD types to be exhaustive

* Update client.go

need explicit fallthrough in empty case statements

* constant for APIVersion; addtl tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants