copy markdown
You might already have a complex agent workflow built but need to increase the accuracy for tasks. Sometimes it's better document extraction for more visibility to your agent, or higher quality web data extracted for clearer context.
You can easily wire Interfaze as a tool inside your existing agent pipeline without changing your existing workflow.
Run-task mode lets you run specific parts of the model without running the full model. The output is raw structured JSON, no prose, no wrappers, just the data your agent needs for better context leading to better accuracy.
You already have a complex agent workflow. Adding OCR, live web data, or audio transcription as tool calls is the cleanest path.
High reasoning continuous loop tasks. Tasks that can run for a long time and would need higher quality context at different stages of the task on different documents, websites, etc.
Add a <task> tag to the system prompt and set the response format to an empty schema. Interfaze activates only a small part of the full model and runs only the requested capability.
Learn more about run-task mode.
<task>web_search</task>The output always follows this shape:
{
"name": "web_search",
"result": { ... }
}The result schema is task-specific and consistent on every run. Pass it back as tool output and your agent's context is immediately enriched.
Available tasks:
| Task | What it does |
|---|---|
ocr | Extract text and structured data from images or documents |
object_detection | Detect and locate objects in images |
web_search | Real-time web search with sources |
scraper | Extract structured content from any web page |
speech_to_text | Transcribe audio files with timestamps |
translate | Translate text between languages |
All examples below include this client initialization in each tab.
OpenAI SDK
Vercel AI SDK
LangChain SDK
import OpenAI from "openai";
const interfaze = new OpenAI({
apiKey: process.env.INTERFAZE_API_KEY,
baseURL: "https://api.interfaze.ai/v1",
});Register Interfaze OCR as a tool in your agent. When the model encounters a PDF or document URL, it calls the tool and gets back clean structured text to reason over.
OpenAI SDK
Vercel AI SDK
LangChain SDK
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { z } from "zod";
const interfaze = new OpenAI({
apiKey: process.env.INTERFAZE_API_KEY,
baseURL: "https://api.interfaze.ai/v1",
});
const model = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function runInterfazeTask(task: string, prompt: string) {
const res = await interfaze.chat.completions.create({
model: "interfaze-beta",
messages: [
{ role: "system", content: `<task>${task}</task>` },
{ role: "user", content: prompt },
],
response_format: zodResponseFormat(z.any(), "empty_schema"),
});
return JSON.parse(res.choices[0].message.content!).result;
}
const ocrTool = {
type: "function" as const,
function: {
name: "ocr",
description: "Extract text and structured data from images or documents.",
parameters: {
type: "object",
properties: {
url: { type: "string", description: "URL of the image or document." },
},
required: ["url"],
},
},
};
const messages: OpenAI.ChatCompletionMessageParam[] = [
{
role: "user",
content: "Extract the title, authors, abstract, and key findings from this research paper: https://arxiv.org/pdf/2602.04101",
},
];
const res = await model.chat.completions.create({
model: "gpt-5.4",
messages,
tools: [ocrTool],
tool_choice: "auto",
});
messages.push(res.choices[0].message);
for (const call of res.choices[0].message.tool_calls ?? []) {
const { url } = JSON.parse(call.function.arguments);
const result = await runInterfazeTask("ocr", `Extract the title, authors, abstract, and key findings from: ${url}`);
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result) });
}
const final = await model.chat.completions.create({ model: "gpt-5.4", messages });
console.log(final.choices[0].message.content);Give your coding agent a web search tool backed by Interfaze. It looks up live docs, searches existing bug reports, and pulls changelogs before writing code, so it never hallucinates a deprecated API.
OpenAI SDK
Vercel AI SDK
LangChain SDK
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { z } from "zod";
const interfaze = new OpenAI({
apiKey: process.env.INTERFAZE_API_KEY,
baseURL: "https://api.interfaze.ai/v1",
});
const model = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function runInterfazeTask(task: string, prompt: string) {
const res = await interfaze.chat.completions.create({
model: "interfaze-beta",
messages: [
{ role: "system", content: `<task>${task}</task>` },
{ role: "user", content: prompt },
],
response_format: zodResponseFormat(z.any(), "empty_schema"),
});
return JSON.parse(res.choices[0].message.content!).result;
}
const webSearchTool = {
type: "function" as const,
function: {
name: "web_search",
description: "Search the web for real-time information, documentation, or bug reports.",
parameters: {
type: "object",
properties: {
query: { type: "string", description: "The search query." },
},
required: ["query"],
},
},
};
const messages: OpenAI.ChatCompletionMessageParam[] = [
{
role: "system",
content: "You are a coding assistant. Always search for the latest docs before writing code.",
},
{
role: "user",
content: "Write a React hook for infinite scroll using TanStack Query v5.",
},
];
const res = await model.chat.completions.create({
model: "gpt-5.4",
messages,
tools: [webSearchTool],
tool_choice: "auto",
});
messages.push(res.choices[0].message);
for (const call of res.choices[0].message.tool_calls ?? []) {
const { query } = JSON.parse(call.function.arguments);
const result = await runInterfazeTask("web_search", query);
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result) });
}
const final = await model.chat.completions.create({ model: "gpt-5.4", messages });
console.log(final.choices[0].message.content);Wire the Interfaze scraper as a tool for your research agent. The model calls it when it needs content from a URL and gets back clean structured data to work with.
OpenAI SDK
Vercel AI SDK
LangChain SDK
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { z } from "zod";
const interfaze = new OpenAI({
apiKey: process.env.INTERFAZE_API_KEY,
baseURL: "https://api.interfaze.ai/v1",
});
const model = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function runInterfazeTask(task: string, prompt: string) {
const res = await interfaze.chat.completions.create({
model: "interfaze-beta",
messages: [
{ role: "system", content: `<task>${task}</task>` },
{ role: "user", content: prompt },
],
response_format: zodResponseFormat(z.any(), "empty_schema"),
});
return JSON.parse(res.choices[0].message.content!).result;
}
const scraperTool = {
type: "function" as const,
function: {
name: "scraper",
description: "Extract structured content from any public web page.",
parameters: {
type: "object",
properties: {
url: { type: "string", description: "URL of the page to scrape." },
instruction: { type: "string", description: "What to extract from the page." },
},
required: ["url"],
},
},
};
const messages: OpenAI.ChatCompletionMessageParam[] = [
{
role: "user",
content: "Summarize the key features and capabilities on https://interfaze.ai",
},
];
const res = await model.chat.completions.create({
model: "gpt-5.4",
messages,
tools: [scraperTool],
tool_choice: "auto",
});
messages.push(res.choices[0].message);
for (const call of res.choices[0].message.tool_calls ?? []) {
const { url, instruction } = JSON.parse(call.function.arguments);
const result = await runInterfazeTask(
"scraper",
`${instruction ?? "Extract the main content from"} ${url}`
);
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result) });
}
const final = await model.chat.completions.create({ model: "gpt-5.4", messages });
console.log(final.choices[0].message.content);Register speech-to-text as a tool. The model transcribes a full recording in seconds and immediately summarizes it, turning a 60-minute call into a clean summary and action item list without any manual steps.
OpenAI SDK
Vercel AI SDK
LangChain SDK
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { z } from "zod";
const interfaze = new OpenAI({
apiKey: process.env.INTERFAZE_API_KEY,
baseURL: "https://api.interfaze.ai/v1",
});
const model = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function runInterfazeTask(task: string, prompt: string) {
const res = await interfaze.chat.completions.create({
model: "interfaze-beta",
messages: [
{ role: "system", content: `<task>${task}</task>` },
{ role: "user", content: prompt },
],
response_format: zodResponseFormat(z.any(), "empty_schema"),
});
return JSON.parse(res.choices[0].message.content!).result;
}
const sttTool = {
type: "function" as const,
function: {
name: "speech_to_text",
description: "Transcribe an audio file to text.",
parameters: {
type: "object",
properties: {
audio_url: { type: "string", description: "URL of the audio file." },
},
required: ["audio_url"],
},
},
};
const messages: OpenAI.ChatCompletionMessageParam[] = [
{
role: "user",
content:
"Summarize this call and list any follow-up items: https://r2public.jigsawstack.com/interfaze/examples/stt_call.mp3",
},
];
const res = await model.chat.completions.create({
model: "gpt-5.4",
messages,
tools: [sttTool],
tool_choice: "auto",
});
messages.push(res.choices[0].message);
for (const call of res.choices[0].message.tool_calls ?? []) {
const { audio_url } = JSON.parse(call.function.arguments);
const result = await runInterfazeTask("speech_to_text", `Transcribe this audio: ${audio_url}`);
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result) });
}
const final = await model.chat.completions.create({ model: "gpt-5.4", messages });
console.log(final.choices[0].message.content);Register translate as a tool. The model calls it when it needs to understand foreign-language content, then analyzes or summarizes without a second round-trip.
OpenAI SDK
Vercel AI SDK
LangChain SDK
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { z } from "zod";
const interfaze = new OpenAI({
apiKey: process.env.INTERFAZE_API_KEY,
baseURL: "https://api.interfaze.ai/v1",
});
const model = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function runInterfazeTask(task: string, prompt: string) {
const res = await interfaze.chat.completions.create({
model: "interfaze-beta",
messages: [
{ role: "system", content: `<task>${task}</task>` },
{ role: "user", content: prompt },
],
response_format: zodResponseFormat(z.any(), "empty_schema"),
});
return JSON.parse(res.choices[0].message.content!).result;
}
const translateTool = {
type: "function" as const,
function: {
name: "translate",
description: "Translate text between languages.",
parameters: {
type: "object",
properties: {
text: { type: "string", description: "Text to translate." },
target_language: { type: "string", description: "Target language." },
},
required: ["text", "target_language"],
},
},
};
const messages: OpenAI.ChatCompletionMessageParam[] = [
{
role: "user",
content: "Summarize the key findings from this French research abstract: \"Les modèles de langage de grande taille ont transformé le traitement automatique du langage naturel. Cependant, leur coût computationnel reste un obstacle majeur à leur déploiement à grande échelle. Cette étude propose une nouvelle approche de distillation qui réduit la taille du modèle de 80% tout en conservant 95% des performances sur les benchmarks standards.\"",
},
];
const res = await model.chat.completions.create({
model: "gpt-5.4",
messages,
tools: [translateTool],
tool_choice: "auto",
});
messages.push(res.choices[0].message);
for (const call of res.choices[0].message.tool_calls ?? []) {
const { text, target_language } = JSON.parse(call.function.arguments);
const result = await runInterfazeTask("translate", `Translate to ${target_language}: ${text}`);
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result) });
}
const final = await model.chat.completions.create({ model: "gpt-5.4", messages });
console.log(final.choices[0].message.content);Copy this into your existing agent. The executor function handles all the wiring: one implementation, six tools.
OpenAI SDK
Vercel AI SDK
LangChain SDK
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { z } from "zod";
const interfaze = new OpenAI({
apiKey: process.env.INTERFAZE_API_KEY,
baseURL: "https://api.interfaze.ai/v1",
});
export const interfazeToolDefinitions = [
{
type: "function" as const,
function: {
name: "ocr",
description: "Extract text and structured data from images or documents.",
parameters: {
type: "object",
properties: {
url: { type: "string", description: "URL of the image or document." },
},
required: ["url"],
},
},
},
{
type: "function" as const,
function: {
name: "web_search",
description: "Search the web for real-time information, news, or documentation.",
parameters: {
type: "object",
properties: {
query: { type: "string", description: "The search query." },
},
required: ["query"],
},
},
},
{
type: "function" as const,
function: {
name: "scraper",
description: "Extract structured content from any public web page.",
parameters: {
type: "object",
properties: {
url: { type: "string", description: "URL to scrape." },
instruction: { type: "string", description: "What to extract." },
},
required: ["url"],
},
},
},
{
type: "function" as const,
function: {
name: "speech_to_text",
description: "Transcribe audio files to text with timestamps.",
parameters: {
type: "object",
properties: {
audio_url: { type: "string", description: "URL of the audio file." },
},
required: ["audio_url"],
},
},
},
{
type: "function" as const,
function: {
name: "object_detection",
description: "Detect and locate objects in images, returning bounding boxes and labels.",
parameters: {
type: "object",
properties: {
image_url: { type: "string", description: "URL of the image." },
prompt: { type: "string", description: "Description of what objects to detect." },
},
required: ["image_url"],
},
},
},
{
type: "function" as const,
function: {
name: "translate",
description: "Translate text between languages.",
parameters: {
type: "object",
properties: {
text: { type: "string", description: "Text to translate." },
target_language: { type: "string", description: "Target language." },
},
required: ["text", "target_language"],
},
},
},
];
export async function executeInterfazeTool(
toolName: string,
args: Record<string, string>
): Promise<unknown> {
const promptMap: Record<string, string> = {
ocr: `Extract the title, authors, abstract, and key findings from: ${args.url}`,
web_search: args.query,
scraper: `${args.instruction ?? "Extract the main content from"} ${args.url}`,
speech_to_text: `Transcribe this audio: ${args.audio_url}`,
object_detection: `${args.prompt ?? "Detect all objects in"} this image: ${args.image_url}`,
translate: `Translate to ${args.target_language}: ${args.text}`,
};
const res = await interfaze.chat.completions.create({
model: "interfaze-beta",
messages: [
{ role: "system", content: `<task>${toolName}</task>` },
{ role: "user", content: promptMap[toolName] },
],
response_format: zodResponseFormat(z.any(), "empty_schema"),
});
return JSON.parse(res.choices[0].message.content!).result;
}
// Agent loop
const mainModel = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function runAgent(userMessage: string) {
const messages: OpenAI.ChatCompletionMessageParam[] = [
{ role: "user", content: userMessage },
];
while (true) {
const response = await mainModel.chat.completions.create({
model: "gpt-5.4",
messages,
tools: interfazeToolDefinitions,
tool_choice: "auto",
});
const choice = response.choices[0];
if (choice.finish_reason === "stop") {
return choice.message.content;
}
messages.push(choice.message);
for (const call of choice.message.tool_calls ?? []) {
const args = JSON.parse(call.function.arguments);
const result = await executeInterfazeTool(call.function.name, args);
messages.push({
role: "tool",
tool_call_id: call.id,
content: JSON.stringify(result),
});
}
}
}
const result = await runAgent(
"Find the latest changelog for Zod v4 and summarize what changed."
);
console.log(result);Adding high quality context can solve 80% of your agent's accuracy problems from extracting the document in the right format or speeding up your agent workflow by delegating compute intensive tasks to Interfaze.
For that last 20%, adding Interfaze directly into your agent pipeline using any of the major SDKs and AI frameworks will push accuracy into the 99% range and speed up your workflow by offloading compute-intensive tasks from your main model.