metaflow-anakin
A Metaflow extension for Anakin, a web data API. Add @anakin to a step to scrape pages to markdown or structured JSON, crawl sites, run AI web search, run Wire actions on supported sites, and manage website monitors.
pip install metaflow-anakin
Requires Metaflow 2.13+ and Python 3.10 to 3.13.
Quickstart
from metaflow import FlowSpec, anakin, card, current, step
class WebResearchFlow(FlowSpec):
@step
def start(self):
self.pages_to_scrape = ["https://example.com", "https://www.iana.org/help/example-domains"]
self.next(self.scrape, foreach="pages_to_scrape")
@card(type="anakin_calls")
@anakin
@step
def scrape(self):
self.page = current.anakin.scrape_url(self.input)
self.next(self.join_pages)
@step
def join_pages(self, inputs):
self.pages = [inp.page for inp in inputs]
self.next(self.end)
@step
def end(self):
for page in self.pages:
print(page["url"], len(page["markdown"]), "chars")
if __name__ == "__main__":
WebResearchFlow()
python web_research_flow.py run
This works without an API key on a small free per-IP allowance. For everything else, get a key at anakin.io/dashboard (the free tier needs no card) and set ANAKIN_API_KEY.
What the decorator adds
You can call anakin-sdk directly inside a step. @anakin handles what tends to go wrong when you do that in a flow:
- Artifacts stay readable. Methods return plain dicts and lists, so
Flow(...).latest_run.data.pagesworks in a notebook withoutanakin-sdkinstalled. - Your API key stays out of the datastore. The key is read from the environment, can't be a decorator attribute, and
self.client = current.anakinfails the step instead of saving it. @retrywon't repeat a write.wire_write_actionrefuses to run on a re-attempt unless you set@anakin(allow_write_on_retry=True). Read actions retry normally.- You can see what each task fetched. See Call log and card.
@pypisteps get the SDK. See Remote tasks.- Payments are refused.
wire_write_action,wire_buildandbrowser_taskraise before calling the API for anything that looks like a payment or fund transfer, the same rule as Anakin's MCP server. SetANAKIN_ALLOW_FINANCIAL=trueto turn this off. - Monitor webhook secrets are redacted from results, so they aren't stored as artifacts.
Methods
Call these on current.anakin inside a step with @anakin.
| Group | Methods |
|---|---|
| Web data | scrape_url, scrape_batch, map, crawl, search, agentic_search |
| Wire site actions | wire_discover, wire_catalog, wire_read_action, wire_write_action, wire_identities, wire_login, wire_build, wire_build_status |
| Website monitors | monitor_create, monitor_list, monitor_changes, monitor_control |
| AI visibility | ai_visibility_search, ai_visibility_sources |
| Browser | session_list, session_delete, browser_task |
current.anakin.sdk is the underlying anakin.Anakin client, for anything else. Outside a flow, from metaflow import AnakinClient gives you the same methods.
The SDK retries 429 and 5xx responses on its own, so @retry is for failures that outlast those retries. Failed calls raise subclasses of anakin.AnakinError.
Options
@anakin(api_key_env="MY_ANAKIN_KEY", allow_write_on_retry=False, base_url=None)
| Attribute | Default | Meaning |
|---|---|---|
api_key_env |
ANAKIN_API_KEY |
Environment variable holding the key |
allow_write_on_retry |
False |
Let wire_write_action run on a @retry re-attempt |
base_url |
None |
Override the API base URL |
You can also attach it from the command line: python flow.py run --with anakin.
Call log and card
Each task's calls are saved to its metadata, with the operation, target, status, time, job id, cache hit and credits. Query strings are removed from URLs, and request parameters and page content aren't logged.
from metaflow import Flow, get_anakin_calls
for task in Flow("WebResearchFlow").latest_run["scrape"]:
print(get_anakin_calls(task)["calls"])
@card(type="anakin_calls") shows the same log as a table:
python web_research_flow.py card view scrape
The log is metadata rather than an artifact so that merge_artifacts keeps working in joins. Only the first 200 calls per task are kept, and total and dropped tell you if any were left out.
Remote tasks (Kubernetes, AWS Batch)
Metaflow's code package carries this extension to remote tasks, but not its dependencies. Without anakin-sdk in the task's environment, the step fails with an error that says so.
Use @pypi, which gets anakin-sdk added for you:
@pypi(python="3.12")
@anakin
@step
def scrape(self): ...
python flow.py --environment=pypi run --with kubernetes
Or install anakin-sdk>=0.2,<0.3 in your image. anakin-sdk isn't on conda-forge, so @conda steps can't use it.
The key has to reach the task too, because your shell's environment doesn't. Use a secret, not @environment, which puts the value in the job spec:
@kubernetes(secrets=["anakin-credentials"]) # a Kubernetes secret with an ANAKIN_API_KEY key
@anakin
@step
def scrape(self): ...
@secrets(sources=["my-secret-store-entry"]) # any configured @secrets backend
@anakin
@step
def scrape(self): ...
Development
Metaflow finds extensions from an installed distribution's top_level.txt, so install the built wheel, not an editable install, and run pytest directly rather than python -m pytest (a copy of the source on sys.path makes Metaflow refuse to load the extension).
uv build --wheel --out-dir dist
uv venv && uv pip install dist/*.whl --group test --group lint
.venv/bin/pytest
ANAKIN_LIVE_TESTS=1 .venv/bin/pytest tests/test_live.py # calls api.anakin.io, no key needed
License
Apache-2.0
Metadata
Release files for metaflow-anakin 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| metaflow_anakin-0.1.0.tar.gz | 30.4 kB | With provenance | Details for metaflow_anakin-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metaflow_anakin-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for metaflow_anakin-0.1.0-py3-none-any.whl |
Total release size: 58.1 kB
Release files / metaflow_anakin-0.1.0.tar.gz
| Download URL | metaflow_anakin-0.1.0.tar.gz |
|---|---|
| Size | 30.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc0e34ebc67054d4e0e72d57d49bce2afc375f2d9f8541e69d4c394625a9217d
|
|
BLAKE2b-256 checksum How to use checksums |
647c19db009b3da5357f0656ab29979070f074e1b1b4c0af14af01709b3efc0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / metaflow_anakin-0.1.0-py3-none-any.whl
| Download URL | metaflow_anakin-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19a5b31898564f78210f60394804f1b76830f85c8a6ef5e52e8af2d1052a7542
|
|
BLAKE2b-256 checksum How to use checksums |
1383819d1d8e2eee1b24718fc0eed02b30fe0a3aafb4b9440781b19de875a370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for metaflow-anakin 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for metaflow_anakin-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.