@vida-global/openclaw-ai-sdk-provider
v0.2.0
Published
A custom Vercel AI SDK provider for OpenClaw's /v1/responses API.
Keywords
Readme
@vida-global/openclaw-ai-sdk-provider
Community provider for the Vercel AI SDK that targets OpenClaw’s OpenResponses-compatible /v1/responses gateway.
Install
npm install @vida-global/openclaw-ai-sdk-providerBasic usage
import { generateText } from "ai";
import { createOpenClaw } from "@vida-global/openclaw-ai-sdk-provider";
const openclaw = createOpenClaw({
baseURL: process.env.OPENCLAW_BASE_URL ?? "http://localhost:18789/v1",
apiKey: process.env.OPENCLAW_TOKEN,
});
const model = openclaw("openclaw:main");
const result = await generateText({
model,
prompt: "Hello from OpenClaw!",
});Streaming
import { streamText } from "ai";
import { createOpenClaw } from "@vida-global/openclaw-ai-sdk-provider";
const openclaw = createOpenClaw({ apiKey: process.env.OPENCLAW_TOKEN });
const model = openclaw("openclaw:main");
const { textStream } = await streamText({
model,
prompt: "Summarize the last 3 messages.",
});Provider options
OpenClaw-specific options are passed via providerOptions.openclaw:
{
providerOptions: {
openclaw: {
instructions: "System guidance",
user: "customer:123", // stable session routing
reasoningEffort: "low", // low | medium | high
reasoningSummary: "concise", // auto | concise | detailed
metadata: { source: "demo" },
maxToolCalls: 3,
sessionKey: "agent:main:openai:abc123",
agentId: "main"
}
}
}Environment variables
The provider reads these by default:
OPENCLAW_BASE_URL(default:http://localhost:18789/v1)OPENCLAW_API_KEYorOPENCLAW_TOKEN(bearer token)CLAWDBOT_BASE_URL/CLAWDBOT_TOKEN(legacy aliases)
Tools (function calling)
OpenClaw’s gateway supports OpenResponses function tools. The provider maps AI SDK tools to:
{ "type": "function", "function": { "name", "description", "parameters" } }When the model calls a tool, OpenClaw returns function_call items. To continue the turn, send a follow-up function_call_output with the tool result. The AI SDK handles this for you when using the standard tool-calling flow.
Notes
- OpenClaw uses OpenResponses-style items internally; the provider converts AI SDK prompts to OpenResponses
inputitems. - File and image parts are supported; URLs and base64 payloads are forwarded as
input_file/input_image. sessionKeyandagentIdare forwarded via headersx-openclaw-session-keyandx-openclaw-agent-id.
