Skip to content

Commit 9002060

Browse files
committed
Update anthropic construction
1 parent 1d6e4df commit 9002060

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pydantic_ai_slim/pydantic_ai/providers/gateway.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
from urllib.parse import urljoin
88

99
import httpx
10-
from anthropic import AsyncAnthropic
1110

1211
from pydantic_ai.exceptions import UserError
1312
from pydantic_ai.models import Model, cached_async_http_client, get_user_agent
1413

1514
if TYPE_CHECKING:
15+
from anthropic import AsyncAnthropic
1616
from google.genai import Client as GoogleClient
1717
from groq import AsyncGroq
1818
from openai import AsyncOpenAI
@@ -106,9 +106,9 @@ def gateway_provider(
106106

107107
return AnthropicProvider(
108108
anthropic_client=AsyncAnthropic(
109+
auth_token=api_key,
109110
base_url=urljoin(base_url, 'anthropic'),
110111
http_client=http_client,
111-
default_headers={'Authorization': api_key},
112112
)
113113
)
114114
elif upstream_provider == 'google-vertex':

tests/providers/cassettes/test_gateway/test_gateway_provider_with_anthropic.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interactions:
4040
content:
4141
- text: The capital of France is Paris.
4242
type: text
43-
id: msg_014JDheu3y78eUkXc8faaVUx
43+
id: msg_015tco2dv5oh9rFq1PcZAduv
4444
model: claude-3-5-sonnet-20241022
4545
role: assistant
4646
stop_reason: end_turn

0 commit comments

Comments
 (0)