Metadata-Version: 2.4
Name: cracked-ai-langchain
Version: 0.1.0
Summary: LangChain tools for Cracked, the agent tool router: CrackedTool plus cracked_tools(query) that turns discover results into StructuredTools.
License: MIT
Project-URL: Documentation, https://cracked.ai/docs/sdks
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: cracked-ai>=0.1.0
Requires-Dist: langchain-core>=0.2
Requires-Dist: pydantic>=2

# Cracked for LangChain

Give any LangChain agent 50,000+ tools through one API key.

Publishing to PyPI soon. Until then install from the repo path:

```bash
pip install ./sdk/python ./sdk/integrations/langchain langchain-core
# later: pip install cracked-ai-langchain
```

Set `CRACKED_API_KEY` (get one at https://cracked.ai/app/keys, or let the agent register itself with `Cracked.register_agent()`).

## Two ways to use it

**1. Generic toolkit** (the agent discovers, inspects and runs on its own):

```python
from langchain.agents import create_agent          # or your usual agent constructor
from cracked_ai_langchain import cracked_toolkit

agent = create_agent(model="openai:gpt-4.1", tools=cracked_toolkit())
agent.invoke({"messages": [("user", "What is the weather in Austin right now?")]})
```

Tools: `cracked_discover`, `cracked_inspect`, `cracked_run` (`CrackedTool`), `cracked_run_capability`.

**2. Pre-resolved tools** (one StructuredTool per endpoint, schema taken from `inspect`, so the model fills the provider's real fields):

```python
from cracked_ai_langchain import cracked_tools

tools = cracked_tools("instagram profile followers", limit=3)
for t in tools:
    print(t.name, t.args)     # e.g. apify_apify_instagram-profile-scraper {'usernames': ...}
agent = create_agent(model="openai:gpt-4.1", tools=tools)
```

`CrackedTool` alone is a multi-argument `BaseTool` (`provider`, `endpoint`, `input`) you can add to an existing tool list.

All tools return a status line (`runId`, `status`, `httpStatus`, `costUsd`) followed by the JSON output, truncated to `max_output_chars` (default 20,000). API errors come back as JSON `{"error", "status", "message"}` strings so the agent can recover (402 = top up, 503 BLOCKED = provider needs your key, pick another).

## Example

`python example.py` runs `cracked_toolkit()` and a `cracked_tools("weather")` tool directly (no LLM needed) so you can verify wiring before adding a model.
