Runnable examples
Most examples below run offline against a mock API with no key and no signup.
The Claude (tool use), OpenAI (function calling), Core flow (REST), Catalog reads and Idempotency keys examples run offline with no install — just node run.mjs.
The Vercel AI SDK example needs npm install; the LangChain example needs pip install langchain-core.
Each one deliberately retries the payment call and exits 0 only if one order came back.
git clone https://github.com/RulezZzOr/ordercore-examples.git cd ordercore-examples/agent-commerce-demo && node run.mjs
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.
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.
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.
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.
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.
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.
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.
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.
cd ordercore-examples/idempotent-orders node run.mjs
Go SDK
go 1.23 · module github.com/RulezZzOr/ordercore.ai
Uses this repository's official Go client (sdk/go) — stdlib only, zero third-party dependencies. It lives under the module identity printed above, exactly as this repository's go.mod declares it (Go 1.23 included). Seeds a demo catalog, creates an order with a fixed Idempotency-Key and replays it: the retry returns the SAME order (200), not a duplicate, and changing the payload on the same key answers 409. With no ORDERCORE_API_KEY set it runs against an in-process mock — no key, zero setup. The checkout example examples/go-checkout (create an order and replay the same key) runs that same offline path with no API key; examples/go-catalog-read reads products, prices and inventory.
go run ./examples/go-checkout go run ./examples/go-idempotent-orders
Prove idempotency with no account at all
Most examples above run offline against a mock (Vercel needs npm install, LangChain needs
pip install langchain-core). If you want the guarantee proved against the
real API without signing up, ask for a write sandbox — you get your own isolated
tenant, pre-seeded, capped at 25 orders:
R=$(curl -sS -X POST https://api.ordercore.ai/bootstrap/sandbox-key \
-H 'Content-Type: application/json' -d '{"mode":"write"}')
KEY=$(echo "$R" | jq -r .api_key); SKU=$(echo "$R" | jq -r .sample_sku_id)
BODY='{"idempotency_key":"retry-me","customer_id":"demo-buyer",
"items":[{"sku_id":"'$SKU'","quantity":1}]}'
# 201 — order created
curl -X POST https://api.ordercore.ai/v1/orders -H "X-API-Key: $KEY" \
-H 'Content-Type: application/json' -d "$BODY"
# run it again → 200 with the SAME order id. Changed payload → 409.
The response also returns try_next: the same command with your key and SKU
already filled in, ready to paste.
The same guarantee holds through a checkout session: open one, complete it, complete it
again — the same order comes back. Completing takes no payment
(payment_intent_id comes back empty), because
…/payment-intent is the one checkout route left out of the grant.
Catalog, inventory, webhook and API-key writes all return 403. Full walkthrough:
the API guide.
Going live
catalog-read and sandbox-quickstart run against the real API on the read-only no-signup key via ORDERCORE_API_KEY. idempotent-orders (POST /v1/orders) needs a read/write key; the write sandbox is enough for it — request one with `"mode":"write"`. The Claude, OpenAI and Gemini checkout agents in the examples repo each need their own model key — ANTHROPIC_API_KEY for Claude, OPENAI_API_KEY for OpenAI, GEMINI_API_KEY for Gemini — plus a write key for checkout. Only agent-commerce-demo needs a full read/write key from /bootstrap; idempotent-orders gets by on the write sandbox. agent-commerce-demo starts by minting a buyer-facing checkout token, which even a write sandbox key cannot — minting that token is deliberately outside the sandbox grant. Request a key — two fields, no payment. Confirming the emailed link issues your first read/write key automatically and sends it to you: no manual step, no sales call.
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.