@fetch-hive/sdk
v0.3.0
Published
Official Node.js / TypeScript SDK for the Fetch Hive API
Maintainers
Readme
@fetch-hive/sdk
Official Node.js / TypeScript SDK for Fetch Hive — invoke AI prompts, workflows, and agents from your application.
Installation
npm install @fetch-hive/sdk
# or
yarn add @fetch-hive/sdk
# or
pnpm add @fetch-hive/sdkQuick start
import { FetchHive } from '@fetch-hive/sdk';
const client = new FetchHive({ apiKey: process.env.FETCH_HIVE_API_KEY! });Get your API key from the Fetch Hive dashboard.
Invoke a prompt
const result = await client.invokePrompt({
deployment: 'my-prompt',
inputs: { name: 'Alice', topic: 'machine learning' },
metadata: {},
});
console.log(result.response);Invoke a prompt (streaming)
for await (const chunk of client.invokePromptStream({
deployment: 'my-prompt',
inputs: { name: 'Alice' },
})) {
if (chunk.type === 'response') process.stdout.write(chunk.response ?? '');
if (chunk.type === 'usage') console.log('\nUsage:', chunk.usage);
}Invoke a workflow
const run = await client.invokeWorkflow({
deployment: 'my-workflow',
inputs: { customer_id: '42' },
metadata: {},
});
console.log(run.status, run.output);Invoke a workflow (async)
const run = await client.invokeWorkflow({
deployment: 'my-workflow',
inputs: { customer_id: '42' },
async: { enabled: true, callback_url: 'https://example.com/webhook' },
});
console.log('Queued:', run.run_id);Invoke an agent
const reply = await client.invokeAgent({
agent: 'my-agent',
message: 'What is the weather in London?',
metadata: {},
});
console.log(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 null.
Invoke an agent (streaming)
for await (const chunk of client.invokeAgentStream({
agent: 'my-agent',
message: 'What is the weather in London?',
thread_id: 'session-abc123', // optional — persist conversation history
})) {
if (chunk.type === 'response') process.stdout.write(chunk.response ?? '');
if (chunk.type === 'tool') console.log(`\nCalling tool: ${chunk.tool}`);
if (chunk.type === 'usage') console.log('\nUsage:', chunk.usage);
}Multimodal (image) inputs
const result = await client.invokeAgent({
agent: 'vision-agent',
message: 'Describe this image',
image_urls: ['https://example.com/photo.jpg'],
});
console.log(result.response);Authentication
Pass the API key to the constructor:
const client = new FetchHive({ apiKey: 'fhk_...' });Or set the environment variable and omit the explicit key:
export FETCH_HIVE_API_KEY=fhk_...Configuration
| Option | Default | Description |
|---|---|---|
| apiKey | process.env.FETCH_HIVE_API_KEY | Bearer token from the Fetch Hive dashboard |
| baseURL | https://api.fetchhive.com/v1 | Override the API base URL |
Links
Version
0.3.0
License
MIT — see LICENSE.
