Quickstart

JoyToken is an OpenAI-compatible model gateway. Your application sends model requests to JoyToken, and JoyToken handles API keys, routing, policies, wallet limits, usage, and billing attribution.

Required Values

ItemValue
API keyJOY_TOKEN_API_KEY=jt_xxx
OpenAI-compatible base URLJOY_TOKEN_OPENAI_BASE_URL from Environments
Starting modelauto
Request IDX-Request-ID: quickstart-001

Step 1: Set the Environment

$export JOY_TOKEN_API_KEY="jt_xxx"
$export JOY_TOKEN_OPENAI_BASE_URL="https://api-dev.joytokens.ai/openai/v1"

Keep API keys in server-side environment variables, secret managers, or CI/CD secrets. Do not put them in browsers, mobile apps, public repositories, or logs.

Step 2: Send a Request

$curl "$JOY_TOKEN_OPENAI_BASE_URL/chat/completions" \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $JOY_TOKEN_API_KEY" \
> -H "X-Request-ID: quickstart-001" \
> -d '{
> "model": "auto",
> "messages": [
> { "role": "user", "content": "Reply with exactly: pong" }
> ],
> "stream": false
> }'

A successful response includes model output in choices[0].message.content.

Step 3: Use the OpenAI SDK

1import OpenAI from "openai";
2
3const client = new OpenAI({
4 apiKey: process.env.JOY_TOKEN_API_KEY,
5 baseURL: process.env.JOY_TOKEN_OPENAI_BASE_URL,
6});
7
8const response = await client.chat.completions.create({
9 model: "auto",
10 messages: [{ role: "user", content: "Reply with exactly: pong" }],
11});
12
13console.log(response.choices[0]?.message?.content);

Step 4: Check the Integration

PlaceExpected result
HTTP responsechoices[0].message.content has content
Response headersX-DAOE-Used-Model and X-DAOE-Used-Provider
JoyToken ConsoleLogs and usage are attributed to this API key

Choose a Next Step

GoalPage
API keys and server-side proxyAuthentication
auto and pinned modelsModels
tiers, pinned models, and wallet fallbackRouting
API key policy and budgetGuardrails
Credits and usage attributionUsage & Billing
status codes and debuggingTroubleshooting