High severity beginner · Fix: 2-5 min

TypeError

TypeError: from_anthropic() got an unexpected keyword argument 'tool_use'

What this error means
The instructor library's from_anthropic method was called with an unsupported 'tool_use' argument, causing a TypeError.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 42, in <module>
    instructor_instance = Instructor.from_anthropic(tool_use=True)
TypeError: from_anthropic() got an unexpected keyword argument 'tool_use'
QUICK FIX
Remove the 'tool_use' keyword argument from the from_anthropic() call to fix the TypeError immediately.

Why it happens

The from_anthropic method in the instructor library does not accept a 'tool_use' keyword argument. This usually happens when developers try to enable Anthropic's tool use feature incorrectly or with outdated method signatures.

Detection

Catch TypeError exceptions when calling from_anthropic and log the exact arguments passed to identify unsupported parameters before the app crashes.

Causes & fixes

1

Passing 'tool_use' argument to from_anthropic which does not support it

✓ Fix

Remove the 'tool_use' argument from the from_anthropic call and configure tool use separately via Anthropic client or prompt.

2

Using outdated instructor library version that lacks tool use support

✓ Fix

Upgrade the instructor library to the latest version that supports Anthropic tool use properly or follow updated usage docs.

3

Confusing Anthropic SDK's tool use parameter with instructor's from_anthropic method parameters

✓ Fix

Use Anthropic SDK client directly to enable tool use, and instantiate instructor without unsupported keyword arguments.

Code: broken vs fixed

Broken - triggers the error
python
from instructor import Instructor

# This line causes the error
instructor_instance = Instructor.from_anthropic(tool_use=True)
print(instructor_instance)
Fixed - works correctly
python
import os
from instructor import Instructor

# Removed unsupported 'tool_use' argument
instructor_instance = Instructor.from_anthropic()
print(instructor_instance)

# Set environment variables or configure Anthropic client separately for tool use
Removed the unsupported 'tool_use' argument from from_anthropic() call because the method does not accept it, preventing the TypeError.
⚠

Workaround

Wrap the from_anthropic call in try/except TypeError, then instantiate without 'tool_use' and configure Anthropic tool use separately via the Anthropic SDK client.

✓

Prevention

Consult the latest instructor and Anthropic SDK documentation to use supported parameters only and separate concerns between instructor instantiation and Anthropic client configuration.

Python 3.9+ · instructor >=0.1.0 · tested on 0.2.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.