Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

use new anthropic interface

Ishaan Jaffbd39a395f1eb
diff --git a/litellm/__init__.py b/litellm/__init__.py
index a62322cef9e..4db5bff11bb 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -1026,7 +1026,7 @@ from .proxy.proxy_cli import run_server
from .router import Router
from .assistants.main import *
from .batches.main import *
-from .messages import *
+from .anthropic import *
from .batch_completion.main import * # type: ignore
from .rerank_api.main import *
from .llms.anthropic.experimental_pass_through.messages.handler import *
diff --git a/litellm/anthropic/__init__.py b/litellm/anthropic/__init__.py
new file mode 100644
index 00000000000..c56a530c3c5
--- /dev/null
+++ b/litellm/anthropic/__init__.py
@@ -0,0 +1,4 @@
+"""
+Anthropic module for LiteLLM
+"""
+from .messages import acreate, create
diff --git a/litellm/messages/__init__.py b/litellm/anthropic/messages/__init__.py
similarity index 100%
rename from litellm/messages/__init__.py
rename to litellm/anthropic/messages/__init__.py
diff --git a/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py b/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py
index cb7ac0d3bf5..ec268b1a245 100644
--- a/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py
+++ b/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py
@@ -84,7 +84,7 @@ async def test_anthropic_messages_non_streaming():
messages = [{"role": "user", "content": "Hello, can you tell me a short joke?"}]
# Call the handler
- response = await litellm.messages.acreate(
+ response = await litellm.anthropic.messages.acreate(
messages=messages,
api_key=api_key,
model="claude-3-haiku-20240307",
@@ -116,7 +116,7 @@ async def test_anthropic_messages_streaming():
# Call the handler
async_httpx_client = AsyncHTTPHandler()
- response = await litellm.messages.acreate(
+ response = await litellm.anthropic.messages.acreate(
messages=messages,
api_key=api_key,
model="claude-3-haiku-20240307",
@@ -136,7 +136,7 @@ async def test_anthropic_messages_streaming_with_bad_request():
Test the anthropic_messages with streaming request
"""
try:
- response = await litellm.messages.acreate(
+ response = await litellm.anthropic.messages.acreate(
messages=["hi"],
api_key=os.getenv("ANTHROPIC_API_KEY"),
model="claude-3-haiku-20240307",
@@ -460,7 +460,7 @@ async def test_anthropic_messages_with_extra_headers():
mock_client.post = AsyncMock(return_value=mock_response)
# Call the handler with extra_headers and our mocked client
- response = await litellm.messages.acreate(
+ response = await litellm.anthropic.messages.acreate(
messages=messages,
api_key=api_key,
model="claude-3-haiku-20240307",