Use OpenAI SDK (Python / Node.js) with TokenMaster

The official OpenAI SDKs work unchanged — point base_url at TokenMaster and use any model ID, including Claude, Gemini and DeepSeek.

You will need

  • An API key starting with tm- (Console → API keys) — Get an API key
  • Base URL: https://tokenmaster.store/v1
  • A model ID, e.g. anthropic/claude-sonnet-5.5 (see the model list)

Setup

  1. Install the SDK (pip install openai or npm i openai).
  2. Create the client with TokenMaster's base URL and call chat.completions.create.
import os
from openai import OpenAI

client = OpenAI(base_url="https://tokenmaster.store/v1", api_key=os.environ["TOKENMASTER_API_KEY"])
resp = client.chat.completions.create(
    model="anthropic/claude-sonnet-5.5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://tokenmaster.store/v1", apiKey: process.env.TOKENMASTER_API_KEY });
const resp = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5.5",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);

Good to know

  • chat.completions, responses.create (stateless — send the whole conversation; no previous_response_id or hosted tools), embeddings (e.g. baai/bge-m3) and models.list() are available; images returns 404.
  • Not available through TokenMaster: image generation, speech, rerank, the Assistants API, and OpenAI-hosted tools. Chat Completions, the Responses API (stateless), the Anthropic Messages API and embeddings are available.

Checked against OpenAI SDK (Python / Node.js) openai-python 3 / openai-node 7 on 2026-10-19. Menu names can change between versions.

Troubleshooting

  • 401 / invalid API key — check the key was copied in full and has not been deleted in the console.
  • 404 — the base URL is wrong. It must end in /v1 unless the guide says otherwise.
  • Model not found / not available — use the exact ID from the model list (vendor/model, lowercase). Some vendors are not available in every region.
  • Errors mentioning /responses — the tool is using OpenAI's Responses API. TokenMaster accepts it, but statelessly (no previous_response_id) and without OpenAI-hosted tools; if the tool relies on those, switch it to Chat Completions as noted above.
  • 402 / insufficient balance — top up in the console; requests are refused rather than run up a debt.

SDKs & frameworks

All integration guides → · All model prices →