Internalize / Docs
Integrations

Vercel AI SDK

Use Internalize with generateText, streamText, and your own tools.

View as Markdown

Use @ai-sdk/openai-compatible to target Chat Completions explicitly. Keep the provider and credentials on your server.

npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const internalize = createOpenAICompatible({
  name: "internalize",
  baseURL: "https://convergingthought.com/v1",
  apiKey: process.env.INTERNALIZE_API_KEY,
});

const result = await generateText({
  model: internalize("glm-5.3"),
  prompt: "Explain test-time training with an example.",
  maxRetries: 0,
});
console.log(result.text);

Use an adapter

Resolve the subject in your authenticated server handler, then include headers: { "X-Internalize-Subject": subject } in generateText or streamText. Headers belong to that request; avoid mutating a shared provider for each customer.

An unseen subject starts from base. After learning activates a version, subsequent requests with the same subject route to it automatically. To compare against base, omit the subject entirely in a separate request.

Tools

The AI SDK converts ordinary function tools into the Chat Completions format. Define inputSchema and an execute handler using the SDK's tool helper. Your application owns the handler and its authorization. Validate tool arguments before using them for external actions.

For internalize, expose only a content argument. Bind the authorized subject in the server closure and store a durable idempotency key for that tool invocation. Do not generate a fresh key on each handler retry. Follow Add learning for activation and long-running job semantics.

Streaming

streamText can parse Internalize's SSE responses. Text and tool arguments are emitted after the complete model response passes validation, so the current stream is buffered. Show a waiting state until the first content arrives. Cancelling your UI stream does not cancel the durable model job.

Supported surface

Use text prompts, text conversation messages, function tools, temperature, and output-token limits. Images, audio, embeddings, Responses-only features, and structured json_schema output are not available. Do not silently fall back to another model when an adapter request fails.

The protocol tests exercise generateText, streamText, and function-call parsing using the installed AI SDK against the same gateway serializers. They use a local transport and do not measure model quality or live provider availability.

See the official compatible-provider guide for provider configuration and the tool guide for application-side execution.

On this page