AI Connect/Integration/Framework adapters

Framework adapters

Ask AI about Vinkius

Zero-dependency subpath exports that convert user-scoped capabilities into the tool format of OpenAI, Anthropic, Gemini, the Vercel AI SDK, LangChain, LlamaIndex, Cloudflare Workers AI, or any OpenAI-compatible runtime.

Adapters are zero-dependency subpath exports that convert capabilities into your framework's tool format (each framework's own term). Where a framework needs one of its own factories, you inject it: no peer dependency, no version coupling.

Load the capability set once, convert at the model boundary, and keep the original CapabilitySet for dispatch:

typescript
const capabilities = await vinkius.user('alice_123').capabilities();
FrameworkImportNotes
OpenAI (chat completions)@vinkius/connect/openaitoOpenAITools, runOpenAIToolCall
OpenAI Agents (@openai/agents)@vinkius/connect/openai-agentstoOpenAIAgentsTools (inject tool)
Anthropic (Messages)@vinkius/connect/anthropictoAnthropicTools, runAnthropicToolUse
Google Gemini@vinkius/connect/geminitoGeminiTools, runGeminiFunctionCall
Vercel AI SDK@vinkius/connect/ai-sdktoAISDKTools (inject jsonSchema)
LangChain.js@vinkius/connect/langchaintoLangChainTools (inject tool)
LlamaIndex.TS@vinkius/connect/llamaindextoLlamaIndexTools (inject tool)
Cloudflare Workers AI@vinkius/connect/workers-aitoWorkersAITools (for runWithTools)
Any / neutral@vinkius/connect/json-schematoJSONSchemaTools, executeByName

OpenAI (chat completions)

typescript
import OpenAI from 'openai';
import { toOpenAITools, runOpenAIToolCall } from '@vinkius/connect/openai';

const capabilities = await vinkius.user('alice_123').capabilities();

const completion = await openai.chat.completions.create({
  model: 'your-model',
  messages: [{ role: 'user', content: 'Open a GitHub issue titled "Ship it"' }],
  tools: toOpenAITools(capabilities),
});

const call = completion.choices[0]?.message.tool_calls?.[0];
if (call) {
  const result = await runOpenAIToolCall(capabilities, call);
  console.log(result.content);
}

OpenAI Agents (@openai/agents)

Distinct from the chat-completions adapter. Inject the Agents SDK's tool factory; the JSON Schema is passed as raw parameters with strict: false.

typescript
import { Agent, tool } from '@openai/agents';
import { toOpenAIAgentsTools } from '@vinkius/connect/openai-agents';

const capabilities = await vinkius.user('alice_123').capabilities();
const agent = new Agent({
  name: 'assistant',
  tools: toOpenAIAgentsTools(capabilities, { tool }),
});

Anthropic (Messages)

typescript
import { toAnthropicTools, runAnthropicToolUse } from '@vinkius/connect/anthropic';

const capabilities = await vinkius.user('alice_123').capabilities();
const tools = toAnthropicTools(capabilities); // pass as `tools` to messages.create
// on a returned tool_use block: await runAnthropicToolUse(capabilities, block)

Google Gemini

Produces function declarations for the unified Google GenAI SDK (@google/genai).

typescript
import { toGeminiTools, runGeminiFunctionCall } from '@vinkius/connect/gemini';

const capabilities = await vinkius.user('alice_123').capabilities();
const response = await model.generateContent({
  contents,
  tools: [{ functionDeclarations: toGeminiTools(capabilities) }],
});

// on a returned functionCall part:
const result = await runGeminiFunctionCall(capabilities, functionCall);

Vercel AI SDK

Pass the AI SDK's own jsonSchema helper so parameters are wrapped correctly. Mastra consumes Vercel AI SDK tools natively, so it is covered by this adapter.

typescript
import { jsonSchema } from 'ai';
import { toAISDKTools } from '@vinkius/connect/ai-sdk';

const capabilities = await vinkius.user('alice_123').capabilities();
const tools = toAISDKTools(capabilities, { jsonSchema });

LangChain.js

Inject LangChain's own tool factory so the returned objects are genuine, bindable LangChain tools; the adapter keeps zero dependencies.

typescript
import { tool } from '@langchain/core/tools';
import { toLangChainTools } from '@vinkius/connect/langchain';

const capabilities = await vinkius.user('alice_123').capabilities();
const tools = toLangChainTools(capabilities, { tool });
const model = chat.bindTools(tools);

LlamaIndex.TS

Inject LlamaIndex's tool factory. Accepts raw JSON Schema, so no Zod is required.

typescript
import { tool } from 'llamaindex';
import { toLlamaIndexTools } from '@vinkius/connect/llamaindex';

const capabilities = await vinkius.user('alice_123').capabilities();
const tools = toLlamaIndexTools(capabilities, { tool });

Cloudflare Workers AI

toWorkersAITools produces embedded function-calling tools (each with a bound function) for runWithTools from @cloudflare/ai-utils.

typescript
import { runWithTools } from '@cloudflare/ai-utils';
import { toWorkersAITools } from '@vinkius/connect/workers-ai';

const capabilities = await vinkius.user('alice_123').capabilities();
const res = await runWithTools(env.AI, 'your-model', {
  messages,
  tools: toWorkersAITools(capabilities),
});

Neutral and other frameworks

toJSONSchemaTools emits plain { name, description, parameters } definitions: the lowest common denominator for any OpenAI-compatible provider or custom agent loop, with executeByName to dispatch.

A few frameworks are intentionally covered by the adapters above rather than their own subpath:

  • Mastra consumes Vercel AI SDK tools natively; use the ai-sdk adapter.
  • Claude Agent SDK (@anthropic-ai/claude-agent-sdk) requires a Zod schema and in-process MCP registration. Use the Messages API anthropic adapter.
  • CrewAI is a Python framework. Use the neutral JSON Schema output as the bridge until a Vinkius Python SDK exists.

Dispatch caveats

Adapter dispatch helpers call capability.execute(args) without ExecuteOptions: those executions do not carry an idempotency key or caller signal and receive one transport attempt. Unknown names passed to adapter dispatchers throw plain Error, not VinkiusError. When an operation requires cancellation or idempotency, resolve the Capability and call execute() directly. See Error handling.