fix: use AnthropicProvider to pass api_key to PydanticAI model

AnthropicModel doesn't accept api_key directly; it must be passed
through an AnthropicProvider instance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 09:47:02 +01:00
co-authored by Claude Opus 4.5
parent 496f37a538
commit c7a4012831
+2 -1
View File
@@ -9,6 +9,7 @@ from typing import Union
from pydantic_ai.models.anthropic import AnthropicModel
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.anthropic import AnthropicProvider
from src.core.config import config
from src.core.logging_config import get_logger
@@ -113,7 +114,7 @@ def get_model(prefer_cloud: bool | None = None) -> Union[AnthropicModel, OpenAIC
)
return AnthropicModel(
model_name=config.ANTHROPIC_MODEL,
api_key=config.ANTHROPIC_API_KEY,
provider=AnthropicProvider(api_key=config.ANTHROPIC_API_KEY),
)
# Fall back to Ollama