---
agent:
  instructions: "Use this search API to find Trusteed documentation (pages, blog posts, FAQ, error codes, the agent checkout guide and MCP tools) with keywords, instead of crawling individual pages. Results are returned in Markdown. It does not search store catalogues: for products use POST /api/v1/search."
  endpoint: "https://trusteed.xyz/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---
Source: https://trusteed.xyz/en/for-agents/sdk-quickstarts

[![](/sol46/shield.svg)**Trusteed** Control and evidence for delegated operations](https://trusteed.xyz/en)

[ES](https://trusteed.xyz/es/for-agents/sdk-quickstarts?setlang=es)[EN](https://trusteed.xyz/en/for-agents/sdk-quickstarts?setlang=en)

[Log in](https://trusteed.xyz/en/login)[Audit your store for free↗](https://trusteed.xyz/en/audit)

SDK Quickstarts

# Connect your AI agent to Trusteed

Copy-ready examples for the 3 most popular AI SDKs. Each example includes trust score verification.

[OpenAI Agents SDK](https://trusteed.xyz/en/for-agents/sdk-quickstarts#openai)[Claude Agent SDK](https://trusteed.xyz/en/for-agents/sdk-quickstarts#claude)[Vercel AI SDK](https://trusteed.xyz/en/for-agents/sdk-quickstarts#vercel)

OpenAI Agents SDK 

## OpenAI Agents SDK: Python

Install `pip install openai-agents`

Tested version: openai-agents ≥ 0.14.0

Python Shopping agent with trust verification

```python
import asyncio
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="trusteed",
        params={
            "url": "https://trusteed.xyz/demo-store/mcp/discovery",
            "headers": {"X-Agent-Api-Key": "agnt_your_key"},
            "timeout": 30,
        },
        cache_tools_list=True,
    ) as mcp:
        agent = Agent(
            name="shopping-agent",
            instructions="""
            You are a shopping assistant for Trusteed.
            IMPORTANT: Before any checkout, always call get_merchant_profile
            and verify the merchant's trust level. If it is below your acceptable
            threshold, stop and inform the user.
            Methodology: GET /api/v1/trust/methodology
            """,
        )

        result = await Runner.run_async(
            agent,
            "Search for laptops under $1500, verify merchant trust, and create a cart."
        )
        print(result.final_output)

asyncio.run(main())
```

i 

The agent receives trust\_score in the get\_merchant\_profile response. With the system prompt instructions, the model automatically verifies the threshold before calling create\_cart.

Claude Agent SDK 

## Claude Agent SDK: TypeScript

Install `npm install @anthropic-ai/claude-agent-sdk`

Tested version: @anthropic-ai/claude-agent-sdk ≥ 0.2.0

Note: SDK is under active development. Review the CHANGELOG before upgrading minor versions.

TypeScript Agent with allowedTools and trust check

```typescript
import { query } from "@anthropic-ai/claude-agent-sdk";

// Source: https://code.claude.com/docs/en/agent-sdk/mcp#httpsse-servers

async function main() {
  for await (const message of query({
    prompt: `
      1. Call search_products with query "laptop" limit 5
      2. Call get_merchant_profile to get the merchant's trust level
      3. If the trust level is above your acceptable threshold, call create_cart with the first result
      4. Report the cart_id and trust level
    `,
    options: {
      mcpServers: {
        trusteed: {
          type: "http",
          url: "https://trusteed.xyz/demo-store/mcp/discovery",
          headers: {
            "X-Agent-Api-Key": process.env.TRUSTEED_API_KEY ?? "",
          },
        },
      },
      allowedTools: [
        "mcp__trusteed__search_products",
        "mcp__trusteed__get_merchant_profile",
        "mcp__trusteed__create_cart",
      ],
    },
  })) {
    if (message.type === "result" && message.subtype === "success") {
      process.stdout.write(JSON.stringify(message.result) + "\n");
    }
    if (message.type === "assistant") {
      for (const block of message.message.content) {
        if (block.type === "text") {
          process.stdout.write(block.text);
        }
      }
    }
  }
}

main().catch((err) => process.stderr.write(String(err)));
```

i 

allowedTools restricts which MCP tools the agent can invoke, important for reducing blast radius in production.

Vercel AI SDK 

## Vercel AI SDK: TypeScript

Install `npm install ai @ai-sdk/openai`

Tested version: ai ≥ 6.0.0

Note: experimental\_createMCPClient is still in beta. API may change.

TypeScript (Node.js) generateText with MCP client

```typescript
import { experimental_createMCPClient as createMCPClient } from "ai";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

async function main() {
  const mcpClient = await createMCPClient({
    transport: {
      type: "http",
      url: "https://trusteed.xyz/demo-store/mcp/discovery",
      headers: {
        "X-Agent-Api-Key": process.env.TRUSTEED_API_KEY ?? "",
      },
    },
  });

  const tools = await mcpClient.tools();

  const { text, toolCalls } = await generateText({
    model: openai("gpt-4o"),
    tools,
    maxSteps: 6,
    system: `You are a shopping assistant.
IMPORTANT: Always call get_merchant_profile first and verify the merchant's trust level.
If the merchant's trust level is below your acceptable threshold, do NOT create a cart. Inform the user instead.`,
    prompt: "Find me a laptop under $1500 and start the checkout process.",
  });

  process.stdout.write("Response: " + text + "\n");
  process.stdout.write("Tool calls: " + toolCalls.length + "\n");

  await mcpClient.close();
}

main().catch((err) => process.stderr.write(String(err)));
```

TypeScript (Next.js App Router) Streaming in Next.js App Router

```typescript
// app/api/shop/route.ts
import { experimental_createMCPClient as createMCPClient } from "ai";
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";

export async function POST(req: Request) {
  const { message } = await req.json();

  const mcpClient = await createMCPClient({
    transport: {
      type: "http",
      url: `https://trusteed.xyz/${process.env.STORE_SLUG}/mcp/discovery`,
      headers: { "X-Agent-Api-Key": process.env.TRUSTEED_API_KEY ?? "" },
    },
  });

  const tools = await mcpClient.tools();

  const result = streamText({
    model: openai("gpt-4o"),
    tools,
    maxSteps: 8,
    system: "Shopping assistant. Verify the merchant's trust level is above your acceptable threshold before checkout.",
    messages: [{ role: "user", content: message }],
    onFinish: () => mcpClient.close(),
  });

  return result.toDataStreamResponse();
}
```

i 

streamText with onFinish closes the MCP client automatically when the response completes, preventing connection leaks.

## Trust Check Pattern: common to all 3 SDKs

Trust levels your agent must enforce before initiating checkout

| Score | Level | Agent action |
| --- | --- | --- |
| Highest | EXCELLENT | Proceed without friction |
| High | GOOD | Proceed with standard confirmation |
| Eligible | ACCEPTABLE | Minimum eligible for checkout |
| Below threshold | DO NOT PROCEED | Do NOT initiate checkout |

Full methodology: `GET /api/v1/trust/methodology`

Ready to connect? Get your API key in seconds.

[Get API Key](https://trusteed.xyz/en/for-agents/quickstart)
