Skip to main content

langchain-getabrain

LangChain tools for GetABrain, an API that lets an agent ask verified people in the US a question and get structured answers back.

Two tools:

Tool Name the model sees What it does
GetABrainAskTool getabrain_ask_human Sends a question, waits up to max_wait_seconds for answers, returns them. If nobody has answered yet it returns status: "pending" and a query_id.
GetABrainGetAnswersTool getabrain_get_answers Reads the answers to an earlier question by query_id. Free and read-only.

People take minutes to hours to answer, so a pending result is normal. The question stays open and the second tool picks up the answers later.

Install

pip install -U langchain-getabrain

Credentials

Create an account and API key at https://www.getabrain.ai/requestor/signup (or see the quick start), then:

export GETABRAIN_API_KEY="gab_k_..."
export GETABRAIN_API_SECRET="gab_s_..."

Cost: with a live key, every answer is paid from your GetABrain balance. With a test-mode key (POST /api/v1/requestor/keys {"mode": "test"}), answers are simulated by an AI stand-in, never reach people, and come back marked "simulated": true with a notice. Build and test with a test-mode key first.

Use it directly

from langchain_getabrain import GetABrainAskTool, GetABrainGetAnswersTool

ask = GetABrainAskTool(max_wait_seconds=60)
print(ask.invoke({
    "question": "Which name is easier to remember?",
    "query_type": "multiple_choice",
    "options": ["Quillo", "Brightdesk"],
    "num_responses": 3,
}))

The result is a JSON string:

{"query_id": "...", "status": "answered", "answers_received": 3, "answers_requested": 3,
 "answers": [{"selected_ids": ["2"], "selected_options": ["Brightdesk"]}, "..."],
 "test_mode": false}

Use it in an agent

from langchain.agents import create_agent
from langchain_getabrain import GetABrainAskTool, GetABrainGetAnswersTool

agent = create_agent(
    model="anthropic:claude-sonnet-4-5",
    tools=[GetABrainAskTool(), GetABrainGetAnswersTool()],
    system_prompt="When a decision needs human judgment, ask a person with getabrain_ask_human.",
)
agent.invoke({"messages": [{"role": "user", "content": "Is our headline 'Ship faster' clear to a normal person?"}]})

Arguments the model fills

Argument Type Notes
question str Required.
query_type yes_no | multiple_choice | rating_scale | text Default yes_no. rating_scale is 1 to 5.
options list[str] Required for multiple_choice (2 or more).
context str Optional background shown to the person.
num_responses int How many different people answer. Default 1.

Settings you set in code

Setting Default Notes
max_wait_seconds 60 How long one call waits before returning pending.
poll_interval_seconds 5 Time between status checks.
max_responses 5 Upper limit on num_responses per call, a spend guard.
speed None relaxed / standard / fast / rush: higher pays people more per answer.
api_key, api_secret, base_url env vars GETABRAIN_API_KEY, GETABRAIN_API_SECRET, GETABRAIN_BASE_URL.
client None Pass a ready getabrain.GetABrain client instead.

Other query types (image comparison, ranking, A/B tests, video and audio review) are available through the getabrain Python SDK and the API docs.

Development

uv sync --group test
uv run pytest

Unit tests mock HTTP and make no network calls.

License

MIT

Metadata

Release files for langchain-getabrain 0.1.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 langchain-getabrain 0.1.0
File Size Uploaded Provenance Actions
langchain_getabrain-0.1.0.tar.gz 8.8 kB Without provenance Details for langchain_getabrain-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-getabrain 0.1.0
File Interpreter ABI Platform Actions
langchain_getabrain-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_getabrain-0.1.0-py3-none-any.whl

Total release size: 16.9 kB

Release files / langchain_getabrain-0.1.0.tar.gz

Download URL langchain_getabrain-0.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
eecb8eb8cb97069e83bc6e8b1eb61008ddfafec955377f177afe838494e67603
BLAKE2b-256 checksum
How to use checksums
73f690a94fcc89074d037174748b0656daeb731a723e838831fca30fa82b5d52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / langchain_getabrain-0.1.0-py3-none-any.whl

Download URL langchain_getabrain-0.1.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae43e06a38f03b7e0ef1e735acc6b38737718864b59d76ecf7da27486d06e8f4
BLAKE2b-256 checksum
How to use checksums
5f0032b2dde05cda972a9a19ed4e4a0c1c6fdd32acc065145241e3d73b3002ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for langchain-getabrain 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.

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