QuickstartCopy pagePrerequisites ItemValueNode.js18+API keyJOY_TOKEN_API_KEYModelauto Step 1: Install $npm install @joytoken/agent-sdk-ts Step 2: Set the API Key $export JOY_TOKEN_API_KEY="jt_xxx" Step 3: Create an Agent 1import { Agent, createJoyTokenProvider, stepCountIs } from "@joytoken/agent-sdk-ts";23const agent = new Agent({4 model: createJoyTokenProvider(),5 modelName: "auto",6 system: "You are a concise assistant.",7 stopWhen: [stepCountIs(4)],8});910const result = await agent.run("Reply with exactly: pong");1112console.log(result.finalText);13console.log(result.usage.totalTokens); Step 4: Check the Result PlaceExpected resultProgram outputpongJoyToken LogsRequest path is /openai/v1/chat/completionsJoyToken UsageTokens and credits are attributed to this key Common Errors ErrorFix401 UnauthorizedCheck JOY_TOKEN_API_KEYAgent does not stopAdd stepCountIs or maxToolCallsfinalText is emptyCheck whether the model returned a tool call, or inspect result.messages Next Steps Examples TypeScript SDK Client SDK