Published · AI-generated, automated fact-check against live catalog · 中文版
OpenAI SDK Works With Any Model: Here's How
TL;DR: You don't need to use OpenAI's proprietary models to use the OpenAI SDK. TokShop provides an OpenAI-compatible endpoint that lets you plug open-source models like DeepSeek V3.2, GLM 4.6, and Kimi K2 into any existing OpenAI SDK integration—just change the base URL and API key, and your code works as-is.
Why "OpenAI" in Search Doesn't Mean You're Stuck With OpenAI
When people search "openai" right now, they're often reacting to news like ChatGPT controlling iMessage on Mac—a feature that raises legitimate privacy questions about Apple's closed ecosystem. But the deeper intent behind that search is usually: "How do I get AI capabilities without being locked into one vendor?"
The answer is simpler than most developers expect. The OpenAI SDK has become the de facto standard interface for LLM APIs, and many open-source model providers—including TokShop—have built their APIs to be fully compatible with it. This means you can use the same openai Python package or curl commands you already know, but point them at models that cost a fraction of OpenAI's pricing and run on open weights you can audit.
How to Switch From OpenAI to Open-Source Models in 3 Lines
The core insight is that TokShop's API is designed as a drop-in replacement. You change the base_url and your API key, and everything else—function calling, streaming, embeddings, chat completions—works identically.
Here's a minimal Python example using the standard openai package:
from openai import OpenAI
client = OpenAI(
base_url="https://tokshop.xyz/v1", # just swap this
api_key="sk-tok-..." # and your key
)
response = client.chat.completions.create(
model="deepseek-v3.2", # any model on TokShop
messages=[{"role": "user", "content": "Explain how API compatibility works."}]
)
print(response.choices[0].message.content)
For a quick test with curl, it's equally straightforward:
curl https://tokshop.xyz/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-tok-..." \
-d '{
"model": "glm-4.6",
"messages": [{"role": "user", "content": "Hello!"}]
}'
No special SDK, no custom client, no vendor-specific boilerplate. If your code currently works with OpenAI's API, it will work with TokShop after changing two values.
What Models Can You Actually Use Through the OpenAI SDK?
TokShop currently offers several open-source models, each with different strengths and price points. Here's a comparison of what you get per million tokens:
| Model | Context Window | Input Price (per 1M tokens) | Output Price (per 1M tokens) | Best For |
|---|---|---|---|---|
| DeepSeek V3.2 | 128,000 | $0.42 | $0.63 | Budget-friendly general tasks |
| GLM 4.6 | 200,000 | $0.90 | $3.30 | Long documents, balanced cost |
| Kimi K2 | 131,072 | $0.855 | $3.45 | Reasoning and analysis |
| Qwen3 Coder | 262,144 | $2.25 | $11.25 | Code generation, large contexts |
The pricing difference is stark. DeepSeek V3.2's input price is roughly 30x cheaper than OpenAI's GPT-4o tier, and even the most expensive option here—Qwen3 Coder—costs significantly less than OpenAI's code-specific models as of recent reports. For teams processing millions of tokens daily, that difference is real money.
What About the Apple iMessage Privacy Concerns?
The recent news about ChatGPT controlling iMessage on Mac raises a valid concern: when your AI assistant can read and send your texts, you're trusting that vendor with highly sensitive personal data. OpenAI's privacy policy allows them to use your conversations to improve their models unless you explicitly opt out, and the iMessage integration means those messages could become training data.
Open-source models don't automatically solve this problem—your data still passes through whatever API provider you choose. But they give you options. With TokShop, there are no model-training clauses in the API terms; your prompts and completions are used solely to serve your requests, not to improve the models. And because the models are open-weight, you can eventually self-host them if privacy requirements become strict enough.
For developers building on Mac, the practical takeaway is: if you're already using the OpenAI SDK for iMessage-related automation, you can switch to a cheaper, more private model through TokShop without rewriting your automation logic. The same client.chat.completions.create call works, just with a different endpoint.
How Does Billing Work When You Switch?
TokShop uses a simple prepaid credit system. You add USD credits to your account, and every API call deducts the exact cost based on token usage. When your balance hits zero, the API returns an HTTP 402 insufficient_balance error—no surprise invoices, no monthly minimums.
This model is particularly nice for developers who are tired of OpenAI's tiered rate limits and usage-based billing that can spike unpredictably. With TokShop, you see exactly what each call costs in your dashboard, with per-request token counts logged. You can check pricing details to estimate costs before committing.
For a typical integration, here's what a simple request costs with DeepSeek V3.2:
- A 500-token input prompt and 300-token output: $0.00021 + $0.000189 = $0.000399
- 10,000 such requests per month: $3.99
Compare that to equivalent OpenAI pricing, and you'll often find 10-20x savings on high-volume workloads.
Is There Any Downside to Using Open-Source Models?
Honest trade-offs matter. Open-source models via TokShop aren't universally "better" than OpenAI's offerings—they're different tools. Here's what to watch for:
- Benchmark variance: Open-source models can match or exceed OpenAI on specific tasks (like coding with Qwen3 Coder), but they may lag on nuanced instruction-following or creative writing. Test on your actual workload.
- Ecosystem maturity: OpenAI has more third-party tooling, plugins, and community examples. The OpenAI SDK compatibility helps, but some advanced features (like vision or audio) may not be available on all models.
- Support and uptime: OpenAI has enterprise SLAs; TokShop is a developer-focused service. For production-critical workloads, check the docs for rate limits and availability expectations.
The key is to treat model selection as a configurable choice, not a permanent commitment. Because TokShop's API is OpenAI-compatible, you can A/B test models side-by-side with the same codebase and switch when one performs better for your use case.
FAQ
Can I use the OpenAI Python SDK with TokShop without changing my code?
Yes, with one exception: you must change the base_url to https://tokshop.xyz/v1 and use a TokShop API key. All other SDK methods—chat completions, streaming, function calling—work identically because TokShop implements the OpenAI API specification.
Do open-source models on TokShop support function calling and streaming?
Yes, the models that support these features through the OpenAI API will work through TokShop. However, you should verify in the documentation which specific models support function calling, as it varies by model. Streaming works across all models.
How do I get an API key for TokShop?
Sign up at https://tokshop.xyz/register with your email and password, then create an API key in the dashboard. Keys are displayed only once at creation, so save them securely. They follow the format sk-tok-... and are used as the Authorization bearer token in requests.
All models discussed are live on our OpenAI-compatible API with transparent per-token pricing. See pricing and get a key →