Skip to content

Integrating Generic OpenAI-Compatible Tools

The one rule

Change base_url to https://api.xmai.sg/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 xmAI, 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 XmAI 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.xmai.sg/v1
ToolWhere to set itConfig keyExample value
OpenAI Python SDKOpenAI(...) constructorbase_urlhttps://api.xmai.sg/v1
OpenAI Node.js SDKnew OpenAI({...}) constructorbaseURLhttps://api.xmai.sg/v1
CursorSettings → Models → Override OpenAI Base URLUI text fieldhttps://api.xmai.sg/v1
Cline (VS Code)API Provider → OpenAI CompatibleAPI Base URLhttps://api.xmai.sg/v1
Continue.dev~/.continue/config.yamlmodels[].apiBaseapiBasehttps://api.xmai.sg/v1
Zed AIsettings.jsonassistant.providersopenai.api_urlapi_urlhttps://api.xmai.sg/v1
Vercel AI SDK (@ai-sdk/openai)createOpenAI({...})baseURLhttps://api.xmai.sg/v1
LangChain (Python)ChatOpenAI(...)openai_api_basehttps://api.xmai.sg/v1
LlamaIndex (Python)OpenAI(...) constructorapi_basehttps://api.xmai.sg/v1
LiteLLMlitellm.api_base or env OPENAI_API_BASEapi_basehttps://api.xmai.sg/v1
AiderCLI flag or env--openai-api-base / OPENAI_API_BASEhttps://api.xmai.sg/v1
Open WebUI / Chatbot UISettings → OpenAI API Base URLUI text fieldhttps://api.xmai.sg/v1

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

Worked examples

OpenAI Python SDK

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-xmai-key",
    base_url="https://api.xmai.sg/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-xmai-key',
  baseURL: 'https://api.xmai.sg/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 xmai = createOpenAI({
  apiKey: process.env.XMAI_API_KEY,
  baseURL: 'https://api.xmai.sg/v1',
})

const { text } = await generateText({
  model: xmai('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-xmai-key",
    openai_api_base="https://api.xmai.sg/v1",
)
print(llm.invoke("Hello!").content)

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

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

Cursor

  1. Open Settings (⌘/Ctrl ,) → Models pane
  2. Enable Override OpenAI Base URL and set it to https://api.xmai.sg/v1
  3. In the OpenAI API Key field, paste your xmAI 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 xmAI-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 ConsoleRequest 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 — xmAI's Chat Completions endpoint is https://api.xmai.sg/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 xmAI doesn't ship (e.g. gpt-4). The request reaches xmAI 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 xmAI domain. Exclude it:

bash
export NO_PROXY="api.xmai.sg"

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

xmAI 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 xmAI 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.

The Unified API for LLMs