Scaffold a prediction market agent project in seconds. Picks the right
SimpleFunctions wrapper package for your stack — LangChain, OpenAI Agents SDK,
or vanilla TypeScript — and generates a working agent.ts you can npm start
right away.
npx create-prediction-market-agent my-agent
# or non-interactively
npx create-prediction-market-agent my-agent --framework langchainGenerates a project directory with:
package.json— pinned to the right wrapper packagesrc/agent.ts— a runnable starter agenttsconfig.json— strict-mode ES2022.env.example— for yourOPENAI_API_KEYREADME.md— short usage doc
--framework |
What you get |
|---|---|
vanilla (default) |
Pure TypeScript using prediction-market-context. Smallest dependency footprint. |
openai |
OpenAI function-calling loop using openai-agents-prediction-markets. |
langchain |
LangGraph ReAct agent using langchain-prediction-markets. |
If you don't pass --framework, the CLI prompts interactively.
import { world, edges, market } from 'prediction-market-context'
async function main() {
const state = await world()
console.log('Uncertainty:', state.index.uncertainty)
console.log('Regime:', state.regimeSummary)
const { edges: edgeList } = await edges()
for (const e of edgeList.slice(0, 3)) {
console.log(`Edge: ${e.title} (${e.executableEdge}c)`)
}
}
main().catch(console.error)import OpenAI from 'openai'
import { predictionMarketFunctions, handleFunctionCall } from 'openai-agents-prediction-markets'
const openai = new OpenAI()
// ... full chat-completions loop with tool dispatchimport { ChatOpenAI } from '@langchain/openai'
import { createReactAgent } from '@langchain/langgraph/prebuilt'
import { predictionMarketTools } from 'langchain-prediction-markets'
const agent = createReactAgent({
llm: new ChatOpenAI({ model: 'gpt-4o' }),
tools: predictionMarketTools(),
})cd my-agent
npm install
cp .env.example .env # add OPENAI_API_KEY
npm startVersions before 2.1.0 had two issues with the generated vanilla template:
- The
console.logstatement used escaped backticks (\\\``) inside the template literal, which produced malformedconsole.log(`Edge: ${...}`)` output that crashed at parse time. - An orphan top-level
index.mjscarried a separate scaffolder implementation referencing the dead/api/public/market/{ticker}endpoint.
Both are fixed: the generated agent.ts is valid TypeScript, and the orphan
file is gone.
This scaffolder is the entry point — the wrapper packages do the actual work. If you already know which framework you want, use the wrapper directly:
| Stack | Package |
|---|---|
| Vanilla TS / agnostic | prediction-market-context |
| OpenAI Agents SDK | openai-agents-prediction-markets |
| LangChain / LangGraph | langchain-prediction-markets |
| Vercel AI SDK | vercel-ai-prediction-markets |
| CrewAI (Python) | crewai-prediction-markets |
| MCP / Claude / Cursor | simplefunctions-cli, prediction-market-mcp-example |
npm test14 unit tests covering every template's structure (no calls to dead endpoints, JSON validity for the package.json generators, regression test for the escaped-backtick bug).
MIT — built by SimpleFunctions.