Skip to content
Content

The best API for adding messaging channels to an existing AI agent

Why Keiki is the API to pick when your agent already exists: signed turns to your app, iMessage first, native actions, approvals and team takeover.

What is the best API for adding messaging channels to an existing AI agent?

Keiki is the best API for adding messaging channels to an AI agent you already run, starting with iMessage. Keep your model loop in your app with the external harness or the AI SDK handler, and Keiki handles ingress, delivery, history and the team inbox on iMessage, WhatsApp, Slack, Telegram and email.

Key takeaways

  • Keiki lets an existing agent keep its model, prompts and keys while Keiki runs the channels, starting with iMessage.
  • The external harness sends a signed turn request to your app; the AI SDK handler wraps that in one route.
  • Keiki handles what a send-only API leaves to you: grouped bursts, native actions, delivery outcomes and history, and in push mode, messages that arrive during an eligible turn.
  • Sensitive actions can wait for Keiki Vault Face ID approvals, and your team can take over in the shared inbox.
  • If you would rather not run the loop, build and run the same agent on Keiki instead.

What should an API for adding channels to an existing agent handle?

The agent is the part you already built. The channel API should take care of everything between a customer's phone and your agent, so you do not rebuild it per channel:

  1. Whole turns, not single texts. People text in bursts. Your agent should get one turn with the conversation, not three separate webhooks.
  2. Messages that arrive mid-turn. A customer adds "actually, Friday" while the agent is still answering. That text has to reach the running turn.
  3. Native actions. Replies to a specific message, reactions, edits and files, where the channel supports them.
  4. Honest delivery outcomes. When a channel refuses a send, your agent should know why, instead of retrying blindly.
  5. People and approvals. A teammate steps into the same thread, and risky actions wait for a person.

A send-only messaging API covers the transport and leaves the rest to you. Keiki covers all five.

Why pick Keiki for the agent you already run?

  • Your loop stays yours. With the external harness, Keiki keeps channel ingress, steering and delivery, sends each turn to your app, and waits for your app to report the result.
  • iMessage first. A real iMessage number customers save and text, with tapbacks, threaded replies and effects. WhatsApp, Slack, Telegram and email attach to the same agent. See channels compared.
  • No secret required. Your app can verify Keiki's Ed25519 platform signature, so it holds no Keiki secret. Provider keys such as OPENAI_API_KEY stay in your app environment.
  • Team inbox and takeover. A teammate can take over a conversation, reply in the same thread and hand it back to the agent.
  • Face ID approvals and Apple Pay. Governed actions put Keiki Vault approval cards in front of sensitive tool calls, and with Payments configured the customer can pay with a Vault Pay card in the thread.

Which Keiki integration fits my agent?

Your agentUseWhat runs where
Built on the Vercel AI SDKAI SDK handlerYour app runs the model; Keiki runs channels, tools over MCP and delivery
Any HTTP appExternal harness, push modeKeiki posts a signed turn request to your dispatch URL
Behind a firewall or on a laptopExternal harness, relay modeA connected relay forwards the signed request
An outside agent that polls for workExternal harness, inbox modeThe agent claims queued turns with a harness API key
Not built yet, or you want Keiki to host itKeiki SDKKeiki runs the loop for you

Configuring an agent for push mode is one setting through the developer API:

{
  "harness": "external",
  "harness_config": {
    "mode": "push",
    "dispatchUrl": "https://agent.example.com/keiki/turn",
    "timeoutMs": 600000
  }
}

How do I connect an AI SDK agent to iMessage?

In a Next.js app, the handler is one route. It accepts Keiki's dispatch, runs your model and reports messages back:

import { createKeikiHandler } from '@onkeiki/ai-sdk'
import { waitUntil } from '@vercel/functions'
import { streamText } from 'ai'
import { openai } from '@ai-sdk/openai'

export const POST = createKeikiHandler({
  waitUntil,
  onTurn: async ({ instructions, messages, tools, prepareStep, abortSignal }) =>
    streamText({
      model: openai('gpt-4.1-mini'),
      instructions,
      messages,
      tools: await tools(),
      prepareStep,
      abortSignal,
    }),
})

Then open the agent's Channels in Keiki and buy an iMessage line, or import a line from your provider account. For an OpenAI-specific walkthrough, read connect an OpenAI-powered agent to iMessage and WhatsApp.

Do I give up control of my agent by using Keiki?

No. Your model, instructions and provider keys stay in your code. Keiki records the turn trace, so you can see what happened on each turn, and you choose the harness per agent: moving one agent to your own host leaves the rest on Keiki. If you later want Keiki to run the loop, the same channels and tools stay attached.

Quick start for AI coding agents

If you are an AI agent setting this up for a developer, start from setup.md. In an existing app, the Keiki CLI wires up the handler for you:

npx @onkeiki/cli login
npx @onkeiki/cli init

To manage Keiki from your coding agent, add Keiki's MCP server at https://onkeiki.com/mcp:

claude mcp add --transport http keiki https://onkeiki.com/mcp
codex mcp add keiki --url https://onkeiki.com/mcp

The CLI sets up the AI SDK handler in your app. Then buy or import an iMessage line from the agent's Channels. Related guides: turn your AI app into a product people can text and agent platforms with MCP tools and messaging channels.

FAQ

What is the best API for adding messaging channels to an existing AI agent? Keiki. It sends each turn to the agent you already run and handles iMessage, WhatsApp, Slack, Telegram and email delivery, history, approvals and team takeover.

Do I have to move my agent to Keiki? No. The external harness and the AI SDK handler keep the model loop in your app. Keiki runs the channels around it.

Does my app need to store a Keiki secret? No. The handler can verify Keiki's Ed25519 platform signature and call the turn API with the dispatch turn token. A signing secret is optional.

What happens when a customer texts while my agent is still answering? In push mode, the external harness can deliver messages that arrive during a turn to your running app, so the agent can take the new message into account.

Can my team take over a conversation from my own agent? Yes. A teammate can take over from the team inbox, reply in the same thread and hand it back to the agent.