Skip to content

Use ANTHROPIC_API_KEY as default#3

Merged
DavidTorresIPA merged 3 commits intomainfrom
use-claude-api
Jan 20, 2026
Merged

Use ANTHROPIC_API_KEY as default#3
DavidTorresIPA merged 3 commits intomainfrom
use-claude-api

Conversation

@NKeleher
Copy link
Contributor

Pull Request Summary 🚀

What does this PR do? 📝

Enables both anthropic and openai api keys in the llm basics scripts

Why is this change needed? 🤔

We'd like to be able to have an option to use Anthropic API keys in the llm basics tutorial

How was this implemented? 🛠️

Set anthropic as default (using Haiku 4.5 as default model).

How to test or reproduce ? 🧪

  1. just venv or uv sync to update the python virtual environments.
  2. Add the ANTHROPIC_API_KEY to your .env
  3. Activate virtual environment
  4. Test API connections python examples/test_connection.py
  5. Run the remainder of the python examples in docs/session_01_setup.md

Screenshots (if applicable) 📷

Checklist ✅

  • I have run and tested my changes locally
  • I have limited this PR to less than 1000 lines of code change (if not, explain why)
  • I have updated/added tests to cover my changes (if applicable)
  • I have updated/added requirements to cover my changes (if applicable)
  • I have run linting and formatting on any code changes (if applicable)
  • [ X] I have updated the documentation (README, etc.) accordingly

Reviewer Emoji Legend

:code: Meaning
😃👍💯 :smiley: :+1: :100: I like this...

...and I want the author to know it! This is a way to highlight positive parts of a code review.
⭐⭐⭐ :star: :star: :star: Important to fix before PR can be approved...

And I am providing reasons why it needs to be addressed as well as suggested improvements.
⭐⭐ :star: :star: Important to fix but non-blocking for PR approval...

And I am providing suggestions where it could be improved either in this PR or later.
:star: Give this some thought but non-blocking for PR approval...

...and consider this a suggestion, not a requirement.
:question: I have a question.

This should be a fully formed question with sufficient information and context that requires a response.
📝 :memo: This is an explanatory note, fun fact, or relevant commentary that does not require any action.
:pick: This is a nitpick.

This does not require any changes and is often better left unsaid. This may include stylistic, formatting, or organization suggestions and should likely be prevented/enforced by linting if they really matter
♻️ :recycle: Suggestion for refactoring.

Should include enough context to be actionable and not be considered a nitpick.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for Anthropic's Claude API alongside the existing OpenAI integration, enabling users to work with either provider based on their API key configuration. The changes introduce a unified LLM client interface that abstracts provider-specific differences while maintaining educational transparency about API variations.

Changes:

  • Added Anthropic SDK dependency and multi-provider client factory with automatic detection
  • Replaced direct OpenAI API calls with provider-agnostic adapter functions across all examples
  • Updated documentation to explain dual-provider support and configuration options

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/openai_client.py Removed OpenAI-specific client (replaced by multi-provider client)
src/llm_client.py New unified interface supporting both Anthropic and OpenAI with automatic provider detection
pyproject.toml Added anthropic dependency and migrated dev dependencies to dependency-groups
examples/translate_ipa_document.py Updated to use multi-provider client with provider-specific model selection
examples/test_connection.py Converted to test either provider based on configuration
examples/function_calling_call.py Updated function calling example to work with both providers
examples/function_calling_basic.py Updated basic function calling to support both APIs
examples/chat_stream.py Converted streaming example to multi-provider support
examples/chat_history_stream.py Updated interactive chat with streaming for both providers
examples/chat_history.py Converted chat history example to multi-provider interface
examples/chat.py Updated basic chat example to support both providers
docs/session_01_setup.md Documented multi-provider setup, configuration, and usage patterns
.env.example Added example configuration for both API keys with provider selection guidance

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@DavidTorresIPA DavidTorresIPA merged commit 05a40db into main Jan 20, 2026
1 check passed
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.

3 participants