An @ai-sdk
compatible AI provider implementation for the A2A Protocol, enabling universal interoperability between LLMs, tools, streaming output, and file-based artifacts.
Hint: Is currently in alpha, not feature complete and should not be used for production workloads.
- 🔌 Drop-in
ai
Provider (v5 and later) - 🔁 Full support for A2A JSON-RPC 2.0 API by using
@a2a-js/sdk
- ⚖️ MIT Licensed and easy to integrate
pnpm install a2a-ai-provider
Make sure you also install ai
(v5 which is currently @beta):
pnpm install ai@beta
import { a2a } from "a2a-ai-provider";
import { generateText } from "ai"
const chatId = "unique-chat-id"; // for each conversation to keep history in a2a server
const result = await generateText({
model: a2a('https://your-a2a-server.example.com'),
prompt: 'What is love?',
providerOptions: {
"a2a": {
"contextId": chatId,
}
},
});
console.log(result.text);
or if you like the stream version, use:
import { a2a } from "a2a-ai-provider";
import { streamText } from "ai"
const chatId = "unique-chat-id"; // for each conversation to keep history in a2a server
const streamResult = streamText({
model: a2a('https://your-a2a-server.example.com'),
prompt: 'What is love?',
providerOptions: {
"a2a": {
"contextId": chatId,
}
},
});
await streamResult.consumeStream();
console.log(await streamResult.content);
createA2a({
idGenerator?: IdGenerator; // replace the default IdGenerator
});
a2a-ai-provider is licensed under the terms of MIT. See LICENSE for more information.