Skip to content

Integrating Generic OpenAI-Compatible Tools ​

The one rule

Change base_url to https://api.tokensg.ai/v1. That's it. Every tool in the OpenAI ecosystem — CLIs, IDE plugins, SDKs, agent frameworks — reads this value from a config file or constructor argument. Once you redirect it at TokenSG, streaming, tool use, system prompts, and every other Chat Completions feature continue to work unchanged.

This page is the umbrella reference for tools that don't yet have a dedicated integration page. If your tool isn't listed, use the matrix below as a template — 95% of OpenAI-compatible tools follow the same pattern.

Prerequisites ​

  • Registered at TokenSG Console with credits available (free tier included)
  • Created an API Key on the API Keys page (format sk-xxx...)

Tool matrix ​

The endpoint you'll use everywhere:

https://api.tokensg.ai/v1
ToolWhere to set itConfig keyExample value
OpenAI Python SDKOpenAI(...) constructorbase_urlhttps://api.tokensg.ai/v1
OpenAI Node.js SDKnew OpenAI({...}) constructorbaseURLhttps://api.tokensg.ai/v1
CursorSettings → Models → Override OpenAI Base URLUI text fieldhttps://api.tokensg.ai/v1
Cline (VS Code)API Provider → OpenAI CompatibleAPI Base URLhttps://api.tokensg.ai/v1
Continue.dev~/.continue/config.yaml → models[].apiBaseapiBasehttps://api.tokensg.ai/v1
Zed AIsettings.json → assistant.providers → openai.api_urlapi_urlhttps://api.tokensg.ai/v1
Vercel AI SDK (@ai-sdk/openai)createOpenAI({...})baseURLhttps://api.tokensg.ai/v1
LangChain (Python)ChatOpenAI(...)openai_api_basehttps://api.tokensg.ai/v1
LlamaIndex (Python)OpenAI(...) constructorapi_basehttps://api.tokensg.ai/v1
LiteLLMlitellm.api_base or env OPENAI_API_BASEapi_basehttps://api.tokensg.ai/v1
AiderCLI flag or env--openai-api-base / OPENAI_API_BASEhttps://api.tokensg.ai/v1
Open WebUI / Chatbot UISettings → OpenAI API Base URLUI text fieldhttps://api.tokensg.ai/v1

Pair whichever key field it uses (api_key, apiKey, OPENAI_API_KEY, etc.) with your TokenSG key (sk-...). No code changes beyond that.

Worked examples ​

OpenAI Python SDK ​

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-tokensg-key",
    base_url="https://api.tokensg.ai/v1",
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

OpenAI Node.js SDK ​

javascript
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: 'sk-your-tokensg-key',
  baseURL: 'https://api.tokensg.ai/v1',
})

const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(response.choices[0].message.content)

Vercel AI SDK (@ai-sdk/openai) ​

typescript
import { createOpenAI } from '@ai-sdk/openai'
import { generateText } from 'ai'

const tokensg = createOpenAI({
  apiKey: process.env.TOKENSG_API_KEY,
  baseURL: 'https://api.tokensg.ai/v1',
})

const { text } = await generateText({
  model: tokensg('gpt-4o'),
  prompt: 'Hello!',
})
console.log(text)

LangChain (Python) ​

python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-4o",
    openai_api_key="sk-your-tokensg-key",
    openai_api_base="https://api.tokensg.ai/v1",
)
print(llm.invoke("Hello!").content)

Continue.dev (~/.continue/config.yaml) ​

yaml
models:
  - name: TokenSG GPT-4o
    provider: openai
    model: gpt-4o
    apiKey: sk-your-tokensg-key
    apiBase: https://api.tokensg.ai/v1
  - name: TokenSG Claude Sonnet 4.6
    provider: openai
    model: claude-sonnet-4-6
    apiKey: sk-your-tokensg-key
    apiBase: https://api.tokensg.ai/v1

Cursor ​

  1. Open Settings (⌘/Ctrl ,) → Models pane
  2. Enable Override OpenAI Base URL and set it to https://api.tokensg.ai/v1
  3. In the OpenAI API Key field, paste your TokenSG key (sk-...)
  4. Click Verify — a green tick means you're connected

Custom model IDs in Cursor

Cursor's model dropdown shows OpenAI-native model names. Add TokenSG-specific IDs (like claude-sonnet-4-6 or gemini-2.5-pro) via Add Custom Model → type the ID and save.

Verifying the connection ​

After sending a test request from any of the tools above:

  1. Log into the Console → Request Logs to confirm the request landed
  2. Or watch the Today's Usage card on the Dashboard for credit consumption

A new row in the log = you're connected.

Common pitfalls ​

Trailing /v1 ​

Always include /v1 in base_url — TokenSG's Chat Completions endpoint is https://api.tokensg.ai/v1/chat/completions. Anthropic SDK users in Claude Code omit /v1 because the SDK auto-appends it; OpenAI SDKs do not auto-append, so you must write the full /v1.

Model ID mismatches ​

Tools that hardcode a model-picker dropdown may request IDs TokenSG doesn't ship (e.g. gpt-4). The request reaches TokenSG and comes back as 404 model not found. Fix: change the model to an ID listed in /v1/models (or the Models page).

Proxy / firewall ​

Corporate http_proxy settings sometimes intercept the TokenSG domain. Exclude it:

bash
export NO_PROXY="api.tokensg.ai"

Custom CA chains:

bash
export NODE_EXTRA_CA_CERTS=/path/to/your-ca-chain.pem

401 auth failures ​

  • Check key status / expiry on the API Keys page
  • Confirm the tool actually sends Authorization: Bearer <key> (some tools mis-label the field — if in doubt, enable verbose logging and inspect the header)

402 insufficient balance ​

TokenSG deducts per-token in real time. When your balance runs out, requests return 402 or insufficient_balance. Top up on the wallet page, or enable auto-topup.

Don't see your tool? ​

If you got a tool working with TokenSG via the "change the base URL" pattern, we'd love a PR with a dedicated guide — open one at github.com/xmai-ai/xmai-docs or ping the team in-app. The matrix above stays authoritative; every new page is a link from here.