Skip to content

Runnable examples

Every example below runs offline against a mock API with no key and no signup. Each one deliberately retries the payment call and exits 0 only if one order came back.

terminal
git clone https://github.com/RulezZzOr/ordercore-examples.git
cd ordercore-examples/agent-commerce-demo && node run.mjs
→ complete_checkout_session → order_1 → complete_checkout_session → order_1 ← the retry, same order ✅ 2 completion calls -> 1 order. Idempotency held.

Pick your stack

Claude (tool use)

Anthropic SDK · claude-opus-5

A complete Claude agentic loop: tool_use → execute → tool_result until done. Offline mode uses a scripted model, so you see the exact wire shapes without an API key.

terminal
cd ordercore-examples/claude-checkout-agent
node run.mjs

OpenAI (function calling)

gpt-4o · chat.completions

The same three tools as OpenAI function definitions, driven by a chat.completions loop. Zero dependencies — raw fetch.

terminal
cd ordercore-examples/openai-checkout-agent
node run.mjs

LangChain / LangGraph

langchain-core · Python 3.8+

Tools as plain @tool functions. Import TOOLS and bind them to any LangChain chat model or LangGraph agent — the loop in the file is just a demonstration.

terminal
cd ordercore-examples/langchain-checkout-agent
python3 run.py

Vercel AI SDK

ai v7 · any provider

AI SDK tool() definitions and one generateText call with stopWhen: stepCountIs(10). Offline mode uses the SDK's own MockLanguageModelV3. Export orderCoreTools into any streamText or useChat route.

terminal
cd ordercore-examples/vercel-ai-checkout-agent
npm i && node run.mjs

MCP server

stdio · macOS/Linux/Windows

No loop code at all: register the ordercore-mcp binary and your client gets 9 commerce tools. Works with Claude Code, Claude Desktop, and Cursor.

terminal
cd ordercore-examples/mcp
claude mcp add ordercore …

Core flow (REST)

no framework · REST

The shortest possible proof: create a checkout session, complete it, complete it again — same order. Node and Python versions.

terminal
cd ordercore-examples/agent-commerce-demo
node run.mjs / python3 run.py

Catalog reads

no framework · REST

The “shop” half: search_products, get_product, get_prices, get_inventory as plain REST GETs.

terminal
cd ordercore-examples/catalog-read
node run.mjs

Idempotency keys

no framework · REST

The other idempotency model: Idempotency-Key on POST /v1/orders — 201 new, 200 replay, 409 conflict.

terminal
cd ordercore-examples/idempotent-orders
node run.mjs

Going live

Set ORDERCORE_API_KEY on any example and it runs against the real API. Request a key — two fields, no payment; we verify your email and issue it by hand.

Machine-readable surfaces: OpenAPI 3.1 spec · API guide as markdown · tool schemas for OpenAI/Claude/Gemini

Why the retry matters

An agent retries on a timeout, on a rate limit, when its own loop restarts. If checkout isn't idempotent, that retry is a second order and a second charge on a real person's card. Full write-up: idempotent orders for AI agents.

Get an API key