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]

docs(anthropic.md): add claude-3-7-sonnet support

Krrish Dholakiade8497309b93
diff --git a/docs/my-website/docs/providers/anthropic.md b/docs/my-website/docs/providers/anthropic.md
index cda0bb97a67..55e9ba10d38 100644
--- a/docs/my-website/docs/providers/anthropic.md
+++ b/docs/my-website/docs/providers/anthropic.md
@@ -819,6 +819,114 @@ resp = litellm.completion(
print(f"\nResponse: {resp}")
```
+## Usage - Thinking / `reasoning_content`
+
+<Tabs>
+<TabItem value="sdk" label="SDK">
+
+```python
+from litellm import completion
+
+resp = completion(
+ model="anthropic/claude-3-7-sonnet-20250219",
+ messages=[{"role": "user", "content": "What is the capital of France?"}],
+ thinking={"type": "enabled", "budget_tokens": 1024},
+)
+
+```
+
+</TabItem>
+
+<TabItem value="proxy" label="PROXY">
+
+1. Setup config.yaml
+
+```yaml
+- model_name: claude-3-7-sonnet-20250219
+ litellm_params:
+ model: anthropic/claude-3-7-sonnet-20250219
+ 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 <YOUR-LITELLM-KEY>" \
+ -d '{
+ "model": "claude-3-7-sonnet-20250219",
+ "messages": [{"role": "user", "content": "What is the capital of France?"}],
+ "thinking": {"type": "enabled", "budget_tokens": 1024}
+ }'
+```
+
+</TabItem>
+</Tabs>
+
+
+**Expected Response**
+
+```python
+ModelResponse(
+ id='chatcmpl-c542d76d-f675-4e87-8e5f-05855f5d0f5e',
+ created=1740470510,
+ model='claude-3-7-sonnet-20250219',
+ object='chat.completion',
+ system_fingerprint=None,
+ choices=[
+ Choices(
+ finish_reason='stop',
+ index=0,
+ message=Message(
+ content="The capital of France is Paris.",
+ role='assistant',
+ tool_calls=None,
+ function_call=None,
+ provider_specific_fields={
+ 'citations': None,
+ 'thinking_blocks': [
+ {
+ 'type': 'thinking',
+ 'thinking': 'The capital of France is Paris. This is a very straightforward factual question.',
+ 'signature': 'EuYBCkQYAiJAy6...'
+ }
+ ]
+ }
+ ),
+ thinking_blocks=[
+ {
+ 'type': 'thinking',
+ 'thinking': 'The capital of France is Paris. This is a very straightforward factual question.',
+ 'signature': 'EuYBCkQYAiJAy6AGB...'
+ }
+ ],
+ reasoning_content='The capital of France is Paris. This is a very straightforward factual question.'
+ )
+ ],
+ usage=Usage(
+ completion_tokens=68,
+ prompt_tokens=42,
+ total_tokens=110,
+ completion_tokens_details=None,
+ prompt_tokens_details=PromptTokensDetailsWrapper(
+ audio_tokens=None,
+ cached_tokens=0,
+ text_tokens=None,
+ image_tokens=None
+ ),
+ cache_creation_input_tokens=0,
+ cache_read_input_tokens=0
+ )
+)
+```
+
## **Passing Extra Headers to Anthropic API**
Pass `extra_headers: dict` to `litellm.completion`
@@ -1135,3 +1243,4 @@ curl http://0.0.0.0:4000/v1/chat/completions \
</TabItem>
</Tabs>
+
diff --git a/tests/llm_translation/test_anthropic_completion.py b/tests/llm_translation/test_anthropic_completion.py
index 4f031e20d8c..44c305b02eb 100644
--- a/tests/llm_translation/test_anthropic_completion.py
+++ b/tests/llm_translation/test_anthropic_completion.py
@@ -1172,7 +1172,7 @@ def test_anthropic_thinking_output():
thinking={"type": "enabled", "budget_tokens": 1024},
)
- print(resp.choices[0].message)
+ print(resp)
assert (
resp.choices[0].message.provider_specific_fields["thinking_blocks"] is not None
)