diff --git a/docs/my-website/docs/providers/anthropic.md b/docs/my-website/docs/providers/anthropic.md index 4ab4eb0608..1740450b90 100644 --- a/docs/my-website/docs/providers/anthropic.md +++ b/docs/my-website/docs/providers/anthropic.md @@ -606,11 +606,6 @@ response = await client.chat.completions.create( ## **Function/Tool Calling** -:::info - -LiteLLM now uses Anthropic's 'tool' param 🎉 (v1.34.29+) -::: - ```python from litellm import completion @@ -669,6 +664,128 @@ response = completion( ) ``` +### MCP Tool Calling + +Here's how to use MCP tool calling with Anthropic: + + + + +LiteLLM supports MCP tool calling with Anthropic in the OpenAI Responses API format. + + + + + +```python +import os +from litellm import completion + +os.environ["ANTHROPIC_API_KEY"] = "sk-ant-..." + +tools=[ + { + "type": "mcp", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", + "require_approval": "never", + }, +] + +response = completion( + model="anthropic/claude-sonnet-4-20250514", + messages=[{"role": "user", "content": "Who won the World Cup in 2022?"}], + tools=tools +) +``` + + + + +```python +import os +from litellm import completion + +os.environ["ANTHROPIC_API_KEY"] = "sk-ant-..." + +tools = [ + { + "type": "url", + "url": "https://mcp.deepwiki.com/mcp", + "name": "deepwiki-mcp", + } +] +response = completion( + model="anthropic/claude-sonnet-4-20250514", + messages=[{"role": "user", "content": "Who won the World Cup in 2022?"}], + tools=tools +) + +print(response) +``` + + + + + + + +1. Setup config.yaml + +```yaml +model_list: + - model_name: claude-4-sonnet + litellm_params: + model: anthropic/claude-sonnet-4-20250514 + api_key: os.environ/ANTHROPIC_API_KEY +``` + +2. Start proxy + +```bash +litellm --config /path/to/config.yaml +``` + +3. Test it! + + + + +```bash +curl http://0.0.0.0:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LITELLM_KEY" \ + -d '{ + "model": "claude-4-sonnet", + "messages": [{"role": "user", "content": "Who won the World Cup in 2022?"}], + "tools": [{"type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never"}] + }' +``` + + + + +```bash +curl http://0.0.0.0:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LITELLM_KEY" \ + -d '{ + "model": "claude-4-sonnet", + "messages": [{"role": "user", "content": "Who won the World Cup in 2022?"}], + "tools": [ + { + "type": "url", + "url": "https://mcp.deepwiki.com/mcp", + "name": "deepwiki-mcp", + } + ] + }' +``` + + + + + ### Parallel Function Calling