Metadata-Version: 2.5
Name: fastaf-sdk
Version: 0.1.0
Summary: FastAF API client and optional agent tools
Project-URL: Homepage, https://fastaf.co
Project-URL: Repository, https://github.com/fastaf-co/fastaf-sdk
Author-email: FastAF <dev@fastaf.co>
Requires-Python: >=3.10
Requires-Dist: httpx<1,>=0.27
Provides-Extra: crewai
Requires-Dist: crewai<2,>=1; extra == 'crewai'
Provides-Extra: langchain
Requires-Dist: langchain-core<2,>=1; extra == 'langchain'
Provides-Extra: llamaindex
Requires-Dist: llama-index-core<0.15,>=0.14; extra == 'llamaindex'
Provides-Extra: test
Requires-Dist: build<2,>=1; extra == 'test'
Requires-Dist: pytest<10,>=8; extra == 'test'
Description-Content-Type: text/markdown

# fastaf-sdk

[FastAF](https://fastaf.co) · Docs: https://fastaf.co/docs/


Distribution name: **fastaf-sdk**. Import: **fastaf**. The unrelated `fastaf`
PyPI distribution is not this SDK. Nothing here has been published.

Python 3.10+. Local installation (from this directory):

```sh
pip install -e .
# Install only integrations you use:
pip install -e '.[langchain,llamaindex,crewai]'
```

```python
import os
from fastaf import FastAF, FastAFError

with FastAF(os.environ["FASTAF_API_KEY"]) as client:
    data = client.search("best espresso machine", results=5)
    markdown = client.request("scrape", {"url": "https://example.com", "formats": "markdown"})
    data = client.request("serp", {"query": "coffee"}, method="POST")
```

`request(endpoint, params)` covers the live `/v1/*` endpoints. Returns decoded
JSON, text, or bytes for images. Keys stay in Authorization headers. Errors
raise `FastAFError` with `status`, `body`, and `headers` (including Retry-After).
Network/timeout exceptions remain httpx exceptions. Default timeout: 60 seconds;
override `timeout=30`. There are no automatic retries, redirects or x402 payments.
A 402 on keyed REST means insufficient credits, not permission to spend a wallet.
Close the client or use its context manager. Do not put keys in browser code.

## Agent tools

```python
from fastaf.tools import langchain_tool, llamaindex_tool, crewai_tool

# Use inside the client's lifetime. Each accepts the same FastAF client.
search = langchain_tool(client)    # StructuredTool
search = llamaindex_tool(client)   # FunctionTool
search = crewai_tool(client)       # CrewAI tool
```

Tools accept `query` and `results` (1-10, default 5). They return JSON strings;
credentials are not part of agent-visible schemas. Each call consumes API
credits, so configure agent step limits. Integrations import lazily.

## Tests and local packaging

```sh
pip install -e '.[test,langchain,llamaindex,crewai]'
pytest
python -m build
```

Tests use httpx.MockTransport, never real keys or billable calls. Without optional
frameworks, their integration tests skip; install all extras to run the full suite.
The private distribution classifier deliberately blocks uploading to PyPI.
