Anthropic Integration
Run Anthropic Claude as a Pixeltable computed column. messages() on insert, cached per row, with the official SDK behind one import.
Challenge
Calling Anthropic from an application usually means a client, a retry loop, and a place to store the completion. The Messages API is well specified, but the surrounding work is not: you persist the prompt, you persist the model name, you persist the text that came back, and you decide when to call again if the prompt changes. A worker that loops rows and writes JSON into a second table will re-call Claude for rows that did not change unless you add your own cache key. Rate limits then land in that worker too. Pixeltable already has a table. The missing piece is treating the Anthropic call as a column of that table, not a side effect of a job.
Solution
Pixeltable ships pixeltable.functions.anthropic.messages as a UDF. On a TableModel you assign it to a computed field. Insert a row and that expression runs. Unchanged rows keep the cached Message object. The package throttles from the rate-limit headers Anthropic returns, so you do not configure a token bucket. Set ANTHROPIC_API_KEY, or the [anthropic] section of the Pixeltable config file. pip install anthropic is required. The documented notebook uses create_table and add_computed_column; an application file uses the same UDF as a class assignment and pxt schema update.
Integration Steps
Step 1 of 4Install Pixeltable plus the Anthropic SDK, then export ANTHROPIC_API_KEY.
# pip install -U 'pixeltable[serve]' anthropic# export ANTHROPIC_API_KEY=...# pxt initimport pixeltable as pxtfrom pixeltable.functions.anthropic import messagesTableModel = pxt.model_base()
💡 The UDF requires the anthropic package. The key can also live in $PIXELTABLE_HOME/config.toml under [anthropic]. Do not put the key in app.py.
Key Benefits
Use Cases
Technical Requirements
Related articles
Ready to Integrate Anthropic?
Get started with Pixeltable and Anthropic in minutes.
pip install pixeltable