---
title: Provider Adapters
description: Drop-in adapters that wire CodeSpar sessions into your existing agent framework — Claude, OpenAI, Vercel AI SDK, LangChain, Mastra, and 6 more.
---

import { Callout } from "fumadocs-ui/components/callout";

# Provider Adapters

<VersionBadge pkg="@codespar/sdk" />

CodeSpar ships a published adapter for every agent framework we've seen in production. Each one wires a CodeSpar `Session` into that framework's native tool-calling loop so you keep the framework's architecture, streaming, and state management — CodeSpar only adds the commerce tools.

```typescript
// Two lines, any framework
const session = await codespar.create("user_123", { preset: "brazilian" });
const tools = adapter.tools(session);
```

---

## LLM SDKs

<NextStepsGrid items={[
  { label: "ADAPTER", title: "Anthropic Claude", description: "Wire sessions into the Claude Messages API tool-use loop. Recommended starting point.", href: "/docs/providers/claude" },
  { label: "ADAPTER", title: "OpenAI", description: "Drop-in tool definitions for the OpenAI Responses API or Chat Completions.", href: "/docs/providers/openai" },
  { label: "ADAPTER", title: "Google Gen AI", description: "Use CodeSpar tools with Gemini 2.5 Pro and the Google AI SDK.", href: "/docs/providers/google-genai" },
]} />

## Agent frameworks

<NextStepsGrid items={[
  { label: "ADAPTER", title: "Vercel AI SDK", description: "useChat, streamText, and generateText with CodeSpar tools attached.", href: "/docs/providers/vercel" },
  { label: "ADAPTER", title: "LangChain", description: "LangChain Tool objects that plug into AgentExecutor and LangGraph.", href: "/docs/providers/langchain" },
  { label: "ADAPTER", title: "Mastra", description: "Mastra agent + workflow tools for the CodeSpar session.", href: "/docs/providers/mastra" },
  { label: "ADAPTER", title: "LlamaIndex", description: "LlamaIndex Tool shape for agent and chat engine integrations.", href: "/docs/providers/llama-index" },
]} />

## Multi-agent frameworks

<NextStepsGrid items={[
  { label: "ADAPTER", title: "CrewAI", description: "CodeSpar tools available to every Agent in a CrewAI crew.", href: "/docs/providers/crewai" },
  { label: "ADAPTER", title: "AutoGen", description: "Microsoft AutoGen v0.4 tool interface for multi-agent conversations.", href: "/docs/providers/autogen" },
  { label: "ADAPTER", title: "Letta (MemGPT)", description: "Letta agent tools with stateful, self-editing memory.", href: "/docs/providers/letta" },
  { label: "ADAPTER", title: "CAMEL-AI", description: "CAMEL toolkit integration for role-playing agent workflows.", href: "/docs/providers/camel" },
]} />

## Protocol

<NextStepsGrid items={[
  { label: "PROTOCOL", title: "Model Context Protocol", description: "Consume CodeSpar tools from any MCP-compatible client (Claude Desktop, Cursor, Continue, custom).", href: "/docs/providers/mcp" },
]} />

---

## What the adapters do

Every adapter does the same three things, translated into the framework's native shape:

1. **Tool discovery.** `adapter.tools(session)` returns the session's tools (meta-tools + any server-specific tools) in the shape the framework expects — `Tool[]` for Claude, `{ name: fn }` for LangChain, `ZodSchema`-backed for Vercel, etc.
2. **Tool execution.** When the framework calls a tool, the adapter routes the call through `session.execute()`. Billing, audit, and multi-tenant isolation happen in the CodeSpar API — the adapter is a thin wrapper.
3. **Error mapping.** CodeSpar's typed errors (`needs_connection`, `insufficient_scope`, `provider_rate_limited`) are mapped to whatever the framework expects so retries and fallbacks keep working.

<Callout type="info">
The adapters are **optional**. If your framework isn't listed, you can use `session.execute()` directly — see [Build Your Own Adapter](/docs/build-your-own).
</Callout>

## Picking an adapter

Most teams pick based on what they already have.

| You have | Use |
|----------|-----|
| An existing Claude app | [Claude adapter](/docs/providers/claude) |
| An existing OpenAI app | [OpenAI adapter](/docs/providers/openai) |
| A Vercel AI SDK frontend | [Vercel adapter](/docs/providers/vercel) |
| Python + LangChain | [LangChain adapter](/docs/providers/langchain) |
| A multi-agent crew | [CrewAI](/docs/providers/crewai) / [AutoGen](/docs/providers/autogen) |
| Claude Desktop / Cursor / Continue | [MCP](/docs/providers/mcp) |
| Starting fresh | [Claude adapter](/docs/providers/claude) or [Vercel adapter](/docs/providers/vercel) |

## Next steps

<NextStepsGrid items={[
  { label: "QUICKSTART", title: "5-minute quickstart", description: "Ship your first commerce agent with the Claude adapter.", href: "/docs/quickstart" },
  { label: "CONCEPT", title: "Sessions", description: "The primitive every adapter wraps — lifecycle, tools, execute, send.", href: "/docs/concepts/sessions" },
  { label: "GUIDE", title: "Build your own adapter", description: "For frameworks we don't ship adapters for yet.", href: "/docs/build-your-own" },
  { label: "COOKBOOK", title: "Pix Payment Agent", description: "End-to-end example wiring an adapter into a real commerce flow.", href: "/docs/cookbooks/pix-payment-agent" },
]} />
