Official Node.js / TypeScript SDK for Fetch Hive — invoke AI prompts, workflows, and agents from your application.
npm install @fetch-hive/sdk
# or
yarn add @fetch-hive/sdk
# or
pnpm add @fetch-hive/sdkimport { 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.
const result = await client.invokePrompt({
deployment: 'my-prompt',
inputs: { name: 'Alice', topic: 'machine learning' },
metadata: {},
});
console.log(result.response);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);
}const run = await client.invokeWorkflow({
deployment: 'my-workflow',
inputs: { customer_id: '42' },
metadata: {},
});
console.log(run.status, run.output);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);const reply = await client.invokeAgent({
agent: 'my-agent',
message: 'What is the weather in London?',
metadata: {},
});
console.log(reply.response);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.
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);
}const result = await client.invokeAgent({
agent: 'vision-agent',
message: 'Describe this image',
image_urls: ['https://example.com/photo.jpg'],
});
console.log(result.response);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_...| 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 |
0.2.6
MIT — see LICENSE.