Docs

API Reference

Complete API reference for Alien Function bindings.

The Function binding enables direct function-to-function invocation — low-latency internal calls that bypass public endpoints.

invoke

Invokes a function with a full HTTP request.

const response = await func.invoke(request)
// response: { status: number, headers: Record<string, string>, body: Uint8Array }
let response = func.invoke(FunctionInvokeRequest {
    target_function: "processor".into(),
    method: "POST".into(),
    path: "/resize".into(),
    headers: BTreeMap::new(),
    body: payload_bytes,
    timeout: Some(Duration::from_secs(30)),
}).await?;
ParameterTypeRequiredDescription
request.targetFunctionstringYesFunction name or identifier.
request.methodstringYesHTTP method (GET, POST, PUT, DELETE, etc.).
request.pathstringYesRequest path (e.g., /resize).
request.headersRecord<string, string>NoHTTP headers.
request.bodyUint8ArrayNoRequest body as bytes.
request.timeoutMsnumberNoTimeout in milliseconds.

Returns: FunctionInvokeResponse{ status: number, headers: Record<string, string>, body: Uint8Array }


invokeJson

High-level JSON invocation with typed request and response.

const result = await func.invokeJson<TReq, TRes>(
  targetFunction: string,
  body: TReq,
  options?: {
    method?: string       // default: "POST"
    path?: string         // default: "/"
    headers?: Record<string, string>
    timeoutMs?: number
  }
): Promise<TRes>

Automatically serializes the request body as JSON and parses the response body as JSON.


get

Convenience method for GET requests with a typed JSON response.

const result = await func.get<TRes>(
  targetFunction: string,
  path?: string,
  options?: {
    headers?: Record<string, string>
    timeoutMs?: number
  }
): Promise<TRes>

getUrl

Returns the function's public URL, if it has public ingress configured.

const url = await func.getUrl(): Promise<string | undefined>
async fn get_function_url(&self) -> Result<Option<String>>

Returns undefined / None if the function has private ingress only.


Types

FunctionInvokeRequest

interface FunctionInvokeRequest {
  targetFunction: string
  method: string
  path: string
  headers?: Record<string, string>
  body?: Uint8Array
  timeoutMs?: number
}
pub struct FunctionInvokeRequest {
    pub target_function: String,
    pub method: String,
    pub path: String,
    pub headers: BTreeMap<String, String>,
    pub body: Vec<u8>,
    pub timeout: Option<Duration>,
}

FunctionInvokeResponse

interface FunctionInvokeResponse {
  status: number
  headers: Record<string, string>
  body: Uint8Array
}
pub struct FunctionInvokeResponse {
    pub status: u16,
    pub headers: BTreeMap<String, String>,
    pub body: Vec<u8>,
}

On this page