SDK base URL quickcheck

Check OpenAI SDK base URL config before routing to TKEN

Run a no-network guard before changing an existing Node.js or Python OpenAI SDK app. Confirm the TKEN /v1 base URL shape, API-key environment boundary, model-selection readiness, JSON output, and strict CI behavior before the first live endpoint call.

No-network config guard networkRequests: 0
git clone https://github.com/vivian254338489/tken-openai-compatible-examples.git
cd tken-openai-compatible-examples

$env:TKEN_BASE_URL="https://www.tken.shop/v1"
$env:TKEN_API_KEY="sk-your-tken-key"
$env:TKEN_MODEL="replace-with-an-available-model"

node tools/openai-sdk-base-url-quickcheck.mjs --strict --json
No network requests and no key values printed
Catches base URLs missing the /v1 suffix
Prepares Node.js baseURL and Python base_url migrations

What the quickcheck proves

The tool does not prove that every model or optional endpoint is available. It proves that the local SDK configuration is shaped correctly enough to move into live model discovery without wasting time on homepage URLs, missing environment variables, or accidental direct-provider traffic.

Base URL
Absolute URL ending in /v1
Environment
API key present without printing value
Model
Reminds you to choose from /models
JSON output
Machine-readable CI preflight result
Strict mode
Fails on missing key or model env
Network
networkRequests: 0 before endpoint tests

Migration sequence

1. Run the no-network quickcheck

Start with the local configuration guard. It should pass before any SDK call, endpoint tester, CI step, or app workflow points at the TKEN base URL.

node tools/openai-sdk-base-url-quickcheck.mjs --json

2. Verify model discovery

After the config shape is correct, call /models and select a model ID returned for the current key and account. Do not assume that a model name copied from another provider route is available.

node tools/endpoint-tester.mjs --base-url "$TKEN_BASE_URL" --api-key-env TKEN_API_KEY --skip-chat

3. Send one small chat request

Use a non-sensitive prompt, the selected model ID, and one non-streaming /chat/completions request before testing streaming, tool calls, JSON mode, embeddings, or production traffic.

node tools/endpoint-tester.mjs --base-url "$TKEN_BASE_URL" --api-key-env TKEN_API_KEY --model "$TKEN_MODEL"

4. Move one SDK call

Switch one low-risk SDK call to TKEN, keep timeout and retry limits conservative, then expand only after the app-level response shape is confirmed.

SDK setting matrix

TKEN examples use `TKEN_BASE_URL` and `TKEN_API_KEY` so gateway traffic is visibly separated from direct provider traffic. If an app already depends on `OPENAI_BASE_URL`, confirm the runtime config path before changing shared environment variables.

Node.js SDK
baseURL: process.env.TKEN_BASE_URL
Python SDK
base_url=os.environ["TKEN_BASE_URL"]
Default env
OPENAI_BASE_URL is SDK-specific
TKEN value
https://www.tken.shop/v1

Common failure map

404 on /models

The app may be pointing at https://www.tken.shop instead of https://www.tken.shop/v1. Run the quickcheck with the exact base URL before debugging SDK payloads.

401 or unauthorized

Confirm the API-key environment variable is present without printing it. Then verify the key is scoped to the route and account you are testing.

Model not found

Re-run /models and choose a returned ID. Treat model availability as account and route specific, not implied by SDK compatibility.

Works locally but fails in CI

Add `--strict --json` before the live endpoint test so missing environment variables fail early with a compact machine-readable result.

TKEN is an independent third-party OpenAI-compatible API gateway and is not officially affiliated with OpenAI or other model providers. Model availability, pricing, context limits, streaming behavior, tool support, and rate limits can vary by account, channel, and provider status. Live /pricing remains the source of truth.

SDK quickcheck FAQ

Why run this before an endpoint smoke test?

It catches configuration mistakes that do not require a network call, such as a missing /v1 suffix, missing key environment variable, or absent model-selection variable in strict mode.

Does passing mean the selected model supports every SDK feature?

No. Passing means the SDK configuration is ready for model discovery. Test streaming, JSON mode, tool calls, embeddings, and other endpoint-specific behavior separately.

Where is the release?

The v0.24.0 examples release includes the quickcheck tool, documentation, package script, and local validation coverage. Open the v0.24.0 release.

Can I adapt it for another OpenAI-compatible endpoint?

Yes. Pass a different base URL and API-key environment variable, then keep the same no-key-printing and no-network guardrails.

Validate config before moving SDK traffic

Create a TKEN key, set https://www.tken.shop/v1 as the base URL, run the quickcheck, then use /models and one chat request to prove the live endpoint path.