Skip to main content

machinelibrary

Python client for Machine Library: search full text across scholarly papers, books, patents, standards and Wikipedia, read bounded full text, and find passages inside long documents. Every result carries a canonical source_uri to cite.

Built for AI agents and RAG pipelines. Framework adapters: langchain-machinelibrary, llama-index-tools-machinelibrary. Prefer MCP? Connect https://mcp.machinelibrary.ai — see machinelibrary.ai/mcp.

Install

pip install machinelibrary
export MACHINELIBRARY_API_KEY=ml_...   # https://machinelibrary.ai/keys

Use

from machinelibrary import MachineLibrary

ml = MachineLibrary()
hits = ml.search("solid-state battery dendrite growth", limit=5)
for hit in hits:
    print(hit.title, hit.source_uri)
    print("  ", hit.text)

# Find the passages that support a claim, without downloading the whole text.
for passage in ml.search_in_document(hits[0].source_uri, "critical current density"):
    print(passage.text)

# Bounded full text (check `content_truncated`).
doc = ml.fetch_document("doi:10.1038/nature14539", max_tokens=8000)

AsyncMachineLibrary has the same methods as coroutines.

Dates for issued_after / issued_before are Unix seconds. Identifiers accept DOIs (doi:…, https://doi.org/…), pmid:, arxiv: and isbn: shorthands.

Billing and limits

Searches and document reads are charged per request to the account that owns the key; see pricing. InsufficientCreditError means the balance needs a top-up. Results are evidence to review, not proof that a claim is correct, and coverage is not exhaustive.

License

MIT

Search profiles (0.2.0)

Search scope and ranking defaults come from the server's API profile, which currently searches Library documents. Clients do not select indexes. The index option (and LlamaIndex's social option) has been removed; call search(query, limit=...) in Python or search(query, { limit }) in JavaScript. For unified Library and Social search through MCP, connect to https://mcp.machinelibrary.ai and call machinelibrary_search.

Metadata

Release files for machinelibrary 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for machinelibrary 0.2.0
File Size Uploaded Provenance Actions
machinelibrary-0.2.0.tar.gz 7.7 kB Without provenance Details for machinelibrary-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for machinelibrary 0.2.0
File Interpreter ABI Platform Actions
machinelibrary-0.2.0-py3-none-any.whl Python 3 none any Details for machinelibrary-0.2.0-py3-none-any.whl

Total release size: 15.4 kB

Release files / machinelibrary-0.2.0.tar.gz

Download URL machinelibrary-0.2.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0be6a17466bec376e3805222d52d499cfb826cbbb32421c5a99728b85270cb16
BLAKE2b-256 checksum
How to use checksums
1dd5ed16e1d09e762abf1a6c7172dfca83d9ab6aeba8cd5db314023e7f2dd73c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / machinelibrary-0.2.0-py3-none-any.whl

Download URL machinelibrary-0.2.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82c0c878f1bcf213c84564018ba287a144b23e76ff2c1d40875009a21ad31c33
BLAKE2b-256 checksum
How to use checksums
e8443db885d795f0ff104fd133d7026ad54702e55bceb2acb049f3d7c401c984
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for machinelibrary 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page