Skip to main content

fetch-hive-sdk

Official Python SDK for Fetch Hive — invoke AI prompts, workflows, and agents from your application.

PyPI version

Installation

pip install fetch-hive-sdk

Quick start

from fetch_hive_sdk import FetchHive

client = FetchHive(api_key="fhk_...")
# or: client = FetchHive()  # reads FETCH_HIVE_API_KEY env var

Get your API key from the Fetch Hive dashboard.

Invoke a prompt

result = client.invoke_prompt(
    deployment="my-prompt",
    inputs={"name": "Alice", "topic": "machine learning"},
    metadata={},
)
print(result["response"])

Invoke a prompt (streaming)

for chunk in client.invoke_prompt_stream(
    deployment="my-prompt",
    inputs={"name": "Alice"},
):
    if chunk.get("type") == "response":
        print(chunk.get("response", ""), end="", flush=True)
    elif chunk.get("type") == "usage":
        print("\nUsage:", chunk["usage"])

Invoke a workflow

run = client.invoke_workflow(
    deployment="my-workflow",
    inputs={"customer_id": "42"},
    metadata={},
)
print(run["status"], run.get("output"))

Invoke a workflow (async)

run = client.invoke_workflow(
    deployment="my-workflow",
    inputs={"customer_id": "42"},
    async_mode=True,
    callback_url="https://example.com/webhook",
)
print("Queued:", run["run_id"])

Invoke an agent

reply = client.invoke_agent(
    agent="my-agent",
    message="What is the weather in London?",
    metadata={},
)
print(reply["response"])

Metadata

Pass optional metadata on prompt, workflow, or agent invokes to attach flat audit fields for log display and filtering. Metadata values must be strings, numbers, booleans, or None.

Invoke an agent (streaming)

for chunk in client.invoke_agent_stream(
    agent="my-agent",
    message="What is the weather in London?",
    thread_id="session-abc123",  # optional — persist conversation history
):
    if chunk.get("type") == "response":
        print(chunk.get("response", ""), end="", flush=True)
    elif chunk.get("type") == "tool":
        print(f"\n[Calling tool: {chunk.get('tool')}]")
    elif chunk.get("type") == "usage":
        print("\nUsage:", chunk["usage"])

Tool approvals

tool_approval is optional on invoke_agent, invoke_agent_stream, ainvoke_agent_stream, and invoke_workflow. Omit it, or pass "policy", to follow saved rules. "auto_approve" applies to this call only, and only when the API key is allowed to auto-approve actions.

When a response has status "awaiting_approval", decide with the API key. The run resumes on the server. Do not send decided_tool_approvals.

client.decide_tool_action_approval("WORKSPACE_ID", "APPROVAL_ID", "allow_once")

pending = client.list_tool_action_approvals("WORKSPACE_ID", status="pending")
one = client.get_tool_action_approval("WORKSPACE_ID", "APPROVAL_ID")

reply = client.invoke_agent(
    agent="my-agent",
    message="Send the follow-up",
    tool_approval="auto_approve",
)

decision is "allow_once" or "deny". always_allow is only available in the dashboard.

Multimodal (image) inputs

result = client.invoke_agent(
    agent="vision-agent",
    message="Describe this image",
    image_urls=["https://example.com/photo.jpg"],
)
print(result["response"])

Async streaming

import asyncio

async def main():
    async for chunk in client.ainvoke_agent_stream(
        agent="my-agent",
        message="Hello",
        thread_id="session-abc123",
    ):
        if chunk.get("type") == "response":
            print(chunk.get("response", ""), end="", flush=True)
        elif chunk.get("type") == "tool":
            print(f"\n[Calling tool: {chunk.get('tool')}]")
        elif chunk.get("type") == "usage":
            print("\nUsage:", chunk["usage"])

asyncio.run(main())

Authentication

Pass the API key to the constructor or set the environment variable:

export FETCH_HIVE_API_KEY=fhk_...
client = FetchHive()  # picks up FETCH_HIVE_API_KEY automatically

Configuration

Option Default Description
api_key FETCH_HIVE_API_KEY env var Bearer token from the Fetch Hive dashboard
base_url https://api.fetchhive.com/v1 Override the API base URL
timeout 120 Request timeout in seconds

Version

0.4.1

License

MIT — see LICENSE.

Metadata

Release files for fetch-hive-sdk 0.4.1

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

Source distribution (sdist)

Source distribution for fetch-hive-sdk 0.4.1
File Size Uploaded Provenance
fetch_hive_sdk-0.4.1.tar.gz 133.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fetch-hive-sdk 0.4.1
File Interpreter ABI Platform
fetch_hive_sdk-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 141.2 kB

Release files / fetch_hive_sdk-0.4.1.tar.gz

Download URL fetch_hive_sdk-0.4.1.tar.gz
Size 133.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2435dc693192fc6216b6eca3942a9b19e5a63c0bcb66925aba60c5d0e731ccba
BLAKE2b-256 checksum
How to use checksums
4746001f808e497f8321b939181e93ce31f9cf42a5ab14255ecb9b86bb9e7df3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / fetch_hive_sdk-0.4.1-py3-none-any.whl

Download URL fetch_hive_sdk-0.4.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a885b70c15f16eb16ec7e037c001cc31b3ff20541fc723c36442ca4a962c72a1
BLAKE2b-256 checksum
How to use checksums
da8f54e66cfcf759ec920a0e8a81808b23455a786a3a92344ab7cb658ccebea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for fetch-hive-sdk 0.4.1

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.

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