Interfaze

logo

pricing

help

docs

blog

sign in

Get Started

Introduction

Examples

Vision

Concepts

Resources

Projects

Integrations

API Reference

Vercel AI SDK Integration

copy markdown

Interfaze has a native Vercel AI SDK provider, so you get generateText, streamText, and structured output through Output out of the box, plus Interfaze extras like precontext, reasoning, and the cache flag on providerMetadata.

Installation

These examples use Vercel AI SDK v7 (ai@^7.0.0).

npm / yarn

npm install ai @interfaze-ai/ai-sdk
# or
yarn add ai @interfaze-ai/ai-sdk

Official Documentation

  • Vercel AI SDK Documentation
  • Interfaze provider on npm
  • Vercel Stream

Basic Setup

Import the default interfaze instance to read INTERFAZE_API_KEY from the environment, or build your own with createInterfaze.

Vercel AI SDK

import { createInterfaze, interfaze } from "@interfaze-ai/ai-sdk";

// reads INTERFAZE_API_KEY from the environment
interfaze("interfaze");

// or configure it yourself
const custom = createInterfaze({ apiKey: "<your-api-key>" });

Examples

Text Generation

Vercel AI SDK

import { generateText } from "ai";

const { text } = await generateText({
  model: interfaze("interfaze"),
  prompt: "Write a short story about a robot learning to paint",
});

console.log(text);

Structured Output

Learn more about structured output.

Vercel AI SDK

import { generateText, Output } from "ai";
import { z } from "zod";

const weatherSchema = z.object({
  city: z.string().describe("The name of the city"),
  temperature_celsius: z.number().describe("Current temperature in Celsius"),
  condition: z.string().describe("Weather condition, e.g. sunny, rainy, cloudy"),
});

const { output } = await generateText({
  model: interfaze("interfaze"),
  output: Output.object({ schema: weatherSchema }),
  prompt: "What is the current weather in Tokyo?",
});

console.log(output);

Image / File Input

Vercel AI SDK

import { generateText } from "ai";

const { text } = await generateText({
  model: interfaze("interfaze"),
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "What is in this image?" },
        {
          type: "image",
          image: new URL("https://r2public.jigsawstack.com/interfaze/examples/construction.png"),
        },
      ],
    },
  ],
});

console.log(text);

Streaming

Learn more about streaming.

Vercel AI SDK

import { streamText } from "ai";

const { textStream } = streamText({
  model: interfaze("interfaze"),
  prompt: "Write a short story about a robot learning to paint",
});

for await (const delta of textStream) {
  process.stdout.write(delta);
}

Function Calling

Learn more about function calling.

Vercel AI SDK

import { generateText, tool, stepCountIs } from "ai";
import { z } from "zod";

const { text } = await generateText({
  model: interfaze("interfaze"),
  prompt: "What's the weather like in San Francisco?",
  tools: {
    weather: tool({
      description: "Get the weather in a location",
      inputSchema: z.object({
        location: z.string().describe("The location to get the weather for"),
      }),
      execute: async ({ location }) => ({
        location,
        temperature: 72 + Math.floor(Math.random() * 21) - 10,
      }),
    }),
  },
  stopWhen: stepCountIs(5),
  toolChoice: "auto",
});

console.log(text);

Interfaze metadata

Fields a plain chat provider would drop come back on providerMetadata.interfaze.

Vercel AI SDK

import { generateText } from "ai";

const { text, providerMetadata } = await generateText({
  model: interfaze("interfaze"),
  prompt: "Latest news on Nvidia",
});

console.log(providerMetadata?.interfaze?.vcache); // boolean — cache hit
console.log(providerMetadata?.interfaze?.reasoning); // string | undefined
console.log(providerMetadata?.interfaze?.precontext); // raw task output
  • vcache tells you whether the response came from the cache.
  • reasoning carries the thinking text when reasoning is on.
  • precontext carries the raw output of any task the model ran. Learn more about precontext.

Client options

Router, cache, and streaming behaviour are set once on the provider.

Vercel AI SDK

import { createInterfaze } from "@interfaze-ai/ai-sdk";

const interfaze = createInterfaze({
  apiKey: process.env.INTERFAZE_API_KEY,
  showAdditionalInfo: true, // stream precontext deltas as they're produced
  bypassMoA: true, // skip the mixture-of-agents router
  bypassCache: true, // skip the semantic cache
});

Learn more about bypassing MoA and caching.

Request options

Per-request options go under providerOptions.interfaze.

Vercel AI SDK

import { generateText } from "ai";

const { text, providerMetadata } = await generateText({
  model: interfaze("interfaze"),
  prompt: "Which region should we launch in first, and why?",
  providerOptions: {
    interfaze: {
      reasoningEffort: "high",
      guard: ["S1", "S10", "S12_IMAGE"],
    },
  },
});

console.log(providerMetadata?.interfaze?.reasoning);
console.log(text);

Learn more about reasoning and guardrails.

Errors

Interfaze errors surface as the AI SDK's APICallError, carrying the HTTP status and response body.

Vercel AI SDK

import { APICallError, generateText } from "ai";

try {
  await generateText({
    model: interfaze("interfaze"),
    prompt: "Who is the founder of Interfaze?",
  });
} catch (error) {
  if (APICallError.isInstance(error)) {
    console.log(error.statusCode); // e.g. 400, 401, 429
    console.log(error.responseBody); // raw Interfaze error payload
  }
}

Previous

Interfaze SDK

Next

LangChain SDK

Interfaze

logo

Product

Playground

OCR

Models

Leaderboards

Pricing

OpenWebSearch

DefaultModel