back
loading skill details...
Add an AI agent / RAG backend (@convex-dev/agent) to the Convex app.
Add an AI agent / RAG backend
Install @convex-dev/agent for durable threads, message history, tool-calls, and vector search/RAG — the backend for an in-app AI agent. Call models through the Convex AI Gateway by default: Convex holds the provider credentials, so there is no LLM key to obtain, store, or rotate.
Workflow
Install @convex-dev/agent + @convex-dev/ai-sdk-provider; add the agent component to convex.config.ts.
Define the agent (tools, instructions) with languageModel: convexGateway("provider/model") — no API key needed (needs convex 1.45+ on a Convex Cloud deployment, paid plan).
Create threads + stream messages; persist history in Convex.
For RAG: embed docs into a vector index and retrieve in the tool. The gateway does not serve embeddings yet, so store the embedding provider's key via the env micro power.
Only if the gateway is unavailable (free plan, self-hosted, local backend): call the provider SDK with a key stored via the env micro power.
Rulesdon't have the plugin yet? install it then click "run inline in claude" again.