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| Tool | Where to set it | Config key | Example value |
|---|---|---|---|
| OpenAI Python SDK | OpenAI(...) constructor | base_url | https://api.xmai.sg/v1 |
| OpenAI Node.js SDK | new OpenAI({...}) constructor | baseURL | https://api.xmai.sg/v1 |
| Cursor | Settings → Models → Override OpenAI Base URL | UI text field | https://api.xmai.sg/v1 |
| Cline (VS Code) | API Provider → OpenAI Compatible | API Base URL | https://api.xmai.sg/v1 |
| Continue.dev | ~/.continue/config.yaml → models[].apiBase | apiBase | https://api.xmai.sg/v1 |
| Zed AI | settings.json → assistant.providers → openai.api_url | api_url | https://api.xmai.sg/v1 |
Vercel AI SDK (@ai-sdk/openai) | createOpenAI({...}) | baseURL | https://api.xmai.sg/v1 |
| LangChain (Python) | ChatOpenAI(...) | openai_api_base | https://api.xmai.sg/v1 |
| LlamaIndex (Python) | OpenAI(...) constructor | api_base | https://api.xmai.sg/v1 |
| LiteLLM | litellm.api_base or env OPENAI_API_BASE | api_base | https://api.xmai.sg/v1 |
| Aider | CLI flag or env | --openai-api-base / OPENAI_API_BASE | https://api.xmai.sg/v1 |
| Open WebUI / Chatbot UI | Settings → OpenAI API Base URL | UI text field | https://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
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
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)
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)
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)
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/v1Cursor
- Open Settings (⌘/Ctrl ,) → Models pane
- Enable Override OpenAI Base URL and set it to
https://api.xmai.sg/v1 - In the OpenAI API Key field, paste your xmAI key (
sk-...) - 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:
- Log into the Console → Request Logs to confirm the request landed
- 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:
export NO_PROXY="api.xmai.sg"Custom CA chains:
export NODE_EXTRA_CA_CERTS=/path/to/your-ca-chain.pem401 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.
Related
- Quick Start — SDK-level example with Python / Node / Go / curl
- Chat Completions API — the underlying API
- Models — available models and pricing
- Error Codes — error handling guide
- Claude Code — Anthropic-native setup
- OpenCode — open-source agentic client
- Codex CLI — OpenAI's official terminal agent
- Gemini CLI — why Gemini CLI itself is a poor fit + workaround