client.functions.invoke
Invoke an edge function by name.
Signature
class Client {
functions: {
invoke<T = unknown>(name: string, body?: unknown): Promise<{ data: T; latencyMs: number }>
}
}
Parameters
| Name | Type | Required | Notes |
|---|---|---|---|
| string | yes | Function name to invoke |
| unknown | no | JSON-serializable payload |
Throws
| Error | Condition |
|---|---|
| Function does not exist |
| Invalid or expired API key |
| Function execution threw |
| Function exceeded 30s timeout |
Examples
Basic invoke:
import { Client } from '@blueforge/client'
const bf = new Client({ apiKey: process.env.BF_API_KEY!, url: 'https://your-project.blueforge.dev' })
const { data, latencyMs } = await bf.functions.invoke('hello', { name: 'world' })
console.log(data, `(${latencyMs}ms)`)
Error handling:
try {
await bf.functions.invoke('hello')
} catch (e) {
if (e instanceof NotFoundError) console.error('function not found')
if (e instanceof TimeoutError) console.error('function timed out')
}
Pitfalls
- Cold starts — first invocation may take 1–3s longer while the runtime initialises
- Payload limit — request body is capped at 1 MB
- Timeout — functions hard-stop at 30 seconds regardless of response
See also
{auto-injected}
Tested against
{auto-injected}