First API call
Create a key, configure the OpenAI SDK and send a non-streaming Chat Completions request.
Open tutorialTutorials
Use these tutorials to connect a compatible SDK, compare Chinese model routes and add the operational habits needed before a real customer-facing rollout.
Create a key, configure the OpenAI SDK and send a non-streaming Chat Completions request.
Open tutorialUse stream: true, read server-sent events and show partial output in a chat interface or CLI.
Open tutorialCompare DeepSeek, Qwen and Kimi on the same prompt set before choosing a default route.
Open tutorialMove China-model traffic from OpenRouter-style routing to SmarToken with a controlled evaluation run.
Open tutorialSeparate keys by service, rotate exposed keys and keep private secrets out of browser code.
Open tutorialEstimate token spend, review wallet history and decide when to use a lower-cost route.
Open tutorialQuickstart path
A successful first call should prove authentication, endpoint configuration, model ID and basic logging. It does not need to solve every production concern on day one.
01
Sign in, create an API key in the console and store it as SMTOKEN_API_KEY in your backend or local secret store.
02
Keep the OpenAI SDK, but set baseURL to the SmarToken /v1 endpoint so requests go through the gateway.
03
Start with a task-specific route such as deepseek-chat for coding value, kimi-k2 for long context or qwen-plus for multilingual application behavior.
04
Save prompt, answer, model, latency and cost for the first test set so route changes are based on evidence.
SDK sample
Keep secrets out of frontend code. This sample belongs in a backend route, server action, worker or CLI environment where environment variables are private.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.SMTOKEN_API_KEY,
baseURL: "https://thesmartoken.com/v1",
});
const response = await client.chat.completions.create({
model: "deepseek-chat",
messages: [{ role: "user", content: "Give me a short migration checklist." }],
});
console.log(response.choices[0]?.message?.content);Troubleshooting
Most early issues come from key handling, balance, concurrency or model selection. Fix those before assuming the model route is unsuitable.
| Symptom | First check |
|---|---|
| 401 Unauthorized | Check the Bearer token, confirm the key was not revoked and make sure the request is sent server-side. |
| 429 Rate limited | Reduce concurrency, add exponential backoff and retry later. Include timestamp and model ID if filing a ticket. |
| Insufficient balance | Add balance, shorten the prompt or choose a lower-cost model before retrying the request. |
| Unexpected output | Compare the same prompt across two routes and add examples, format constraints or retrieval context. |
Once the first call works, compare models on a real workflow and estimate production cost before scaling traffic.