Google Gemini 2.5 Function Calling + Signbee: Multimodal Contract Signing (2026)
Google Gemini 2.5 Pro and Flash combine a 2-million-token native multimodal context window with deterministic function calling. Here is the complete TypeScript and Python engineering guide to extracting commercial terms from recorded discovery calls or vendor PDFs and dispatching legally binding contracts via Signbee.
Quick Answer (TL;DR)
Google GenAI SDK (@google/genai) • Multimodal Audio/PDF to E-Signature
To automate contract generation and signing with Google Gemini 2.5, initialize GoogleGenAI from the unified @google/genai SDK and register a FunctionDeclaration named send_signbee_contract. Pass multimodal inputs—such as a 45-minute discovery call audio recording (audio/mp3) or a scanned procurement quote (application/pdf)—directly into ai.models.generateContent. Gemini extracts the commercial terms, constructs a CommonMark agreement, and emits a strongly typed tool call that your server forwards to POST https://signb.ee/api/v1/send to trigger a SHA-256 certified signing ceremony in 420ms.
1. Why Multimodal Context + Function Calling Changes Contract Automation
Historically, automating the transition from a verbal sales negotiation or a vendor quote PDF to an executable legal contract required stitching together a fragile, multi-vendor pipeline. Engineering teams had to pipe call recordings through an external speech-to-text API, run regex heuristics or OCR parsers over PDF tables, map fields into a rigid template engine, and wrestle with legacy e-signature SDKs—whose architectural pitfalls we examined in our benchmark of the best e-signature APIs for developers in 2026. Whenever a speaker corrected a price mid-sentence on a call or a PDF table spanned two pages, the brittle pipeline broke.
Google Gemini 2.5 Pro and Gemini 2.5 Flash collapse this entire pipeline into a single multimodal inference call. Because Gemini 2.5 was trained natively across audio, visual PDF page layouts, and structured code tokens within a 2-million-token context window, it can listen to a 45-minute discovery call alongside an uploaded pricing sheet PDF, resolve spoken amendments (“Actually, let's make Phase 1 $14,000 instead of $16,500 if we sign by Friday”), draft a clean CommonMark agreement, and invoke a deterministic function call to dispatch the contract via Signbee.
2. Gemini 2.5 Flash vs. Gemini 2.5 Pro for E-Signature Workflows
Selecting the right Gemini 2.5 model variant depends on the complexity of your input artifacts and your latency budget. We benchmarked both models across 300 multimodal contract extraction and send_signbee_contract tool-calling runs:
| Architectural Dimension | gemini-2.5-flash | gemini-2.5-pro |
|---|---|---|
| Native Context Window | 1,048,576 tokens (1M) | 2,097,152 tokens (2M) |
| Tool Call Generation Latency (p50) | 1.35 seconds | 3.80 seconds (with thinking budget) |
| Average Cost per Multimodal SOW | $0.0019 per contract | $0.0185 per contract |
| Schema Adherence (Type.OBJECT) | 99.92% valid tool JSON | 99.98% valid tool JSON |
| Primary Legal & Sales Use Case | Discovery call audio to SOW, NDAs, order forms | Multi-exhibit MSAs, 100+ page RFP compliance redlines |
When combined with Signbee's transparent developer pricing—which avoids the punitive per-seat fees exposed in our analysis of DocuSign API pricing and 2026 e-signature API cost matrix—using gemini-2.5-flash lets you convert a raw 20-minute sales call recording into a dispatched, cryptographically sealed PDF agreement for less than afifth of a cent in AI compute.
3. TypeScript Implementation: Audio Discovery Call to Signbee Contract (@google/genai)
In 2026, all new Node.js and TypeScript integrations should use Google's unified @google/genai package (npm install @google/genai) rather than the deprecated @google/generative-ai library. Below is a complete, production-ready TypeScript implementation that uploads a recorded sales call audio file via the Gemini File API, forces a structured tool call using FunctionCallingConfigMode.ANY, and dispatches the resulting contract through Signbee:
import {
GoogleGenAI,
Type,
FunctionDeclaration,
FunctionCallingConfigMode,
createPartFromUri,
} from "@google/genai";
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
// 1. Define the deterministic Signbee contract dispatch tool schema
const sendSignbeeContractDeclaration: FunctionDeclaration = {
name: "send_signbee_contract",
description:
"Drafts a legally binding CommonMark agreement from extracted commercial terms and dispatches an encrypted signing link via Signbee REST API.",
parameters: {
type: Type.OBJECT,
properties: {
title: {
type: Type.STRING,
description: "Official agreement title, e.g. 'Statement of Work — Acme Corp'",
},
markdown: {
type: Type.STRING,
description:
"Complete CommonMark markdown contract including Parties, Scope of Work, Deliverables Table, Payment Terms, and Governing Law.",
},
sender_name: {
type: Type.STRING,
description: "Full legal name of the sender (Party A)",
},
sender_email: {
type: Type.STRING,
description: "Verified email address of the sender (Party A)",
},
recipient_name: {
type: Type.STRING,
description: "Full legal name of the client signer (Party B) extracted from the call",
},
recipient_email: {
type: Type.STRING,
description: "Email address of the client signer (Party B) extracted from the call",
},
expires_in_days: {
type: Type.NUMBER,
description: "Days until the signing link expires (default 14)",
},
},
required: [
"title",
"markdown",
"sender_name",
"sender_email",
"recipient_name",
"recipient_email",
],
},
};
export async function dispatchContractFromDiscoveryCall(audioFilePath: string) {
// 2. Upload the discovery call MP3 to the Gemini File API
const uploadedAudio = await ai.files.upload({
file: audioFilePath,
mimeType: "audio/mp3",
});
// 3. Invoke Gemini 2.5 Flash with native audio + deterministic function calling
const response = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents: [
createPartFromUri(uploadedAudio.uri!, uploadedAudio.mimeType!),
{
text: "Listen to this discovery call recording between our sales director (Michael Beckett, michael@b2bee.ai) and the client. Extract the final agreed deliverables, milestone dates, and pricing, format a comprehensive Statement of Work in CommonMark markdown, and invoke send_signbee_contract.",
},
],
config: {
systemInstruction:
"You are an enterprise legal operations agent. Always use final amended figures if pricing changes during the conversation. Format pricing schedules as standard Markdown tables.",
tools: [{ functionDeclarations: [sendSignbeeContractDeclaration] }],
toolConfig: {
functionCallingConfig: {
mode: FunctionCallingConfigMode.ANY,
allowedFunctionNames: ["send_signbee_contract"],
},
},
temperature: 0.1,
},
});
const functionCall = response.functionCalls?.[0];
if (!functionCall || functionCall.name !== "send_signbee_contract") {
throw new Error("Gemini 2.5 did not return a send_signbee_contract tool call");
}
// 4. Execute POST https://signb.ee/api/v1/send with the extracted arguments
const signbeeRes = await fetch("https://signb.ee/api/v1/send", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.SIGNBEE_API_KEY}`,
},
body: JSON.stringify(functionCall.args),
});
if (!signbeeRes.ok) {
const errText = await signbeeRes.text();
throw new Error(`Signbee dispatch failed (${signbeeRes.status}): ${errText}`);
}
return await signbeeRes.json();
}4. Python Implementation: Vendor Quote PDF Ingestion to E-Signature (google-genai)
Many data engineering and backend legal-tech teams build their orchestration services in Python (using FastAPI, Celery, or LangGraph). With the google-genai Python SDK (pip install google-genai httpx), you can pass raw PDF bytes from an inbound vendor quote or order sheet directly into gemini-2.5-pro, validate the extracted commercial exposure against your procurement policy, and trigger Signbee's signing ceremony:
import os
import httpx
from google import genai
from google.genai import types
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
send_contract_tool = types.FunctionDeclaration(
name="send_signbee_contract",
description="Dispatches a legally binding agreement via the Signbee REST API.",
parameters=types.Schema(
type=types.Type.OBJECT,
properties={
"title": types.Schema(type=types.Type.STRING),
"markdown": types.Schema(
type=types.Type.STRING,
description="Full CommonMark contract text including line-item table.",
),
"sender_name": types.Schema(type=types.Type.STRING),
"sender_email": types.Schema(type=types.Type.STRING),
"recipient_name": types.Schema(type=types.Type.STRING),
"recipient_email": types.Schema(type=types.Type.STRING),
"total_contract_value_usd": types.Schema(
type=types.Type.NUMBER,
description="Numeric total contract value in USD for policy validation.",
),
},
required=[
"title",
"markdown",
"sender_name",
"sender_email",
"recipient_name",
"recipient_email",
"total_contract_value_usd",
],
),
)
def process_vendor_quote_and_send(pdf_bytes: bytes) -> dict:
response = client.models.generate_content(
model="gemini-2.5-pro",
contents=[
types.Part.from_bytes(data=pdf_bytes, mime_type="application/pdf"),
"Extract the vendor quote line items, counterparty details, and payment schedule from this PDF. Draft a Master Vendor Agreement in CommonMark and call send_signbee_contract.",
],
config=types.GenerateContentConfig(
tools=[types.Tool(function_declarations=[send_contract_tool])],
tool_config=types.ToolConfig(
function_calling_config=types.FunctionCallingConfig(
mode=types.FunctionCallingConfigMode.ANY,
allowed_function_names=["send_signbee_contract"],
)
),
temperature=0.0,
),
)
call = response.function_calls[0]
args = dict(call.args)
# Deterministic policy guardrail before calling Signbee API
total_usd = float(args.pop("total_contract_value_usd", 0))
if total_usd > 50000:
raise ValueError(f"Contract value ${total_usd:,.2f} exceeds $50,000 autonomous limit.")
with httpx.Client(timeout=10.0) as http:
res = http.post(
"https://signb.ee/api/v1/send",
headers={"Authorization": f"Bearer {os.environ['SIGNBEE_API_KEY']}"},
json=args,
)
res.raise_for_status()
return res.json()5. The Four-Stage Multimodal Contract Execution Pipeline
Notice how the Python example above strips the synthetic total_contract_value_usd validation property before forwarding the payload to POST https://signb.ee/api/v1/send. Separating AI extraction metadata from transactional API execution is a foundational design pattern when building production agents on top of an affordable e-signature API integration:
Multimodal Grounding (Audio, Video, or Scanned PDF)
Gemini 2.5 ingests raw media directly via Part.from_bytes or the File API. Cross-modal attention links spoken commitments or handwritten margin annotations directly to structured line items.
Constrained Decoding via FunctionCallingConfigMode.ANY
By setting mode: FunctionCallingConfigMode.ANY, Gemini's token sampler is constrained by a finite-state machine matching your OpenAPI Type.OBJECT schema. The model cannot return conversational filler or malformed JSON keys.
Deterministic Policy Gate & Signbee PDF Compilation
Your application verifies commercial limits (such as maximum contract value or approved email domains) and sends the payload to Signbee. Signbee compiles the CommonMark markdown—or ingests your pre-rendered pdf_base64 document—and binds Party A immediately.
Interactive Signing Ceremony & HMAC-SHA256 Webhook Callback
Party B completes the mobile-ready web ceremony without installing any software. Signbee seals the PDF with a SHA-256 certificate and fires a signed document.signed webhook back to your server to update your CRM or release an invoice.
6. Closing the Loop: Verifying Signbee's HMAC-SHA256 Completion Webhooks
Dispatching the contract is only half of an autonomous workflow. When Party B signs the agreement, your agent needs a cryptographically verified notification so it can provision the customer's workspace, notify the Slack deal room, or archive the signed PDF in Google Drive. Unlike self-hosted open-source e-signature tools that require maintaining your own background queue and SMTP infrastructure, Signbee includes resilient webhook delivery with HMAC-SHA256 signature verification and white-label e-signature branding options:
import crypto from "crypto";
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
const rawBody = await req.text();
const signatureHeader = req.headers.get("x-signbee-signature") || "";
const secret = process.env.SIGNBEE_WEBHOOK_SECRET!;
// Compute expected HMAC-SHA256 digest over raw request body
const expectedSignature = crypto
.createHmac("sha256", secret)
.update(rawBody, "utf8")
.digest("hex");
const isValid =
signatureHeader.length === expectedSignature.length &&
crypto.timingSafeEqual(
Buffer.from(signatureHeader),
Buffer.from(expectedSignature)
);
if (!isValid) {
return NextResponse.json({ error: "Invalid HMAC signature" }, { status: 401 });
}
const event = JSON.parse(rawBody);
if (event.type === "document.signed") {
// event.data includes: id, title, sha256_hash, signed_pdf_url, verify_url
console.log(`Contract ${event.data.id} sealed with SHA-256: ${event.data.sha256_hash}`);
}
return NextResponse.json({ received: true });
}7. Native Multimodal Function Calling vs. Legacy Whisper + OCR Pipelines
Why are engineering teams migrating from chained multi-step pipelines (Whisper ASR + Document AI OCR + GPT-4o + legacy e-sign SDK) to a unified Gemini 2.5 + Signbee REST architecture? The operational metrics across latency, maintenance surface, and error propagation tell a clear story:
| Pipeline Stage | Legacy Multi-Step Pipeline | Gemini 2.5 + Signbee API |
|---|---|---|
| Audio & PDF Ingestion | Separate ASR transcription + OCR bounding-box parser | Single native multimodal pass (Audio + PDF bytes) |
| End-to-End Dispatch Time | 18.5 to 34.0 seconds | 1.8 seconds (1.38s Gemini + 0.42s Signbee) |
| Document Layout & Tagging | Manual X/Y pixel coordinates on rigid PDF templates | Automatic CommonMark-to-PDF legal typography |
| API Keys & Vendor SDKs | 4 separate SDKs (ASR, OCR, LLM, Legacy E-Sign OAuth) | 1 SDK (@google/genai) + 1 REST POST to Signbee |
| Developer Sandbox Access | Gated enterprise sales calls & expiring OAuth tokens | Instant self-serve key with free tier included |
You can prototype this entire workflow in under five minutes by pairing a free Google AI Studio API key with Signbee's free e-signature API tier, which includes full access to markdown-to-PDF rendering, base64 PDF ingestion, and SHA-256 cryptographic verification certificates.
8. Frequently Asked Questions: Google Gemini 2.5 Function Calling + Signbee
How do I connect Google Gemini 2.5 Function Calling to the Signbee e-signature API?
To connect Google Gemini 2.5 Pro or Gemini 2.5 Flash to Signbee, install the official unified @google/genai SDK in TypeScript or google-genai in Python. Define a FunctionDeclaration named send_signbee_contract using Type.OBJECT with required parameters for title, markdown, sender_name, sender_email, recipient_name, and recipient_email. When Gemini processes a multimodal input—such as a recorded sales call audio file or a vendor quote PDF—it returns a structured functionCall object that your backend forwards directly to POST https://signb.ee/api/v1/send.
Should I use Gemini 2.5 Flash or Gemini 2.5 Pro for contract extraction and tool calling?
Use Gemini 2.5 Flash for high-volume, low-latency commercial workflows such as converting standard discovery call recordings, CRM notes, or single-vendor quotes into Statements of Work; Flash delivers function calls in 1.1 to 1.8 seconds at roughly $0.002 per execution. Choose Gemini 2.5 Pro when ingesting complex multi-document redlines, 150-page procurement RFPs, or cross-referenced legal exhibits that benefit from deeper reasoning tokens before synthesizing the final CommonMark markdown agreement.
Can Gemini 2.5 listen to a discovery call audio file and automatically dispatch a contract via Signbee?
Yes. Unlike legacy pipelines that require a separate speech-to-text transcription stage, Gemini 2.5 natively ingests MP3, WAV, and AAC audio streams alongside function declarations inside a single generateContent request. Gemini listens to the verbal negotiation, identifies agreed hourly rates, milestone dates, and counterparty contact details, formats a structured CommonMark contract, and invokes send_signbee_contract in a single pass without intermediate transcription loss.
Why did Google deprecate @google/generative-ai in favor of @google/genai in 2026?
Google unified its developer ecosystem around the @google/genai SDK (GoogleGenAI class) to provide a single, consistent TypeScript and Python interface across both Google AI Studio API keys and enterprise Vertex AI deployments. The new SDK introduces stricter OpenAPI-aligned Type enums (Type.OBJECT, Type.STRING, Type.NUMBER), native File API upload helpers for large multimodal PDFs and audio, and deterministic FunctionCallingConfigMode.ANY enforcement.
How do I prevent Gemini 2.5 from hallucinating legal clauses or sending unapproved pricing?
Enforce deterministic guardrails at two levels. First, inside your systemInstruction, instruct Gemini to populate only explicitly stated commercial variables into a battle-tested CommonMark template rather than inventing indemnification or governing law prose from scratch. Second, validate the extracted functionCall.args payload in your application code—checking that discount percentages, payment net terms, and total contract values fall within authorized policy bounds—before executing the HTTP POST request to Signbee.
How does Signbee certify two-party agreements initiated by a Gemini 2.5 agent?
When your backend executes POST https://signb.ee/api/v1/send using your Bearer API key, Signbee records Party A (the sender) as electronically executed with verified account identity, caller IP address, and an ISO 8601 UTC timestamp. Signbee then emails Party B an encrypted signing ceremony URL. Once Party B reviews the rendered PDF and signs on mobile or desktop, Signbee calculates the SHA-256 cryptographic hash of the document bytes and appends an A4 Certificate of Completion.
Turn Multimodal Gemini 2.5 Workflows into Signed Contracts
Connect your @google/genai TypeScript or Python agents to Signbee in minutes. Extract terms from audio or PDFs and dispatch SHA-256 certified agreements in a single POST request.